LCOV - code coverage report
Current view: top level - gcc/rust/hir - rust-ast-lower-type.h Coverage Total Hit
Test: gcc.info Lines: 100.0 % 9 9
Test Date: 2026-09-19 16:22:48 Functions: - 0 0
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_AST_LOWER_TYPE
      20              : #define RUST_AST_LOWER_TYPE
      21              : 
      22              : #include "rust-ast-lower-base.h"
      23              : #include "rust-ast-lower-expr.h"
      24              : #include "rust-hir-path.h"
      25              : #include "rust-type.h"
      26              : 
      27              : namespace Rust {
      28              : namespace HIR {
      29              : 
      30        60878 : class ASTLowerTypePath : public ASTLoweringBase
      31              : {
      32              : protected:
      33              :   using Rust::HIR::ASTLoweringBase::visit;
      34              : 
      35              : public:
      36              :   static HIR::TypePath *translate (AST::TypePath &type);
      37              : 
      38              :   void visit (AST::TypePathSegmentFunction &segment) override;
      39              :   void visit (AST::TypePathSegment &segment) override;
      40              :   void visit (AST::TypePathSegmentGeneric &segment) override;
      41              :   void visit (AST::TypePath &path) override;
      42              : 
      43              : protected:
      44              :   HIR::TypePathSegment *translated_segment;
      45              : 
      46              : private:
      47              :   HIR::TypePath *translated;
      48              : };
      49              : 
      50          247 : class ASTLowerQualifiedPathInType : public ASTLowerTypePath
      51              : {
      52              :   using ASTLowerTypePath::visit;
      53              : 
      54              : public:
      55              :   static HIR::QualifiedPathInType *translate (AST::QualifiedPathInType &type);
      56              : 
      57              :   void visit (AST::QualifiedPathInType &path) override;
      58              : 
      59              : private:
      60              :   HIR::QualifiedPathInType *translated;
      61              : };
      62              : 
      63        67898 : class ASTLoweringType : public ASTLoweringBase
      64              : {
      65              :   using Rust::HIR::ASTLoweringBase::visit;
      66              : 
      67              : public:
      68              :   /**
      69              :    * Allow `arg: impl Trait` types or error out on them
      70              :    */
      71              :   enum class ImplTrait
      72              :   {
      73              :     Allow,
      74              :     Forbid,
      75              :   };
      76              : 
      77              :   static HIR::Type *
      78              :   translate (AST::Type &type, bool default_to_static_lifetime = false,
      79              :              ImplTrait impl_trait_allowed = ImplTrait::Forbid);
      80              : 
      81              :   void visit (AST::BareFunctionType &fntype) override;
      82              :   void visit (AST::TupleType &tuple) override;
      83              :   void visit (AST::TypePath &path) override;
      84              :   void visit (AST::QualifiedPathInType &path) override;
      85              :   void visit (AST::ArrayType &type) override;
      86              :   void visit (AST::ReferenceType &type) override;
      87              :   void visit (AST::RawPointerType &type) override;
      88              :   void visit (AST::SliceType &type) override;
      89              :   void visit (AST::InferredType &type) override;
      90              :   void visit (AST::NeverType &type) override;
      91              :   void visit (AST::TraitObjectTypeOneBound &type) override;
      92              :   void visit (AST::TraitObjectType &type) override;
      93              :   void visit (AST::ParenthesisedType &type) override;
      94              :   void visit (AST::ImplTraitType &type) override;
      95              :   void visit (AST::ImplTraitTypeOneBound &type) override;
      96              : 
      97              :   void emit_impl_trait_error (location_t locus);
      98              : 
      99              : private:
     100              :   ASTLoweringType (bool default_to_static_lifetime,
     101              :                    ImplTrait impl_trait_allowed);
     102              : 
     103              :   /** Used when compiling const and static items. */
     104              :   bool default_to_static_lifetime;
     105              :   ImplTrait impl_trait_allowed;
     106              : 
     107              :   HIR::Type *translated;
     108              : };
     109              : 
     110         9542 : class ASTLowerGenericParam : public ASTLoweringBase
     111              : {
     112              :   using Rust::HIR::ASTLoweringBase::visit;
     113              : 
     114              : public:
     115              :   static HIR::GenericParam *translate (AST::GenericParam &param);
     116              : 
     117              :   void visit (AST::LifetimeParam &param) override;
     118              :   void visit (AST::ConstGenericParam &param) override;
     119              :   void visit (AST::TypeParam &param) override;
     120              : 
     121              : private:
     122         9542 :   ASTLowerGenericParam () : ASTLoweringBase (), translated (nullptr) {}
     123              : 
     124              :   HIR::GenericParam *translated;
     125              : };
     126              : 
     127         2278 : class ASTLoweringTypeBounds : public ASTLoweringBase
     128              : {
     129              :   using Rust::HIR::ASTLoweringBase::visit;
     130              : 
     131              : public:
     132              :   static HIR::TypeParamBound *translate (AST::TypeParamBound &type);
     133              : 
     134              :   void visit (AST::TraitBound &bound) override;
     135              :   void visit (AST::Lifetime &bound) override;
     136              : 
     137              : private:
     138         2278 :   ASTLoweringTypeBounds () : ASTLoweringBase (), translated (nullptr) {}
     139              : 
     140              :   HIR::TypeParamBound *translated;
     141              : };
     142              : 
     143          351 : class ASTLowerWhereClauseItem : public ASTLoweringBase
     144              : {
     145              :   using Rust::HIR::ASTLoweringBase::visit;
     146              : 
     147              : public:
     148              :   static HIR::WhereClauseItem *translate (AST::WhereClauseItem &item);
     149              : 
     150              :   void visit (AST::LifetimeWhereClauseItem &item) override;
     151              :   void visit (AST::TypeBoundWhereClauseItem &item) override;
     152              : 
     153              : private:
     154          351 :   ASTLowerWhereClauseItem () : ASTLoweringBase (), translated (nullptr) {}
     155              : 
     156              :   HIR::WhereClauseItem *translated;
     157              : };
     158              : 
     159              : } // namespace HIR
     160              : } // namespace Rust
     161              : 
     162              : #endif // RUST_AST_LOWER_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.