LCOV - code coverage report
Current view: top level - gcc/rust/typecheck - rust-hir-type-check-type.h (source / functions) Coverage Total Hit
Test: gcc.info Lines: 64.7 % 17 11
Test Date: 2025-06-21 16:26:05 Functions: 25.0 % 4 1
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: - 0 0

             Branch data     Line data    Source code
       1                 :             : // Copyright (C) 2020-2025 Free Software Foundation, Inc.
       2                 :             : 
       3                 :             : // This file is part of GCC.
       4                 :             : 
       5                 :             : // GCC is free software; you can redistribute it and/or modify it under
       6                 :             : // the terms of the GNU General Public License as published by the Free
       7                 :             : // Software Foundation; either version 3, or (at your option) any later
       8                 :             : // version.
       9                 :             : 
      10                 :             : // GCC is distributed in the hope that it will be useful, but WITHOUT ANY
      11                 :             : // WARRANTY; without even the implied warranty of MERCHANTABILITY or
      12                 :             : // FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
      13                 :             : // for more details.
      14                 :             : 
      15                 :             : // You should have received a copy of the GNU General Public License
      16                 :             : // along with GCC; see the file COPYING3.  If not see
      17                 :             : // <http://www.gnu.org/licenses/>.
      18                 :             : 
      19                 :             : #ifndef RUST_HIR_TYPE_CHECK_TYPE
      20                 :             : #define RUST_HIR_TYPE_CHECK_TYPE
      21                 :             : 
      22                 :             : #include "rust-hir-type-check-base.h"
      23                 :             : #include "rust-hir-visitor.h"
      24                 :             : 
      25                 :             : namespace Rust {
      26                 :             : namespace Resolver {
      27                 :             : 
      28                 :             : // FIXME
      29                 :             : // This simply fetches the HIR:::GenericArgs from the base class. Check to see
      30                 :             : // if we can get rid of this class
      31                 :           0 : class TypeCheckResolveGenericArguments : public TypeCheckBase
      32                 :             : {
      33                 :             : public:
      34                 :             :   static HIR::GenericArgs resolve (HIR::TypePathSegment &segment);
      35                 :             : 
      36                 :             :   void visit (HIR::TypePathSegmentGeneric &generic);
      37                 :             : 
      38                 :             : private:
      39                 :           0 :   TypeCheckResolveGenericArguments (location_t locus)
      40                 :           0 :     : TypeCheckBase (), args (HIR::GenericArgs::create_empty (locus))
      41                 :           0 :   {}
      42                 :             : 
      43                 :             :   HIR::GenericArgs args;
      44                 :             : };
      45                 :             : 
      46                 :       52256 : class TypeCheckType : public TypeCheckBase, public HIR::HIRTypeVisitor
      47                 :             : {
      48                 :             : public:
      49                 :             :   static TyTy::BaseType *Resolve (HIR::Type &type);
      50                 :             : 
      51                 :             :   void visit (HIR::BareFunctionType &fntype) override;
      52                 :             :   void visit (HIR::TupleType &tuple) override;
      53                 :             :   void visit (HIR::TypePath &path) override;
      54                 :             :   void visit (HIR::QualifiedPathInType &path) override;
      55                 :             :   void visit (HIR::ArrayType &type) override;
      56                 :             :   void visit (HIR::SliceType &type) override;
      57                 :             :   void visit (HIR::ReferenceType &type) override;
      58                 :             :   void visit (HIR::RawPointerType &type) override;
      59                 :             :   void visit (HIR::InferredType &type) override;
      60                 :             :   void visit (HIR::NeverType &type) override;
      61                 :             :   void visit (HIR::TraitObjectType &type) override;
      62                 :             :   void visit (HIR::ParenthesisedType &type) override;
      63                 :             :   void visit (HIR::ImplTraitType &type) override;
      64                 :             : 
      65                 :             :   // These dont need to be implemented as they are segments or part of types
      66                 :           0 :   void visit (HIR::TypePathSegmentFunction &segment) override {}
      67                 :           0 :   void visit (HIR::TraitBound &bound) override {}
      68                 :             : 
      69                 :             : private:
      70                 :       52256 :   TypeCheckType (HirId id)
      71                 :       52256 :     : TypeCheckBase (), translated (new TyTy::ErrorType (id))
      72                 :       52256 :   {}
      73                 :             : 
      74                 :             :   TyTy::BaseType *resolve_root_path (HIR::TypePath &path, size_t *offset,
      75                 :             :                                      bool *wasBigSelf);
      76                 :             : 
      77                 :             :   TyTy::BaseType *resolve_segments (
      78                 :             :     HirId expr_id, std::vector<std::unique_ptr<HIR::TypePathSegment>> &segments,
      79                 :             :     size_t offset, TyTy::BaseType *tyseg,
      80                 :             :     const Analysis::NodeMapping &expr_mappings, location_t expr_locus,
      81                 :             :     bool tySegIsBigSelf);
      82                 :             : 
      83                 :             :   bool resolve_associated_type (const std::string &search,
      84                 :             :                                 TypeCheckBlockContextItem &ctx,
      85                 :             :                                 TyTy::BaseType **result);
      86                 :             : 
      87                 :             :   TyTy::BaseType *translated;
      88                 :             : };
      89                 :             : 
      90                 :       19558 : class TypeResolveGenericParam : public TypeCheckBase
      91                 :             : {
      92                 :             : public:
      93                 :             :   static TyTy::ParamType *Resolve (HIR::GenericParam &param,
      94                 :             :                                    bool resolve_trait_bounds = true,
      95                 :             :                                    bool apply_sized = true);
      96                 :             : 
      97                 :             :   static void ApplyAnyTraitBounds (HIR::TypeParam &param, TyTy::ParamType *pty);
      98                 :             : 
      99                 :             : protected:
     100                 :             :   void visit (HIR::TypeParam &param);
     101                 :             :   void visit (HIR::LifetimeParam &param);
     102                 :             :   void visit (HIR::ConstGenericParam &param);
     103                 :             : 
     104                 :             :   void apply_trait_bounds (HIR::TypeParam &param, TyTy::ParamType *pty);
     105                 :             : 
     106                 :             : private:
     107                 :       19560 :   TypeResolveGenericParam (bool apply_sized, bool resolve_trait_bounds)
     108                 :       39120 :     : TypeCheckBase (), resolved (nullptr), apply_sized (apply_sized),
     109                 :       19560 :       resolve_trait_bounds (resolve_trait_bounds)
     110                 :             :   {}
     111                 :             : 
     112                 :             :   TyTy::ParamType *resolved;
     113                 :             :   bool apply_sized;
     114                 :             :   bool resolve_trait_bounds;
     115                 :             : };
     116                 :             : 
     117                 :         508 : class ResolveWhereClauseItem : public TypeCheckBase
     118                 :             : {
     119                 :             :   // pair(a, b) => a: b
     120                 :             :   TyTy::RegionConstraints &region_constraints;
     121                 :             : 
     122                 :             : public:
     123                 :             :   static void Resolve (HIR::WhereClauseItem &item,
     124                 :             :                        TyTy::RegionConstraints &region_constraints);
     125                 :             : 
     126                 :             : protected:
     127                 :             :   void visit (HIR::LifetimeWhereClauseItem &item);
     128                 :             :   void visit (HIR::TypeBoundWhereClauseItem &item);
     129                 :             : 
     130                 :             : private:
     131                 :         508 :   ResolveWhereClauseItem (TyTy::RegionConstraints &region_constraints)
     132                 :         508 :     : region_constraints (region_constraints)
     133                 :             :   {}
     134                 :             : };
     135                 :             : 
     136                 :             : } // namespace Resolver
     137                 :             : } // namespace Rust
     138                 :             : 
     139                 :             : #endif // RUST_HIR_TYPE_CHECK_TYPE
        

Generated by: LCOV version 2.1-beta

LCOV profile is generated on x86_64 machine using following configure options: configure --disable-bootstrap --enable-coverage=opt --enable-languages=c,c++,fortran,go,jit,lto,rust,m2 --enable-host-shared. GCC test suite is run with the built compiler.