LCOV - code coverage report
Current view: top level - gcc/rust/hir - rust-ast-lower-base.cc (source / functions) Coverage Total Hit
Test: gcc.info Lines: 42.7 % 581 248
Test Date: 2025-06-21 16:26:05 Functions: 13.1 % 176 23
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                 :             : #include "rust-ast-lower-base.h"
      20                 :             : #include "rust-ast-lower-type.h"
      21                 :             : #include "rust-ast-lower-pattern.h"
      22                 :             : #include "rust-ast-lower-extern.h"
      23                 :             : #include "rust-ast.h"
      24                 :             : #include "rust-attribute-values.h"
      25                 :             : #include "rust-diagnostics.h"
      26                 :             : #include "rust-expr.h"
      27                 :             : #include "rust-item.h"
      28                 :             : #include "rust-system.h"
      29                 :             : #include "rust-attributes.h"
      30                 :             : 
      31                 :             : namespace Rust {
      32                 :             : namespace HIR {
      33                 :             : 
      34                 :             : void
      35                 :           0 : ASTLoweringBase::visit (AST::MacroInvocation &invoc)
      36                 :             : {
      37                 :           0 :   rust_fatal_error (invoc.get_locus (), "rogue macro detected during lowering");
      38                 :             :   rust_unreachable ();
      39                 :             : }
      40                 :             : 
      41                 :             : void
      42                 :           0 : ASTLoweringBase::visit (AST::ErrorPropagationExpr &expr)
      43                 :             : {
      44                 :           0 :   rust_fatal_error (expr.get_locus (),
      45                 :             :                     "missing desugar for question mark operator");
      46                 :             :   rust_unreachable ();
      47                 :             : }
      48                 :             : 
      49                 :             : void
      50                 :           0 : ASTLoweringBase::visit (AST::Token &)
      51                 :           0 : {}
      52                 :             : void
      53                 :           0 : ASTLoweringBase::visit (AST::DelimTokenTree &)
      54                 :           0 : {}
      55                 :             : void
      56                 :           0 : ASTLoweringBase::visit (AST::AttrInputMetaItemContainer &)
      57                 :           0 : {}
      58                 :             : //  void ASTLoweringBase::visit(MetaItemmeta_item) {}
      59                 :             : //  void vsit(Stmtstmt) {}
      60                 :             : //  void ASTLoweringBase::visit(Exprexpr) {}
      61                 :             : void
      62                 :           0 : ASTLoweringBase::visit (AST::IdentifierExpr &)
      63                 :           0 : {}
      64                 :             : //  void ASTLoweringBase::visit(Patternpattern) {}
      65                 :             : //  void ASTLoweringBase::visit(Typetype) {}
      66                 :             : //  void ASTLoweringBase::visit(TypeParamBoundtype_param_bound) {}
      67                 :             : void
      68                 :           0 : ASTLoweringBase::visit (AST::Lifetime &)
      69                 :           0 : {}
      70                 :             : //  void ASTLoweringBase::visit(GenericParamgeneric_param) {}
      71                 :             : void
      72                 :           0 : ASTLoweringBase::visit (AST::LifetimeParam &)
      73                 :           0 : {}
      74                 :             : void
      75                 :           0 : ASTLoweringBase::visit (AST::ConstGenericParam &)
      76                 :           0 : {}
      77                 :             : //  void ASTLoweringBase::visit(TraitItemtrait_item) {}
      78                 :             : //  void ASTLoweringBase::visit(InherentImplIteminherent_impl_item) {}
      79                 :             : //  void ASTLoweringBase::visit(TraitImplItemtrait_impl_item) {}
      80                 :             : 
      81                 :             : // rust-path.h
      82                 :             : void
      83                 :           0 : ASTLoweringBase::visit (AST::PathInExpression &)
      84                 :           0 : {}
      85                 :             : void
      86                 :           0 : ASTLoweringBase::visit (AST::TypePathSegment &)
      87                 :           0 : {}
      88                 :             : void
      89                 :           0 : ASTLoweringBase::visit (AST::TypePathSegmentGeneric &)
      90                 :           0 : {}
      91                 :             : void
      92                 :           0 : ASTLoweringBase::visit (AST::TypePathSegmentFunction &)
      93                 :           0 : {}
      94                 :             : void
      95                 :           0 : ASTLoweringBase::visit (AST::TypePath &)
      96                 :           0 : {}
      97                 :             : void
      98                 :           0 : ASTLoweringBase::visit (AST::QualifiedPathInExpression &)
      99                 :           0 : {}
     100                 :             : void
     101                 :           0 : ASTLoweringBase::visit (AST::QualifiedPathInType &)
     102                 :           0 : {}
     103                 :             : 
     104                 :             : // rust-expr.h
     105                 :             : void
     106                 :           0 : ASTLoweringBase::visit (AST::LiteralExpr &)
     107                 :           0 : {}
     108                 :             : void
     109                 :           0 : ASTLoweringBase::visit (AST::AttrInputLiteral &)
     110                 :           0 : {}
     111                 :             : void
     112                 :           0 : ASTLoweringBase::visit (AST::AttrInputMacro &)
     113                 :           0 : {}
     114                 :             : void
     115                 :           0 : ASTLoweringBase::visit (AST::MetaItemLitExpr &)
     116                 :           0 : {}
     117                 :             : void
     118                 :           0 : ASTLoweringBase::visit (AST::MetaItemPathLit &)
     119                 :           0 : {}
     120                 :             : void
     121                 :           0 : ASTLoweringBase::visit (AST::BorrowExpr &)
     122                 :           0 : {}
     123                 :             : void
     124                 :           0 : ASTLoweringBase::visit (AST::DereferenceExpr &)
     125                 :           0 : {}
     126                 :             : void
     127                 :           0 : ASTLoweringBase::visit (AST::NegationExpr &)
     128                 :           0 : {}
     129                 :             : void
     130                 :           0 : ASTLoweringBase::visit (AST::ArithmeticOrLogicalExpr &)
     131                 :           0 : {}
     132                 :             : void
     133                 :           0 : ASTLoweringBase::visit (AST::ComparisonExpr &)
     134                 :           0 : {}
     135                 :             : void
     136                 :           0 : ASTLoweringBase::visit (AST::LazyBooleanExpr &)
     137                 :           0 : {}
     138                 :             : void
     139                 :           0 : ASTLoweringBase::visit (AST::TypeCastExpr &)
     140                 :           0 : {}
     141                 :             : void
     142                 :           0 : ASTLoweringBase::visit (AST::AssignmentExpr &)
     143                 :           0 : {}
     144                 :             : void
     145                 :           0 : ASTLoweringBase::visit (AST::CompoundAssignmentExpr &)
     146                 :           0 : {}
     147                 :             : void
     148                 :           0 : ASTLoweringBase::visit (AST::GroupedExpr &)
     149                 :           0 : {}
     150                 :             : //  void ASTLoweringBase::visit(ArrayElemselems) {}
     151                 :             : void
     152                 :           0 : ASTLoweringBase::visit (AST::ArrayElemsValues &)
     153                 :           0 : {}
     154                 :             : void
     155                 :           0 : ASTLoweringBase::visit (AST::ArrayElemsCopied &)
     156                 :           0 : {}
     157                 :             : void
     158                 :           0 : ASTLoweringBase::visit (AST::ArrayExpr &)
     159                 :           0 : {}
     160                 :             : void
     161                 :           0 : ASTLoweringBase::visit (AST::ArrayIndexExpr &)
     162                 :           0 : {}
     163                 :             : void
     164                 :           0 : ASTLoweringBase::visit (AST::TupleExpr &)
     165                 :           0 : {}
     166                 :             : void
     167                 :           0 : ASTLoweringBase::visit (AST::TupleIndexExpr &)
     168                 :           0 : {}
     169                 :             : void
     170                 :           0 : ASTLoweringBase::visit (AST::StructExprStruct &)
     171                 :           0 : {}
     172                 :             : //  void ASTLoweringBase::visit(StructExprFieldfield) {}
     173                 :             : void
     174                 :           0 : ASTLoweringBase::visit (AST::StructExprFieldIdentifier &)
     175                 :           0 : {}
     176                 :             : void
     177                 :           0 : ASTLoweringBase::visit (AST::StructExprFieldIdentifierValue &)
     178                 :           0 : {}
     179                 :             : void
     180                 :           0 : ASTLoweringBase::visit (AST::StructExprFieldIndexValue &)
     181                 :           0 : {}
     182                 :             : void
     183                 :           0 : ASTLoweringBase::visit (AST::StructExprStructFields &)
     184                 :           0 : {}
     185                 :             : void
     186                 :           0 : ASTLoweringBase::visit (AST::StructExprStructBase &)
     187                 :           0 : {}
     188                 :             : void
     189                 :           0 : ASTLoweringBase::visit (AST::CallExpr &)
     190                 :           0 : {}
     191                 :             : void
     192                 :           0 : ASTLoweringBase::visit (AST::MethodCallExpr &)
     193                 :           0 : {}
     194                 :             : void
     195                 :           0 : ASTLoweringBase::visit (AST::FieldAccessExpr &)
     196                 :           0 : {}
     197                 :             : void
     198                 :           0 : ASTLoweringBase::visit (AST::ClosureExprInner &)
     199                 :           0 : {}
     200                 :             : void
     201                 :           0 : ASTLoweringBase::visit (AST::BlockExpr &)
     202                 :           0 : {}
     203                 :             : void
     204                 :           0 : ASTLoweringBase::visit (AST::ClosureExprInnerTyped &)
     205                 :           0 : {}
     206                 :             : void
     207                 :           0 : ASTLoweringBase::visit (AST::ContinueExpr &)
     208                 :           0 : {}
     209                 :             : void
     210                 :           0 : ASTLoweringBase::visit (AST::BreakExpr &)
     211                 :           0 : {}
     212                 :             : void
     213                 :           0 : ASTLoweringBase::visit (AST::RangeFromToExpr &)
     214                 :           0 : {}
     215                 :             : void
     216                 :           0 : ASTLoweringBase::visit (AST::RangeFromExpr &)
     217                 :           0 : {}
     218                 :             : void
     219                 :           0 : ASTLoweringBase::visit (AST::RangeToExpr &)
     220                 :           0 : {}
     221                 :             : void
     222                 :           0 : ASTLoweringBase::visit (AST::RangeFullExpr &)
     223                 :           0 : {}
     224                 :             : void
     225                 :           0 : ASTLoweringBase::visit (AST::RangeFromToInclExpr &)
     226                 :           0 : {}
     227                 :             : void
     228                 :           0 : ASTLoweringBase::visit (AST::RangeToInclExpr &)
     229                 :           0 : {}
     230                 :             : 
     231                 :             : void
     232                 :           0 : ASTLoweringBase::visit (AST::BoxExpr &)
     233                 :           0 : {}
     234                 :             : 
     235                 :             : void
     236                 :           0 : ASTLoweringBase::visit (AST::ReturnExpr &)
     237                 :           0 : {}
     238                 :             : void
     239                 :           0 : ASTLoweringBase::visit (AST::UnsafeBlockExpr &)
     240                 :           0 : {}
     241                 :             : void
     242                 :           0 : ASTLoweringBase::visit (AST::LoopExpr &)
     243                 :           0 : {}
     244                 :             : void
     245                 :           0 : ASTLoweringBase::visit (AST::WhileLoopExpr &)
     246                 :           0 : {}
     247                 :             : void
     248                 :           0 : ASTLoweringBase::visit (AST::WhileLetLoopExpr &)
     249                 :           0 : {}
     250                 :             : void
     251                 :           0 : ASTLoweringBase::visit (AST::ForLoopExpr &)
     252                 :           0 : {}
     253                 :             : void
     254                 :           0 : ASTLoweringBase::visit (AST::IfExpr &)
     255                 :           0 : {}
     256                 :             : void
     257                 :           0 : ASTLoweringBase::visit (AST::IfExprConseqElse &)
     258                 :           0 : {}
     259                 :             : void
     260                 :           0 : ASTLoweringBase::visit (AST::IfLetExpr &)
     261                 :           0 : {}
     262                 :             : void
     263                 :           0 : ASTLoweringBase::visit (AST::IfLetExprConseqElse &)
     264                 :           0 : {}
     265                 :             : 
     266                 :             : void
     267                 :           0 : ASTLoweringBase::visit (AST::InlineAsm &)
     268                 :           0 : {}
     269                 :             : 
     270                 :             : void
     271                 :           0 : ASTLoweringBase::visit (AST::LlvmInlineAsm &)
     272                 :           0 : {}
     273                 :             : 
     274                 :             : //  void ASTLoweringBase::visit(MatchCasematch_case) {}
     275                 :             : // void ASTLoweringBase:: (AST::MatchCaseBlockExpr &) {}
     276                 :             : // void ASTLoweringBase:: (AST::MatchCaseExpr &) {}
     277                 :             : void
     278                 :           0 : ASTLoweringBase::visit (AST::MatchExpr &)
     279                 :           0 : {}
     280                 :             : void
     281                 :           0 : ASTLoweringBase::visit (AST::AwaitExpr &)
     282                 :           0 : {}
     283                 :             : void
     284                 :           0 : ASTLoweringBase::visit (AST::AsyncBlockExpr &)
     285                 :           0 : {}
     286                 :             : 
     287                 :             : // rust-item.h
     288                 :             : void
     289                 :           0 : ASTLoweringBase::visit (AST::TypeParam &)
     290                 :           0 : {}
     291                 :             : //  void ASTLoweringBase::visit(WhereClauseItemitem) {}
     292                 :             : void
     293                 :           0 : ASTLoweringBase::visit (AST::LifetimeWhereClauseItem &)
     294                 :           0 : {}
     295                 :             : void
     296                 :           0 : ASTLoweringBase::visit (AST::TypeBoundWhereClauseItem &)
     297                 :           0 : {}
     298                 :             : void
     299                 :           0 : ASTLoweringBase::visit (AST::Module &)
     300                 :           0 : {}
     301                 :             : void
     302                 :          24 : ASTLoweringBase::visit (AST::ExternCrate &)
     303                 :          24 : {}
     304                 :             : //  void ASTLoweringBase::visit(UseTreeuse_tree) {}
     305                 :             : void
     306                 :           0 : ASTLoweringBase::visit (AST::UseTreeGlob &)
     307                 :           0 : {}
     308                 :             : void
     309                 :           0 : ASTLoweringBase::visit (AST::UseTreeList &)
     310                 :           0 : {}
     311                 :             : void
     312                 :           0 : ASTLoweringBase::visit (AST::UseTreeRebind &)
     313                 :           0 : {}
     314                 :             : void
     315                 :         261 : ASTLoweringBase::visit (AST::UseDeclaration &)
     316                 :         261 : {}
     317                 :             : void
     318                 :           0 : ASTLoweringBase::visit (AST::Function &)
     319                 :           0 : {}
     320                 :             : void
     321                 :           2 : ASTLoweringBase::visit (AST::TypeAlias &)
     322                 :           2 : {}
     323                 :             : void
     324                 :           0 : ASTLoweringBase::visit (AST::StructStruct &)
     325                 :           0 : {}
     326                 :             : void
     327                 :           0 : ASTLoweringBase::visit (AST::TupleStruct &)
     328                 :           0 : {}
     329                 :             : void
     330                 :           0 : ASTLoweringBase::visit (AST::EnumItem &)
     331                 :           0 : {}
     332                 :             : void
     333                 :           0 : ASTLoweringBase::visit (AST::EnumItemTuple &)
     334                 :           0 : {}
     335                 :             : void
     336                 :           0 : ASTLoweringBase::visit (AST::EnumItemStruct &)
     337                 :           0 : {}
     338                 :             : void
     339                 :           0 : ASTLoweringBase::visit (AST::EnumItemDiscriminant &)
     340                 :           0 : {}
     341                 :             : void
     342                 :           0 : ASTLoweringBase::visit (AST::Enum &)
     343                 :           0 : {}
     344                 :             : void
     345                 :           0 : ASTLoweringBase::visit (AST::Union &)
     346                 :           0 : {}
     347                 :             : void
     348                 :           0 : ASTLoweringBase::visit (AST::ConstantItem &)
     349                 :           0 : {}
     350                 :             : void
     351                 :           0 : ASTLoweringBase::visit (AST::StaticItem &)
     352                 :           0 : {}
     353                 :             : void
     354                 :           0 : ASTLoweringBase::visit (AST::TraitItemConst &)
     355                 :           0 : {}
     356                 :             : void
     357                 :           0 : ASTLoweringBase::visit (AST::TraitItemType &)
     358                 :           0 : {}
     359                 :             : void
     360                 :           0 : ASTLoweringBase::visit (AST::Trait &)
     361                 :           0 : {}
     362                 :             : void
     363                 :           0 : ASTLoweringBase::visit (AST::InherentImpl &)
     364                 :           0 : {}
     365                 :             : void
     366                 :           0 : ASTLoweringBase::visit (AST::TraitImpl &)
     367                 :           0 : {}
     368                 :             : //  void ASTLoweringBase::visit(ExternalItemitem) {}
     369                 :             : void
     370                 :           0 : ASTLoweringBase::visit (AST::ExternalTypeItem &)
     371                 :           0 : {}
     372                 :             : void
     373                 :           0 : ASTLoweringBase::visit (AST::ExternalStaticItem &)
     374                 :           0 : {}
     375                 :             : void
     376                 :           0 : ASTLoweringBase::visit (AST::ExternBlock &)
     377                 :           0 : {}
     378                 :             : 
     379                 :             : // rust-macro.h
     380                 :             : void
     381                 :           0 : ASTLoweringBase::visit (AST::MacroMatchFragment &)
     382                 :           0 : {}
     383                 :             : void
     384                 :           0 : ASTLoweringBase::visit (AST::MacroMatchRepetition &)
     385                 :           0 : {}
     386                 :             : void
     387                 :           0 : ASTLoweringBase::visit (AST::MacroMatcher &)
     388                 :           0 : {}
     389                 :             : void
     390                 :           0 : ASTLoweringBase::visit (AST::MacroRulesDefinition &)
     391                 :           0 : {}
     392                 :             : void
     393                 :           0 : ASTLoweringBase::visit (AST::MetaItemPath &)
     394                 :           0 : {}
     395                 :             : void
     396                 :           0 : ASTLoweringBase::visit (AST::MetaItemSeq &)
     397                 :           0 : {}
     398                 :             : void
     399                 :           0 : ASTLoweringBase::visit (AST::MetaWord &)
     400                 :           0 : {}
     401                 :             : void
     402                 :           0 : ASTLoweringBase::visit (AST::MetaNameValueStr &)
     403                 :           0 : {}
     404                 :             : void
     405                 :           0 : ASTLoweringBase::visit (AST::MetaListPaths &)
     406                 :           0 : {}
     407                 :             : void
     408                 :           0 : ASTLoweringBase::visit (AST::MetaListNameValueStr &)
     409                 :           0 : {}
     410                 :             : 
     411                 :             : // rust-pattern.h
     412                 :             : void
     413                 :           0 : ASTLoweringBase::visit (AST::LiteralPattern &)
     414                 :           0 : {}
     415                 :             : void
     416                 :           0 : ASTLoweringBase::visit (AST::IdentifierPattern &)
     417                 :           0 : {}
     418                 :             : void
     419                 :           0 : ASTLoweringBase::visit (AST::WildcardPattern &)
     420                 :           0 : {}
     421                 :             : void
     422                 :           0 : ASTLoweringBase::visit (AST::RestPattern &)
     423                 :           0 : {}
     424                 :             : //  void ASTLoweringBase::visit(RangePatternBoundbound) {}
     425                 :             : void
     426                 :           0 : ASTLoweringBase::visit (AST::RangePatternBoundLiteral &)
     427                 :           0 : {}
     428                 :             : void
     429                 :           0 : ASTLoweringBase::visit (AST::RangePatternBoundPath &)
     430                 :           0 : {}
     431                 :             : void
     432                 :           0 : ASTLoweringBase::visit (AST::RangePatternBoundQualPath &)
     433                 :           0 : {}
     434                 :             : void
     435                 :           0 : ASTLoweringBase::visit (AST::RangePattern &)
     436                 :           0 : {}
     437                 :             : void
     438                 :           0 : ASTLoweringBase::visit (AST::ReferencePattern &)
     439                 :           0 : {}
     440                 :             : //  void ASTLoweringBase::visit(StructPatternFieldfield) {}
     441                 :             : void
     442                 :           0 : ASTLoweringBase::visit (AST::StructPatternFieldTuplePat &)
     443                 :           0 : {}
     444                 :             : void
     445                 :           0 : ASTLoweringBase::visit (AST::StructPatternFieldIdentPat &)
     446                 :           0 : {}
     447                 :             : void
     448                 :           0 : ASTLoweringBase::visit (AST::StructPatternFieldIdent &)
     449                 :           0 : {}
     450                 :             : void
     451                 :           0 : ASTLoweringBase::visit (AST::StructPattern &)
     452                 :           0 : {}
     453                 :             : //  void ASTLoweringBase::visit(TupleStructItemstuple_items) {}
     454                 :             : void
     455                 :           0 : ASTLoweringBase::visit (AST::TupleStructItemsNoRange &)
     456                 :           0 : {}
     457                 :             : void
     458                 :           0 : ASTLoweringBase::visit (AST::TupleStructItemsRange &)
     459                 :           0 : {}
     460                 :             : void
     461                 :           0 : ASTLoweringBase::visit (AST::TupleStructPattern &)
     462                 :           0 : {}
     463                 :             : //  void ASTLoweringBase::visit(TuplePatternItemstuple_items) {}
     464                 :             : void
     465                 :           0 : ASTLoweringBase::visit (AST::TuplePatternItemsMultiple &)
     466                 :           0 : {}
     467                 :             : void
     468                 :           0 : ASTLoweringBase::visit (AST::TuplePatternItemsRanged &)
     469                 :           0 : {}
     470                 :             : void
     471                 :           0 : ASTLoweringBase::visit (AST::TuplePattern &)
     472                 :           0 : {}
     473                 :             : void
     474                 :           0 : ASTLoweringBase::visit (AST::GroupedPattern &)
     475                 :           0 : {}
     476                 :             : void
     477                 :           0 : ASTLoweringBase::visit (AST::SlicePattern &)
     478                 :           0 : {}
     479                 :             : void
     480                 :           0 : ASTLoweringBase::visit (AST::AltPattern &)
     481                 :           0 : {}
     482                 :             : 
     483                 :             : // rust-stmt.h
     484                 :             : void
     485                 :           0 : ASTLoweringBase::visit (AST::EmptyStmt &)
     486                 :           0 : {}
     487                 :             : void
     488                 :           0 : ASTLoweringBase::visit (AST::LetStmt &)
     489                 :           0 : {}
     490                 :             : void
     491                 :           0 : ASTLoweringBase::visit (AST::ExprStmt &)
     492                 :           0 : {}
     493                 :             : 
     494                 :             : // rust-type.h
     495                 :             : void
     496                 :           0 : ASTLoweringBase::visit (AST::TraitBound &)
     497                 :           0 : {}
     498                 :             : void
     499                 :           0 : ASTLoweringBase::visit (AST::ImplTraitType &)
     500                 :           0 : {}
     501                 :             : void
     502                 :           0 : ASTLoweringBase::visit (AST::TraitObjectType &)
     503                 :           0 : {}
     504                 :             : void
     505                 :           0 : ASTLoweringBase::visit (AST::ParenthesisedType &)
     506                 :           0 : {}
     507                 :             : void
     508                 :           0 : ASTLoweringBase::visit (AST::ImplTraitTypeOneBound &)
     509                 :           0 : {}
     510                 :             : void
     511                 :           0 : ASTLoweringBase::visit (AST::TraitObjectTypeOneBound &)
     512                 :           0 : {}
     513                 :             : void
     514                 :           0 : ASTLoweringBase::visit (AST::TupleType &)
     515                 :           0 : {}
     516                 :             : void
     517                 :           0 : ASTLoweringBase::visit (AST::NeverType &)
     518                 :           0 : {}
     519                 :             : void
     520                 :           0 : ASTLoweringBase::visit (AST::RawPointerType &)
     521                 :           0 : {}
     522                 :             : void
     523                 :           0 : ASTLoweringBase::visit (AST::ReferenceType &)
     524                 :           0 : {}
     525                 :             : void
     526                 :           0 : ASTLoweringBase::visit (AST::ArrayType &)
     527                 :           0 : {}
     528                 :             : void
     529                 :           0 : ASTLoweringBase::visit (AST::SliceType &)
     530                 :           0 : {}
     531                 :             : void
     532                 :           0 : ASTLoweringBase::visit (AST::InferredType &)
     533                 :           0 : {}
     534                 :             : void
     535                 :           0 : ASTLoweringBase::visit (AST::BareFunctionType &)
     536                 :           0 : {}
     537                 :             : 
     538                 :             : void
     539                 :           0 : ASTLoweringBase::visit (AST::FunctionParam &param)
     540                 :           0 : {}
     541                 :             : 
     542                 :             : void
     543                 :           0 : ASTLoweringBase::visit (AST::VariadicParam &param)
     544                 :           0 : {}
     545                 :             : 
     546                 :             : void
     547                 :           0 : ASTLoweringBase::visit (AST::SelfParam &param)
     548                 :           0 : {}
     549                 :             : 
     550                 :             : void
     551                 :           0 : ASTLoweringBase::visit (AST::FormatArgs &fmt)
     552                 :           0 : {}
     553                 :             : 
     554                 :             : HIR::Lifetime
     555                 :        5584 : ASTLoweringBase::lower_lifetime (AST::Lifetime &lifetime,
     556                 :             :                                  bool default_to_static_lifetime)
     557                 :             : {
     558                 :        5584 :   auto lifetime_type = lifetime.get_lifetime_type ();
     559                 :        5584 :   if (lifetime_type == AST::Lifetime::WILDCARD && default_to_static_lifetime)
     560                 :             :     {
     561                 :             :       // If compiling in a static context.
     562                 :          13 :       lifetime_type = AST::Lifetime::STATIC;
     563                 :             :     }
     564                 :             : 
     565                 :        5584 :   auto crate_num = mappings.get_current_crate ();
     566                 :        5584 :   Analysis::NodeMapping mapping (crate_num, lifetime.get_node_id (),
     567                 :        5584 :                                  mappings.get_next_hir_id (crate_num),
     568                 :        5584 :                                  UNKNOWN_LOCAL_DEFID);
     569                 :        5584 :   mappings.insert_node_to_hir (mapping.get_nodeid (), mapping.get_hirid ());
     570                 :             : 
     571                 :       11168 :   return HIR::Lifetime (mapping, lifetime_type, lifetime.get_lifetime_name (),
     572                 :       11168 :                         lifetime.get_locus ());
     573                 :             : }
     574                 :             : 
     575                 :             : HIR::LoopLabel
     576                 :          36 : ASTLoweringBase::lower_loop_label (AST::LoopLabel &loop_label)
     577                 :             : {
     578                 :          36 :   HIR::Lifetime life = lower_lifetime (loop_label.get_lifetime ());
     579                 :             : 
     580                 :          36 :   auto crate_num = mappings.get_current_crate ();
     581                 :          36 :   Analysis::NodeMapping mapping (crate_num, loop_label.get_node_id (),
     582                 :          36 :                                  mappings.get_next_hir_id (crate_num),
     583                 :          36 :                                  UNKNOWN_LOCAL_DEFID);
     584                 :          36 :   mappings.insert_node_to_hir (mapping.get_nodeid (), mapping.get_hirid ());
     585                 :             : 
     586                 :          36 :   return HIR::LoopLabel (mapping, std::move (life), loop_label.get_locus ());
     587                 :          36 : }
     588                 :             : 
     589                 :             : std::vector<std::unique_ptr<HIR::GenericParam>>
     590                 :        3977 : ASTLoweringBase::lower_generic_params (
     591                 :             :   std::vector<std::unique_ptr<AST::GenericParam>> &params)
     592                 :             : {
     593                 :        3977 :   std::vector<std::unique_ptr<HIR::GenericParam>> lowered;
     594                 :        8383 :   for (auto &ast_param : params)
     595                 :             :     {
     596                 :        4406 :       auto hir_param = ASTLowerGenericParam::translate (*ast_param);
     597                 :        4406 :       lowered.push_back (std::unique_ptr<HIR::GenericParam> (hir_param));
     598                 :             :     }
     599                 :             : 
     600                 :        3977 :   return lowered;
     601                 :             : }
     602                 :             : 
     603                 :             : HIR::PathExprSegment
     604                 :       25434 : ASTLoweringBase::lower_path_expr_seg (AST::PathExprSegment &s)
     605                 :             : {
     606                 :       25434 :   auto crate_num = mappings.get_current_crate ();
     607                 :       25434 :   Analysis::NodeMapping mapping (crate_num, s.get_node_id (),
     608                 :       25434 :                                  mappings.get_next_hir_id (crate_num),
     609                 :       25434 :                                  UNKNOWN_LOCAL_DEFID);
     610                 :             : 
     611                 :       25434 :   return HIR::PathExprSegment (
     612                 :             :     std::move (mapping),
     613                 :       76302 :     HIR::PathIdentSegment (s.get_ident_segment ().as_string ()), s.get_locus (),
     614                 :       50868 :     s.has_generic_args () ? lower_generic_args (s.get_generic_args ())
     615                 :       50868 :                           : HIR::GenericArgs::create_empty ());
     616                 :             : }
     617                 :             : 
     618                 :             : HIR::GenericArgsBinding
     619                 :          37 : ASTLoweringBase::lower_binding (AST::GenericArgsBinding &binding)
     620                 :             : {
     621                 :          37 :   HIR::Type *lowered_type = ASTLoweringType::translate (binding.get_type ());
     622                 :          37 :   return HIR::GenericArgsBinding (binding.get_identifier (),
     623                 :          74 :                                   std::unique_ptr<HIR::Type> (lowered_type),
     624                 :          37 :                                   binding.get_locus ());
     625                 :             : }
     626                 :             : 
     627                 :             : HIR::GenericArgs
     628                 :        3168 : ASTLoweringBase::lower_generic_args (AST::GenericArgs &args)
     629                 :             : {
     630                 :        3168 :   std::vector<HIR::GenericArgsBinding> binding_args;
     631                 :        3205 :   for (auto &binding : args.get_binding_args ())
     632                 :             :     {
     633                 :          37 :       HIR::GenericArgsBinding b = lower_binding (binding);
     634                 :          37 :       binding_args.push_back (std::move (b));
     635                 :          37 :     }
     636                 :             : 
     637                 :        3168 :   std::vector<HIR::Lifetime> lifetime_args;
     638                 :        3218 :   for (auto &lifetime : args.get_lifetime_args ())
     639                 :             :     {
     640                 :          50 :       HIR::Lifetime l = lower_lifetime (lifetime);
     641                 :          50 :       lifetime_args.push_back (std::move (l));
     642                 :          50 :     }
     643                 :             : 
     644                 :        3168 :   std::vector<std::unique_ptr<HIR::Type>> type_args;
     645                 :        3168 :   std::vector<HIR::ConstGenericArg> const_args;
     646                 :             : 
     647                 :        6572 :   for (auto &arg : args.get_generic_args ())
     648                 :             :     {
     649                 :        3404 :       switch (arg.get_kind ())
     650                 :             :         {
     651                 :        3360 :           case AST::GenericArg::Kind::Type: {
     652                 :        3360 :             auto type = ASTLoweringType::translate (arg.get_type ());
     653                 :        3360 :             type_args.emplace_back (std::unique_ptr<HIR::Type> (type));
     654                 :        3360 :             break;
     655                 :             :           }
     656                 :          44 :           case AST::GenericArg::Kind::Const: {
     657                 :          44 :             auto expr = ASTLoweringExpr::translate (arg.get_expression ());
     658                 :          44 :             const_args.emplace_back (
     659                 :          88 :               HIR::ConstGenericArg (std::unique_ptr<HIR::Expr> (expr),
     660                 :          44 :                                     expr->get_locus ()));
     661                 :          44 :             break;
     662                 :             :           }
     663                 :           0 :         default:
     664                 :           0 :           rust_unreachable ();
     665                 :             :         }
     666                 :             :     }
     667                 :             : 
     668                 :        3168 :   return HIR::GenericArgs (std::move (lifetime_args), std::move (type_args),
     669                 :             :                            std::move (binding_args), std::move (const_args),
     670                 :        3168 :                            args.get_locus ());
     671                 :        3168 : }
     672                 :             : 
     673                 :             : HIR::SelfParam
     674                 :        5984 : ASTLoweringBase::lower_self (AST::Param &param)
     675                 :             : {
     676                 :        5984 :   rust_assert (param.is_self ());
     677                 :             : 
     678                 :        5984 :   auto self = static_cast<AST::SelfParam &> (param);
     679                 :        5984 :   auto crate_num = mappings.get_current_crate ();
     680                 :        5984 :   Analysis::NodeMapping mapping (crate_num, self.get_node_id (),
     681                 :        5984 :                                  mappings.get_next_hir_id (crate_num),
     682                 :        5984 :                                  mappings.get_next_localdef_id (crate_num));
     683                 :        5984 :   mappings.insert_location (mapping.get_hirid (), param.get_locus ());
     684                 :             : 
     685                 :        5984 :   if (self.has_type ())
     686                 :             :     {
     687                 :           2 :       HIR::Type *type = ASTLoweringType::translate (self.get_type ());
     688                 :           2 :       return HIR::SelfParam (mapping, std::unique_ptr<HIR::Type> (type),
     689                 :           2 :                              self.get_is_mut (), self.get_locus ());
     690                 :             :     }
     691                 :        5982 :   else if (!self.get_has_ref ())
     692                 :             :     {
     693                 :        3023 :       return HIR::SelfParam (mapping, std::unique_ptr<HIR::Type> (nullptr),
     694                 :        3023 :                              self.get_is_mut (), self.get_locus ());
     695                 :             :     }
     696                 :             : 
     697                 :        2959 :   tl::optional<HIR::Lifetime> lifetime = tl::nullopt;
     698                 :             : 
     699                 :        2959 :   if (self.has_lifetime ())
     700                 :        2871 :     lifetime = lower_lifetime (self.get_lifetime ());
     701                 :             : 
     702                 :        2959 :   return HIR::SelfParam (mapping, lifetime, self.get_is_mut (),
     703                 :        5830 :                          self.get_locus ());
     704                 :        5984 : }
     705                 :             : 
     706                 :             : HIR::Type *
     707                 :        4620 : ASTLoweringBase::lower_type_no_bounds (AST::TypeNoBounds &type)
     708                 :             : {
     709                 :        4620 :   return ASTLoweringType::translate (type);
     710                 :             : }
     711                 :             : 
     712                 :             : HIR::TypeParamBound *
     713                 :         763 : ASTLoweringBase::lower_bound (AST::TypeParamBound &bound)
     714                 :             : {
     715                 :         763 :   return ASTLoweringTypeBounds::translate (bound);
     716                 :             : }
     717                 :             : 
     718                 :             : /* Checks whether the name of a field already exists.  Returns true
     719                 :             :    and produces an error if so.  */
     720                 :             : bool
     721                 :        2183 : struct_field_name_exists (std::vector<HIR::StructField> &fields,
     722                 :             :                           HIR::StructField &new_field)
     723                 :             : {
     724                 :        6448 :   for (auto &field : fields)
     725                 :             :     {
     726                 :        8554 :       if (field.get_field_name ().as_string ().compare (
     727                 :        4277 :             new_field.get_field_name ().as_string ())
     728                 :        4277 :           == 0)
     729                 :             :         {
     730                 :          12 :           rich_location r (line_table, new_field.get_locus ());
     731                 :          12 :           r.add_range (field.get_locus ());
     732                 :          12 :           rust_error_at (r, ErrorCode::E0124, "field %qs is already declared",
     733                 :          12 :                          field.get_field_name ().as_string ().c_str ());
     734                 :          12 :           return true;
     735                 :          12 :         }
     736                 :             :     }
     737                 :             :   return false;
     738                 :             : }
     739                 :             : 
     740                 :             : HIR::FunctionQualifiers
     741                 :       14347 : ASTLoweringBase::lower_qualifiers (const AST::FunctionQualifiers &qualifiers)
     742                 :             : {
     743                 :       14347 :   Unsafety unsafety
     744                 :       14347 :     = qualifiers.is_unsafe () ? Unsafety::Unsafe : Unsafety::Normal;
     745                 :       14347 :   bool has_extern = qualifiers.is_extern ();
     746                 :       14347 :   ABI abi = has_extern ? ABI::C : ABI::RUST;
     747                 :             : 
     748                 :       14347 :   if (qualifiers.has_abi ())
     749                 :             :     {
     750                 :          65 :       const std::string &extern_abi = qualifiers.get_extern_abi ();
     751                 :          65 :       abi = get_abi_from_string (extern_abi);
     752                 :          65 :       if (has_extern && abi == ABI::UNKNOWN)
     753                 :           2 :         rust_error_at (qualifiers.get_locus (), ErrorCode::E0703,
     754                 :             :                        "invalid ABI: found %qs", extern_abi.c_str ());
     755                 :          65 :     }
     756                 :             : 
     757                 :       14347 :   return HIR::FunctionQualifiers (qualifiers.get_async_status (),
     758                 :             :                                   qualifiers.get_const_status (), unsafety,
     759                 :       14347 :                                   has_extern, abi);
     760                 :             : }
     761                 :             : 
     762                 :             : void
     763                 :       30029 : ASTLoweringBase::handle_outer_attributes (const ItemWrapper &item)
     764                 :             : {
     765                 :       34036 :   for (const auto &attr : item.get_outer_attrs ())
     766                 :             :     {
     767                 :        4007 :       const auto &str_path = attr.get_path ().as_string ();
     768                 :        4007 :       if (!Analysis::Attributes::is_known (str_path))
     769                 :             :         {
     770                 :           0 :           rust_error_at (attr.get_locus (), "unknown attribute");
     771                 :           0 :           continue;
     772                 :             :         }
     773                 :             : 
     774                 :        4007 :       bool is_lang_item = str_path == Values::Attributes::LANG
     775                 :        2617 :                           && attr.has_attr_input ()
     776                 :        6624 :                           && attr.get_attr_input ().get_attr_input_type ()
     777                 :        4007 :                                == AST::AttrInput::AttrInputType::LITERAL;
     778                 :             : 
     779                 :        4007 :       bool is_doc_item = str_path == Values::Attributes::DOC;
     780                 :             : 
     781                 :        4007 :       if (is_doc_item)
     782                 :         731 :         handle_doc_item_attribute (item, attr);
     783                 :        3276 :       else if (is_lang_item)
     784                 :        2617 :         handle_lang_item_attribute (item, attr);
     785                 :         659 :       else if (!attribute_handled_in_another_pass (str_path))
     786                 :             :         {
     787                 :           0 :           rust_error_at (attr.get_locus (), "unhandled attribute: [%s]",
     788                 :           0 :                          attr.get_path ().as_string ().c_str ());
     789                 :             :         }
     790                 :        4007 :     }
     791                 :       30029 : }
     792                 :             : 
     793                 :             : void
     794                 :         731 : ASTLoweringBase::handle_doc_item_attribute (const ItemWrapper &,
     795                 :             :                                             const AST::Attribute &attr)
     796                 :             : {
     797                 :         731 :   auto simple_doc_comment = attr.has_attr_input ()
     798                 :         731 :                             && attr.get_attr_input ().get_attr_input_type ()
     799                 :         751 :                                  == AST::AttrInput::AttrInputType::LITERAL;
     800                 :          20 :   if (simple_doc_comment)
     801                 :             :     return;
     802                 :             : 
     803                 :          20 :   const AST::AttrInput &input = attr.get_attr_input ();
     804                 :          20 :   bool is_token_tree
     805                 :          20 :     = input.get_attr_input_type () == AST::AttrInput::AttrInputType::TOKEN_TREE;
     806                 :          20 :   rust_assert (is_token_tree);
     807                 :          20 :   const auto &option = static_cast<const AST::DelimTokenTree &> (input);
     808                 :          20 :   AST::AttrInputMetaItemContainer *meta_item = option.parse_to_meta_item ();
     809                 :             : 
     810                 :             :   // TODO: add actual and complete checks for the doc attributes
     811                 :             :   //
     812                 :             :   // FIXME: Move this to the AttributeChecker visitor
     813                 :          20 :   rust_assert (meta_item);
     814                 :             : }
     815                 :             : 
     816                 :             : void
     817                 :        2617 : ASTLoweringBase::handle_lang_item_attribute (const ItemWrapper &item,
     818                 :             :                                              const AST::Attribute &attr)
     819                 :             : {
     820                 :        2617 :   auto &literal = static_cast<AST::AttrInputLiteral &> (attr.get_attr_input ());
     821                 :        2617 :   const auto &lang_item_type_str = literal.get_literal ().as_string ();
     822                 :        2617 :   auto lang_item_type = LangItem::Parse (lang_item_type_str);
     823                 :             : 
     824                 :        2617 :   if (lang_item_type)
     825                 :        2617 :     mappings.insert_lang_item (*lang_item_type,
     826                 :        2617 :                                item.get_mappings ().get_defid ());
     827                 :             :   else
     828                 :           0 :     rust_error_at (attr.get_locus (), "unknown lang item");
     829                 :        2617 : }
     830                 :             : 
     831                 :             : bool
     832                 :         659 : ASTLoweringBase::attribute_handled_in_another_pass (
     833                 :             :   const std::string &attribute_path) const
     834                 :             : {
     835                 :         659 :   const auto &lookup = attr_mappings->lookup_builtin (attribute_path);
     836                 :         659 :   if (lookup.is_error ())
     837                 :             :     return false;
     838                 :             : 
     839                 :         659 :   if (lookup.handler == Analysis::CompilerPass::UNKNOWN)
     840                 :             :     return false;
     841                 :             : 
     842                 :         659 :   return lookup.handler != Analysis::CompilerPass::HIR_LOWERING;
     843                 :             : }
     844                 :             : 
     845                 :             : std::unique_ptr<HIR::TuplePatternItems>
     846                 :         360 : ASTLoweringBase::lower_tuple_pattern_multiple (
     847                 :             :   AST::TuplePatternItemsMultiple &pattern)
     848                 :             : {
     849                 :         360 :   std::vector<std::unique_ptr<HIR::Pattern>> patterns;
     850                 :        1077 :   for (auto &p : pattern.get_patterns ())
     851                 :             :     {
     852                 :         717 :       HIR::Pattern *translated = ASTLoweringPattern::translate (*p);
     853                 :         717 :       patterns.push_back (std::unique_ptr<HIR::Pattern> (translated));
     854                 :             :     }
     855                 :             : 
     856                 :         360 :   return std::unique_ptr<HIR::TuplePatternItems> (
     857                 :         360 :     new HIR::TuplePatternItemsMultiple (std::move (patterns)));
     858                 :         360 : }
     859                 :             : 
     860                 :             : std::unique_ptr<TuplePatternItems>
     861                 :           0 : ASTLoweringBase::lower_tuple_pattern_ranged (
     862                 :             :   AST::TuplePatternItemsRanged &pattern)
     863                 :             : {
     864                 :           0 :   std::vector<std::unique_ptr<HIR::Pattern>> lower_patterns;
     865                 :           0 :   std::vector<std::unique_ptr<HIR::Pattern>> upper_patterns;
     866                 :             : 
     867                 :           0 :   for (auto &p : pattern.get_lower_patterns ())
     868                 :             :     {
     869                 :           0 :       HIR::Pattern *translated = ASTLoweringPattern::translate (*p);
     870                 :           0 :       lower_patterns.push_back (std::unique_ptr<HIR::Pattern> (translated));
     871                 :             :     }
     872                 :             : 
     873                 :           0 :   for (auto &p : pattern.get_upper_patterns ())
     874                 :             :     {
     875                 :           0 :       HIR::Pattern *translated = ASTLoweringPattern::translate (*p);
     876                 :           0 :       upper_patterns.push_back (std::unique_ptr<HIR::Pattern> (translated));
     877                 :             :     }
     878                 :             : 
     879                 :           0 :   return std::unique_ptr<HIR::TuplePatternItems> (
     880                 :             :     new HIR::TuplePatternItemsRanged (std::move (lower_patterns),
     881                 :           0 :                                       std::move (upper_patterns)));
     882                 :           0 : }
     883                 :             : 
     884                 :             : std::unique_ptr<HIR::RangePatternBound>
     885                 :          42 : ASTLoweringBase::lower_range_pattern_bound (AST::RangePatternBound &bound)
     886                 :             : {
     887                 :          42 :   std::unique_ptr<HIR::RangePatternBound> hir_bound = nullptr;
     888                 :          42 :   switch (bound.get_bound_type ())
     889                 :             :     {
     890                 :          21 :       case AST::RangePatternBound::RangePatternBoundType::LITERAL: {
     891                 :          21 :         AST::RangePatternBoundLiteral &ref
     892                 :             :           = static_cast<AST::RangePatternBoundLiteral &> (bound);
     893                 :             : 
     894                 :          21 :         HIR::Literal literal = lower_literal (ref.get_literal ());
     895                 :             : 
     896                 :          21 :         hir_bound = std::unique_ptr<HIR::RangePatternBound> (
     897                 :             :           new HIR::RangePatternBoundLiteral (literal, ref.get_locus (),
     898                 :          42 :                                              ref.get_has_minus ()));
     899                 :          21 :       }
     900                 :          21 :       break;
     901                 :          21 :       case AST::RangePatternBound::RangePatternBoundType::PATH: {
     902                 :          21 :         auto &ref = static_cast<AST::RangePatternBoundPath &> (bound);
     903                 :             : 
     904                 :          21 :         HIR::PathInExpression *path
     905                 :          21 :           = ASTLowerPathInExpression::translate (ref.get_path ());
     906                 :             : 
     907                 :          63 :         hir_bound = std::unique_ptr<HIR::RangePatternBound> (
     908                 :          21 :           new HIR::RangePatternBoundPath (*path));
     909                 :             :       }
     910                 :          21 :       break;
     911                 :           0 :       case AST::RangePatternBound::RangePatternBoundType::QUALPATH: {
     912                 :           0 :         auto &ref = static_cast<AST::RangePatternBoundQualPath &> (bound);
     913                 :             : 
     914                 :           0 :         HIR::QualifiedPathInExpression *qualpath
     915                 :           0 :           = ASTLowerQualPathInExpression::translate (ref.get_qualified_path ());
     916                 :             : 
     917                 :           0 :         hir_bound = std::unique_ptr<HIR::RangePatternBound> (
     918                 :           0 :           new HIR::RangePatternBoundQualPath (*qualpath));
     919                 :             :       }
     920                 :           0 :       break;
     921                 :             :     }
     922                 :             : 
     923                 :          42 :   return hir_bound;
     924                 :             : }
     925                 :             : 
     926                 :             : HIR::Literal
     927                 :       16448 : ASTLoweringBase::lower_literal (const AST::Literal &literal)
     928                 :             : {
     929                 :       16448 :   HIR::Literal::LitType type = HIR::Literal::LitType::CHAR;
     930                 :       16448 :   switch (literal.get_lit_type ())
     931                 :             :     {
     932                 :             :     case AST::Literal::LitType::CHAR:
     933                 :             :       type = HIR::Literal::LitType::CHAR;
     934                 :             :       break;
     935                 :             :     case AST::Literal::LitType::STRING:
     936                 :        1652 :       type = HIR::Literal::LitType::STRING;
     937                 :             :       break;
     938                 :         411 :     case AST::Literal::LitType::BYTE:
     939                 :         411 :       type = HIR::Literal::LitType::BYTE;
     940                 :         411 :       break;
     941                 :          30 :     case AST::Literal::LitType::BYTE_STRING:
     942                 :          30 :       type = HIR::Literal::LitType::BYTE_STRING;
     943                 :          30 :       break;
     944                 :             :     case AST::Literal::LitType::RAW_STRING:
     945                 :        1652 :       type = HIR::Literal::LitType::STRING;
     946                 :             :       break;
     947                 :       12925 :     case AST::Literal::LitType::INT:
     948                 :       12925 :       type = HIR::Literal::LitType::INT;
     949                 :       12925 :       break;
     950                 :         387 :     case AST::Literal::LitType::FLOAT:
     951                 :         387 :       type = HIR::Literal::LitType::FLOAT;
     952                 :         387 :       break;
     953                 :         844 :     case AST::Literal::LitType::BOOL:
     954                 :         844 :       type = HIR::Literal::LitType::BOOL;
     955                 :         844 :       break;
     956                 :           0 :     case AST::Literal::LitType::ERROR:
     957                 :           0 :       rust_unreachable ();
     958                 :       16448 :       break;
     959                 :             :     }
     960                 :             : 
     961                 :       32896 :   return HIR::Literal (literal.as_string (), type, literal.get_type_hint ());
     962                 :             : }
     963                 :             : 
     964                 :             : HIR::ExternBlock *
     965                 :        1266 : ASTLoweringBase::lower_extern_block (AST::ExternBlock &extern_block)
     966                 :             : {
     967                 :        1266 :   HIR::Visibility vis = translate_visibility (extern_block.get_visibility ());
     968                 :             : 
     969                 :        1266 :   auto crate_num = mappings.get_current_crate ();
     970                 :        1266 :   Analysis::NodeMapping mapping (crate_num, extern_block.get_node_id (),
     971                 :        1266 :                                  mappings.get_next_hir_id (crate_num),
     972                 :        1266 :                                  mappings.get_next_localdef_id (crate_num));
     973                 :             : 
     974                 :        1266 :   std::vector<std::unique_ptr<HIR::ExternalItem>> extern_items;
     975                 :        3366 :   for (auto &item : extern_block.get_extern_items ())
     976                 :             :     {
     977                 :        2100 :       if (item->is_marked_for_strip ())
     978                 :           0 :         continue;
     979                 :             : 
     980                 :        2100 :       HIR::ExternalItem *lowered
     981                 :        2100 :         = ASTLoweringExternItem::translate (item.get (), mapping.get_hirid ());
     982                 :        2100 :       extern_items.push_back (std::unique_ptr<HIR::ExternalItem> (lowered));
     983                 :             :     }
     984                 :             : 
     985                 :        1266 :   ABI abi = ABI::C;
     986                 :        1266 :   if (extern_block.has_abi ())
     987                 :             :     {
     988                 :        1266 :       const std::string &extern_abi = extern_block.get_abi ();
     989                 :        1266 :       abi = get_abi_from_string (extern_abi);
     990                 :        1266 :       if (abi == ABI::UNKNOWN)
     991                 :           2 :         rust_error_at (extern_block.get_locus (), ErrorCode::E0703,
     992                 :             :                        "invalid ABI: found %qs", extern_abi.c_str ());
     993                 :        1266 :     }
     994                 :             : 
     995                 :        1266 :   HIR::ExternBlock *hir_extern_block
     996                 :             :     = new HIR::ExternBlock (mapping, abi, std::move (extern_items),
     997                 :        1266 :                             std::move (vis), extern_block.get_inner_attrs (),
     998                 :        1266 :                             extern_block.get_outer_attrs (),
     999                 :        1266 :                             extern_block.get_locus ());
    1000                 :             : 
    1001                 :        1266 :   mappings.insert_hir_extern_block (hir_extern_block);
    1002                 :             : 
    1003                 :        2532 :   return hir_extern_block;
    1004                 :        1266 : }
    1005                 :             : 
    1006                 :             : void
    1007                 :        1045 : ASTLoweringBase::lower_macro_definition (AST::MacroRulesDefinition &def)
    1008                 :             : {
    1009                 :        1045 :   auto is_export = false;
    1010                 :        1195 :   for (const auto &attr : def.get_outer_attrs ())
    1011                 :         150 :     if (attr.get_path ().as_string () == Values::Attributes::MACRO_EXPORT)
    1012                 :           2 :       is_export = true;
    1013                 :             : 
    1014                 :        1045 :   if (is_export)
    1015                 :             :     {
    1016                 :           2 :       mappings.insert_exported_macro (def);
    1017                 :           2 :       mappings.insert_ast_item (&def);
    1018                 :           2 :       mappings.insert_location (def.get_node_id (), def.get_locus ());
    1019                 :             :     }
    1020                 :        1045 : }
    1021                 :             : 
    1022                 :             : } // namespace HIR
    1023                 :             : } // namespace Rust
        

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.