LCOV - code coverage report
Current view: top level - gcc/rust/hir/tree - rust-hir-type.cc (source / functions) Coverage Total Hit
Test: gcc.info Lines: 57.7 % 163 94
Test Date: 2026-10-17 16:30:31 Functions: 66.7 % 33 22
Legend: Lines:     hit not hit

            Line data    Source code
       1              : 
       2              : // Copyright (C) 2020-2026 Free Software Foundation, Inc.
       3              : 
       4              : // This file is part of GCC.
       5              : 
       6              : // GCC is free software; you can redistribute it and/or modify it under
       7              : // the terms of the GNU General Public License as published by the Free
       8              : // Software Foundation; either version 3, or (at your option) any later
       9              : // version.
      10              : 
      11              : // GCC is distributed in the hope that it will be useful, but WITHOUT ANY
      12              : // WARRANTY; without even the implied warranty of MERCHANTABILITY or
      13              : // FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
      14              : // for more details.
      15              : 
      16              : // You should have received a copy of the GNU General Public License
      17              : // along with GCC; see the file COPYING3.  If not see
      18              : // <http://www.gnu.org/licenses/>.
      19              : 
      20              : #include "rust-hir-type.h"
      21              : 
      22              : namespace Rust {
      23              : namespace HIR {
      24              : 
      25          181 : ImplTraitType::ImplTraitType (
      26              :   Analysis::NodeMapping mappings,
      27              :   std::vector<std::unique_ptr<TypeParamBound>> type_param_bounds,
      28              :   location_t locus)
      29          181 :   : Type (mappings, locus), type_param_bounds (std::move (type_param_bounds))
      30          181 : {}
      31              : 
      32          259 : ImplTraitType::ImplTraitType (ImplTraitType const &other)
      33          259 :   : Type (other.mappings, other.locus)
      34              : {
      35          259 :   type_param_bounds.reserve (other.type_param_bounds.size ());
      36          522 :   for (const auto &e : other.type_param_bounds)
      37          263 :     type_param_bounds.push_back (e->clone_type_param_bound ());
      38          259 : }
      39              : 
      40              : ImplTraitType &
      41            0 : ImplTraitType::operator= (ImplTraitType const &other)
      42              : {
      43            0 :   locus = other.locus;
      44            0 :   mappings = other.mappings;
      45              : 
      46            0 :   type_param_bounds.reserve (other.type_param_bounds.size ());
      47            0 :   for (const auto &e : other.type_param_bounds)
      48            0 :     type_param_bounds.push_back (e->clone_type_param_bound ());
      49              : 
      50            0 :   return *this;
      51              : }
      52              : 
      53          293 : TraitObjectType::TraitObjectType (
      54              :   Analysis::NodeMapping mappings,
      55              :   std::vector<std::unique_ptr<TypeParamBound>> type_param_bounds,
      56              :   location_t locus, bool is_dyn_dispatch)
      57          293 :   : Type (mappings, locus), has_dyn (is_dyn_dispatch),
      58          293 :     type_param_bounds (std::move (type_param_bounds))
      59          293 : {}
      60              : 
      61           68 : TraitObjectType::TraitObjectType (TraitObjectType const &other)
      62           68 :   : Type (other.mappings, other.locus), has_dyn (other.has_dyn)
      63              : {
      64           68 :   type_param_bounds.reserve (other.type_param_bounds.size ());
      65          168 :   for (const auto &e : other.type_param_bounds)
      66          100 :     type_param_bounds.push_back (e->clone_type_param_bound ());
      67           68 : }
      68              : 
      69              : TraitObjectType &
      70            0 : TraitObjectType::operator= (TraitObjectType const &other)
      71              : {
      72            0 :   mappings = other.mappings;
      73            0 :   has_dyn = other.has_dyn;
      74            0 :   locus = other.locus;
      75            0 :   type_param_bounds.reserve (other.type_param_bounds.size ());
      76            0 :   for (const auto &e : other.type_param_bounds)
      77            0 :     type_param_bounds.push_back (e->clone_type_param_bound ());
      78              : 
      79            0 :   return *this;
      80              : }
      81              : 
      82           15 : ParenthesisedType::ParenthesisedType (Analysis::NodeMapping mappings,
      83              :                                       std::unique_ptr<Type> type_inside_parens,
      84              :                                       location_t locus)
      85              :   : TypeNoBounds (mappings, locus),
      86           15 :     type_in_parens (std::move (type_inside_parens))
      87           15 : {}
      88              : 
      89            2 : ParenthesisedType::ParenthesisedType (ParenthesisedType const &other)
      90            2 :   : TypeNoBounds (other.mappings, other.locus),
      91            2 :     type_in_parens (other.type_in_parens->clone_type ())
      92            2 : {}
      93              : 
      94              : ParenthesisedType &
      95            0 : ParenthesisedType::operator= (ParenthesisedType const &other)
      96              : {
      97            0 :   mappings = other.mappings;
      98            0 :   type_in_parens = other.type_in_parens->clone_type ();
      99            0 :   locus = other.locus;
     100            0 :   return *this;
     101              : }
     102              : 
     103              : std::unique_ptr<TraitBound>
     104            0 : ParenthesisedType::to_trait_bound (bool in_parens) const
     105              : {
     106              :   /* If already in parentheses, don't convert - should stay as
     107              :    * ParenthesisedType */
     108            0 :   if (in_parens)
     109            0 :     return nullptr;
     110              : 
     111              :   /* NOTE: obviously it is unknown whether the internal type is a trait bound
     112              :    * due to polymorphism, so just let the internal type handle it. As
     113              :    * parenthesised type, it must be in parentheses. */
     114            0 :   return type_in_parens->to_trait_bound (true);
     115              : }
     116              : 
     117         1497 : TupleType::TupleType (Analysis::NodeMapping mappings,
     118              :                       std::vector<std::unique_ptr<Type>> elems,
     119              :                       location_t locus)
     120         1497 :   : TypeNoBounds (mappings, locus), elems (std::move (elems))
     121         1497 : {}
     122              : 
     123          216 : TupleType::TupleType (TupleType const &other)
     124          216 :   : TypeNoBounds (other.mappings, other.locus)
     125              : {
     126          216 :   mappings = other.mappings;
     127          216 :   elems.reserve (other.elems.size ());
     128          442 :   for (const auto &e : other.elems)
     129          226 :     elems.push_back (e->clone_type ());
     130          216 : }
     131              : 
     132              : TupleType &
     133            0 : TupleType::operator= (TupleType const &other)
     134              : {
     135            0 :   locus = other.locus;
     136              : 
     137            0 :   elems.reserve (other.elems.size ());
     138            0 :   for (const auto &e : other.elems)
     139            0 :     elems.push_back (e->clone_type ());
     140              : 
     141            0 :   return *this;
     142              : }
     143              : 
     144          247 : NeverType::NeverType (Analysis::NodeMapping mappings, location_t locus)
     145          247 :   : TypeNoBounds (mappings, locus)
     146          247 : {}
     147              : 
     148         8255 : RawPointerType::RawPointerType (Analysis::NodeMapping mappings, Mutability mut,
     149              :                                 std::unique_ptr<Type> type, location_t locus)
     150         8255 :   : TypeNoBounds (mappings, locus), mut (mut), type (std::move (type))
     151         8255 : {}
     152              : 
     153           12 : RawPointerType::RawPointerType (RawPointerType const &other)
     154           12 :   : TypeNoBounds (other.mappings, other.locus), mut (other.mut),
     155           12 :     type (other.type->clone_type ())
     156           12 : {}
     157              : 
     158              : RawPointerType &
     159            0 : RawPointerType::operator= (RawPointerType const &other)
     160              : {
     161            0 :   mappings = other.mappings;
     162            0 :   mut = other.mut;
     163            0 :   type = other.type->clone_type ();
     164            0 :   locus = other.locus;
     165            0 :   return *this;
     166              : }
     167              : 
     168        12428 : ReferenceType::ReferenceType (Analysis::NodeMapping mappings, Mutability mut,
     169              :                               std::unique_ptr<Type> type_no_bounds,
     170              :                               location_t locus, tl::optional<Lifetime> lifetime)
     171        12428 :   : TypeNoBounds (mappings, locus), lifetime (std::move (lifetime)), mut (mut),
     172        12428 :     type (std::move (type_no_bounds))
     173        12428 : {}
     174              : 
     175         3217 : ReferenceType::ReferenceType (ReferenceType const &other)
     176         6434 :   : TypeNoBounds (other.mappings, other.locus), lifetime (other.lifetime),
     177         3217 :     mut (other.mut), type (other.type->clone_type ())
     178         3217 : {}
     179              : 
     180              : ReferenceType &
     181            0 : ReferenceType::operator= (ReferenceType const &other)
     182              : {
     183            0 :   mappings = other.mappings;
     184            0 :   lifetime = other.lifetime;
     185            0 :   mut = other.mut;
     186            0 :   type = other.type->clone_type ();
     187            0 :   locus = other.locus;
     188              : 
     189            0 :   return *this;
     190              : }
     191              : 
     192         1117 : ArrayType::ArrayType (Analysis::NodeMapping mappings,
     193              :                       std::unique_ptr<Type> type,
     194              :                       std::unique_ptr<Expr> array_size, location_t locus)
     195         1117 :   : TypeNoBounds (mappings, locus), elem_type (std::move (type)),
     196         1117 :     size (std::move (array_size))
     197         1117 : {}
     198              : 
     199           85 : ArrayType::ArrayType (ArrayType const &other)
     200           85 :   : TypeNoBounds (other.mappings, other.locus),
     201           85 :     elem_type (other.elem_type->clone_type ()), size (other.size->clone_expr ())
     202           85 : {}
     203              : 
     204              : ArrayType &
     205            0 : ArrayType::operator= (ArrayType const &other)
     206              : {
     207            0 :   mappings = other.mappings;
     208            0 :   elem_type = other.elem_type->clone_type ();
     209            0 :   size = other.size->clone_expr ();
     210            0 :   locus = other.locus;
     211            0 :   return *this;
     212              : }
     213              : 
     214         1489 : SliceType::SliceType (Analysis::NodeMapping mappings,
     215              :                       std::unique_ptr<Type> type, location_t locus)
     216         1489 :   : TypeNoBounds (mappings, locus), elem_type (std::move (type))
     217         1489 : {}
     218              : 
     219          746 : SliceType::SliceType (SliceType const &other)
     220          746 :   : TypeNoBounds (other.mappings, other.locus),
     221          746 :     elem_type (other.elem_type->clone_type ())
     222          746 : {}
     223              : 
     224              : SliceType &
     225            0 : SliceType::operator= (SliceType const &other)
     226              : {
     227            0 :   mappings = other.mappings;
     228            0 :   elem_type = other.elem_type->clone_type ();
     229            0 :   locus = other.locus;
     230              : 
     231            0 :   return *this;
     232              : }
     233              : 
     234          454 : InferredType::InferredType (Analysis::NodeMapping mappings, location_t locus)
     235          454 :   : TypeNoBounds (mappings, locus)
     236          454 : {}
     237              : 
     238         3347 : MaybeNamedParam::MaybeNamedParam (Identifier name, ParamKind param_kind,
     239              :                                   std::unique_ptr<Type> param_type,
     240              :                                   location_t locus)
     241         3347 :   : param_type (std::move (param_type)), param_kind (param_kind),
     242         3347 :     name (std::move (name)), locus (locus)
     243         3347 : {}
     244              : 
     245           10 : MaybeNamedParam::MaybeNamedParam (MaybeNamedParam const &other)
     246           10 :   : param_type (other.param_type->clone_type ()), param_kind (other.param_kind),
     247           10 :     name (other.name), locus (other.locus)
     248           10 : {}
     249              : 
     250              : MaybeNamedParam &
     251            0 : MaybeNamedParam::operator= (MaybeNamedParam const &other)
     252              : {
     253            0 :   name = other.name;
     254            0 :   param_kind = other.param_kind;
     255            0 :   param_type = other.param_type->clone_type ();
     256            0 :   locus = other.locus;
     257              : 
     258            0 :   return *this;
     259              : }
     260              : 
     261          615 : BareFunctionType::BareFunctionType (
     262              :   Analysis::NodeMapping mappings, std::vector<LifetimeParam> lifetime_params,
     263              :   FunctionQualifiers qualifiers, std::vector<MaybeNamedParam> named_params,
     264              :   bool is_variadic, std::unique_ptr<Type> type, location_t locus)
     265          615 :   : TypeNoBounds (mappings, locus), for_lifetimes (std::move (lifetime_params)),
     266          615 :     function_qualifiers (std::move (qualifiers)),
     267          615 :     params (std::move (named_params)), is_variadic (is_variadic),
     268          615 :     return_type (std::move (type))
     269          615 : {}
     270              : 
     271           23 : BareFunctionType::BareFunctionType (BareFunctionType const &other)
     272           23 :   : TypeNoBounds (other.mappings, other.locus),
     273           23 :     for_lifetimes (other.for_lifetimes),
     274           23 :     function_qualifiers (other.function_qualifiers), params (other.params),
     275           23 :     is_variadic (other.is_variadic),
     276           23 :     return_type (other.has_return_type () ? other.return_type->clone_type ()
     277           23 :                                           : nullptr)
     278           23 : {}
     279              : 
     280              : BareFunctionType &
     281            0 : BareFunctionType::operator= (BareFunctionType const &other)
     282              : {
     283            0 :   mappings = other.mappings;
     284            0 :   for_lifetimes = other.for_lifetimes;
     285            0 :   function_qualifiers = other.function_qualifiers;
     286            0 :   params = other.params;
     287            0 :   is_variadic = other.is_variadic;
     288            0 :   return_type = other.return_type->clone_type ();
     289            0 :   locus = other.locus;
     290              : 
     291            0 :   return *this;
     292              : }
     293              : 
     294              : } // namespace HIR
     295              : } // namespace Rust
        

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