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: 55.2 % 163 90
Test Date: 2026-09-19 16:22:48 Functions: 63.6 % 33 21
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           40 : ImplTraitType::ImplTraitType (
      26              :   Analysis::NodeMapping mappings,
      27              :   std::vector<std::unique_ptr<TypeParamBound>> type_param_bounds,
      28              :   location_t locus)
      29           40 :   : Type (mappings, locus), type_param_bounds (std::move (type_param_bounds))
      30           40 : {}
      31              : 
      32           35 : ImplTraitType::ImplTraitType (ImplTraitType const &other)
      33           35 :   : Type (other.mappings, other.locus)
      34              : {
      35           35 :   type_param_bounds.reserve (other.type_param_bounds.size ());
      36           74 :   for (const auto &e : other.type_param_bounds)
      37           39 :     type_param_bounds.push_back (e->clone_type_param_bound ());
      38           35 : }
      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          228 : 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          228 :   : Type (mappings, locus), has_dyn (is_dyn_dispatch),
      58          228 :     type_param_bounds (std::move (type_param_bounds))
      59          228 : {}
      60              : 
      61           34 : TraitObjectType::TraitObjectType (TraitObjectType const &other)
      62           34 :   : Type (other.mappings, other.locus), has_dyn (other.has_dyn)
      63              : {
      64           34 :   type_param_bounds.reserve (other.type_param_bounds.size ());
      65           69 :   for (const auto &e : other.type_param_bounds)
      66           35 :     type_param_bounds.push_back (e->clone_type_param_bound ());
      67           34 : }
      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            6 : ParenthesisedType::ParenthesisedType (Analysis::NodeMapping mappings,
      83              :                                       std::unique_ptr<Type> type_inside_parens,
      84              :                                       location_t locus)
      85              :   : TypeNoBounds (mappings, locus),
      86            6 :     type_in_parens (std::move (type_inside_parens))
      87            6 : {}
      88              : 
      89            0 : ParenthesisedType::ParenthesisedType (ParenthesisedType const &other)
      90            0 :   : TypeNoBounds (other.mappings, other.locus),
      91            0 :     type_in_parens (other.type_in_parens->clone_type ())
      92            0 : {}
      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          555 : TupleType::TupleType (Analysis::NodeMapping mappings,
     118              :                       std::vector<std::unique_ptr<Type>> elems,
     119              :                       location_t locus)
     120          555 :   : TypeNoBounds (mappings, locus), elems (std::move (elems))
     121          555 : {}
     122              : 
     123           55 : TupleType::TupleType (TupleType const &other)
     124           55 :   : TypeNoBounds (other.mappings, other.locus)
     125              : {
     126           55 :   mappings = other.mappings;
     127           55 :   elems.reserve (other.elems.size ());
     128          106 :   for (const auto &e : other.elems)
     129           51 :     elems.push_back (e->clone_type ());
     130           55 : }
     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          197 : NeverType::NeverType (Analysis::NodeMapping mappings, location_t locus)
     145          197 :   : TypeNoBounds (mappings, locus)
     146          197 : {}
     147              : 
     148         7099 : RawPointerType::RawPointerType (Analysis::NodeMapping mappings, Mutability mut,
     149              :                                 std::unique_ptr<Type> type, location_t locus)
     150         7099 :   : TypeNoBounds (mappings, locus), mut (mut), type (std::move (type))
     151         7099 : {}
     152              : 
     153            2 : RawPointerType::RawPointerType (RawPointerType const &other)
     154            2 :   : TypeNoBounds (other.mappings, other.locus), mut (other.mut),
     155            2 :     type (other.type->clone_type ())
     156            2 : {}
     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         4684 : ReferenceType::ReferenceType (Analysis::NodeMapping mappings, Mutability mut,
     169              :                               std::unique_ptr<Type> type_no_bounds,
     170              :                               location_t locus, tl::optional<Lifetime> lifetime)
     171         4684 :   : TypeNoBounds (mappings, locus), lifetime (std::move (lifetime)), mut (mut),
     172         4684 :     type (std::move (type_no_bounds))
     173         4684 : {}
     174              : 
     175          746 : ReferenceType::ReferenceType (ReferenceType const &other)
     176         1492 :   : TypeNoBounds (other.mappings, other.locus), lifetime (other.lifetime),
     177          746 :     mut (other.mut), type (other.type->clone_type ())
     178          746 : {}
     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          798 : ArrayType::ArrayType (Analysis::NodeMapping mappings,
     193              :                       std::unique_ptr<Type> type,
     194              :                       std::unique_ptr<Expr> array_size, location_t locus)
     195          798 :   : TypeNoBounds (mappings, locus), elem_type (std::move (type)),
     196          798 :     size (std::move (array_size))
     197          798 : {}
     198              : 
     199           63 : ArrayType::ArrayType (ArrayType const &other)
     200           63 :   : TypeNoBounds (other.mappings, other.locus),
     201           63 :     elem_type (other.elem_type->clone_type ()), size (other.size->clone_expr ())
     202           63 : {}
     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          908 : SliceType::SliceType (Analysis::NodeMapping mappings,
     215              :                       std::unique_ptr<Type> type, location_t locus)
     216          908 :   : TypeNoBounds (mappings, locus), elem_type (std::move (type))
     217          908 : {}
     218              : 
     219          593 : SliceType::SliceType (SliceType const &other)
     220          593 :   : TypeNoBounds (other.mappings, other.locus),
     221          593 :     elem_type (other.elem_type->clone_type ())
     222          593 : {}
     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          227 : InferredType::InferredType (Analysis::NodeMapping mappings, location_t locus)
     235          227 :   : TypeNoBounds (mappings, locus)
     236          227 : {}
     237              : 
     238           52 : MaybeNamedParam::MaybeNamedParam (Identifier name, ParamKind param_kind,
     239              :                                   std::unique_ptr<Type> param_type,
     240              :                                   location_t locus)
     241           52 :   : param_type (std::move (param_type)), param_kind (param_kind),
     242           52 :     name (std::move (name)), locus (locus)
     243           52 : {}
     244              : 
     245            9 : MaybeNamedParam::MaybeNamedParam (MaybeNamedParam const &other)
     246            9 :   : param_type (other.param_type->clone_type ()), param_kind (other.param_kind),
     247            9 :     name (other.name), locus (other.locus)
     248            9 : {}
     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           67 : 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           67 :   : TypeNoBounds (mappings, locus), for_lifetimes (std::move (lifetime_params)),
     266           67 :     function_qualifiers (std::move (qualifiers)),
     267           67 :     params (std::move (named_params)), is_variadic (is_variadic),
     268           67 :     return_type (std::move (type))
     269           67 : {}
     270              : 
     271           22 : BareFunctionType::BareFunctionType (BareFunctionType const &other)
     272           22 :   : TypeNoBounds (other.mappings, other.locus),
     273           22 :     for_lifetimes (other.for_lifetimes),
     274           22 :     function_qualifiers (other.function_qualifiers), params (other.params),
     275           22 :     is_variadic (other.is_variadic),
     276           22 :     return_type (other.has_return_type () ? other.return_type->clone_type ()
     277           22 :                                           : nullptr)
     278           22 : {}
     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.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.