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: 2026-10-03 16:17:38 Functions: 25.0 % 4 1
Legend: Lines:     hit not hit

            Line data    Source code
       1              : // Copyright (C) 2020-2026 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        68744 : class TypeCheckType : public TypeCheckBase, public HIR::HIRTypeVisitor
      47              : {
      48              : public:
      49              :   enum class ResolutionMode
      50              :   {
      51              :     REFERENCE,
      52              :     CANONICAL
      53              :   };
      54              : 
      55              :   static TyTy::BaseType *Resolve (HIR::Type &type, ResolutionMode mode
      56              :                                                    = ResolutionMode::REFERENCE);
      57              : 
      58              :   void visit (HIR::BareFunctionType &fntype) override;
      59              :   void visit (HIR::TupleType &tuple) override;
      60              :   void visit (HIR::TypePath &path) override;
      61              :   void visit (HIR::QualifiedPathInType &path) override;
      62              :   void visit (HIR::ArrayType &type) override;
      63              :   void visit (HIR::SliceType &type) override;
      64              :   void visit (HIR::ReferenceType &type) override;
      65              :   void visit (HIR::RawPointerType &type) override;
      66              :   void visit (HIR::InferredType &type) override;
      67              :   void visit (HIR::NeverType &type) override;
      68              :   void visit (HIR::TraitObjectType &type) override;
      69              :   void visit (HIR::ParenthesisedType &type) override;
      70              :   void visit (HIR::ImplTraitType &type) override;
      71              : 
      72              :   // These dont need to be implemented as they are segments or part of types
      73            0 :   void visit (HIR::TypePathSegmentFunction &segment) override {}
      74            0 :   void visit (HIR::TraitBound &bound) override {}
      75              : 
      76              : private:
      77        68745 :   TypeCheckType (HirId id, ResolutionMode mode)
      78        68745 :     : TypeCheckBase (), translated (new TyTy::ErrorType (id)), mode (mode)
      79        68745 :   {}
      80              : 
      81              :   TyTy::BaseType *resolve_root_path (HIR::TypePath &path, size_t *offset,
      82              :                                      bool *wasBigSelf);
      83              : 
      84              :   TyTy::BaseType *resolve_segments (
      85              :     HirId expr_id, std::vector<std::unique_ptr<HIR::TypePathSegment>> &segments,
      86              :     size_t offset, TyTy::BaseType *tyseg,
      87              :     const Analysis::NodeMapping &expr_mappings, location_t expr_locus,
      88              :     bool tySegIsBigSelf);
      89              : 
      90              :   bool resolve_associated_type (const std::string &search,
      91              :                                 TypeCheckBlockContextItem &ctx,
      92              :                                 TyTy::BaseType **result);
      93              : 
      94              :   bool try_resolve_contextual_self_associated_type (
      95              :     const HIR::TypePathSegment &segment, bool first_segment,
      96              :     bool ty_seg_is_big_self, TyTy::BaseType **result);
      97              : 
      98              :   TyTy::BaseType *translated;
      99              :   ResolutionMode mode;
     100              : };
     101              : 
     102        20679 : class TypeResolveGenericParam : public TypeCheckBase
     103              : {
     104              : public:
     105              :   static TyTy::ParamType *Resolve (HIR::GenericParam &param,
     106              :                                    bool resolve_trait_bounds = true,
     107              :                                    bool apply_sized = true);
     108              : 
     109              :   static void ApplyAnyTraitBounds (HIR::TypeParam &param, TyTy::ParamType *pty);
     110              : 
     111              : protected:
     112              :   void visit (HIR::TypeParam &param);
     113              :   void visit (HIR::LifetimeParam &param);
     114              :   void visit (HIR::ConstGenericParam &param);
     115              : 
     116              :   void apply_trait_bounds (HIR::TypeParam &param, TyTy::ParamType *pty);
     117              : 
     118              : private:
     119        20679 :   TypeResolveGenericParam (bool apply_sized, bool resolve_trait_bounds)
     120        20679 :     : TypeCheckBase (), resolved (nullptr), apply_sized (apply_sized),
     121        20679 :       resolve_trait_bounds (resolve_trait_bounds)
     122              :   {}
     123              : 
     124              :   TyTy::ParamType *resolved;
     125              :   bool apply_sized;
     126              :   bool resolve_trait_bounds;
     127              : };
     128              : 
     129        59431 : class ResolveWhereClauseItem : public TypeCheckBase
     130              : {
     131              :   // pair(a, b) => a: b
     132              :   TyTy::RegionConstraints &region_constraints;
     133              : 
     134              : public:
     135              :   static void Resolve (HIR::WhereClause &clause,
     136              :                        TyTy::RegionConstraints &region_constraints);
     137              : 
     138              : protected:
     139              :   void visit (HIR::LifetimeWhereClauseItem &item);
     140              :   void visit (HIR::TypeBoundWhereClauseItem &item);
     141              : 
     142              : private:
     143              :   static void Resolve (HIR::WhereClauseItem &item,
     144              :                        TyTy::RegionConstraints &region_constraints);
     145              : 
     146              :   bool defer_bindings = false;
     147              :   bool complete_bindings = false;
     148              : 
     149        59431 :   ResolveWhereClauseItem (TyTy::RegionConstraints &region_constraints)
     150        59431 :     : region_constraints (region_constraints)
     151              :   {}
     152              : };
     153              : 
     154              : } // namespace Resolver
     155              : } // namespace Rust
     156              : 
     157              : #endif // RUST_HIR_TYPE_CHECK_TYPE
        

Generated by: LCOV version 2.4-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.