LCOV - code coverage report
Current view: top level - gcc/rust/typecheck - rust-hir-path-probe.cc (source / functions) Coverage Total Hit
Test: gcc.info Lines: 83.5 % 236 197
Test Date: 2024-04-20 14:03:02 Functions: 80.6 % 31 25
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: - 0 0

             Branch data     Line data    Source code
       1                 :             : // Copyright (C) 2020-2024 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-hir-path-probe.h"
      20                 :             : #include "rust-hir-trait-resolve.h"
      21                 :             : #include "rust-type-util.h"
      22                 :             : #include "rust-hir-type-bounds.h"
      23                 :             : #include "rust-hir-full.h"
      24                 :             : 
      25                 :             : namespace Rust {
      26                 :             : namespace Resolver {
      27                 :             : 
      28                 :             : // PathProbeCandidate
      29                 :             : 
      30                 :           3 : PathProbeCandidate::Candidate::Candidate (EnumItemCandidate enum_field)
      31                 :           3 :   : enum_field (enum_field)
      32                 :           3 : {}
      33                 :             : 
      34                 :        2210 : PathProbeCandidate::Candidate::Candidate (ImplItemCandidate impl) : impl (impl)
      35                 :        2210 : {}
      36                 :             : 
      37                 :        1857 : PathProbeCandidate::Candidate::Candidate (TraitItemCandidate trait)
      38                 :        1857 :   : trait (trait)
      39                 :        1857 : {}
      40                 :             : 
      41                 :           3 : PathProbeCandidate::PathProbeCandidate (CandidateType type, TyTy::BaseType *ty,
      42                 :             :                                         location_t locus,
      43                 :           3 :                                         EnumItemCandidate enum_field)
      44                 :           3 :   : type (type), ty (ty), locus (locus), item (enum_field)
      45                 :           3 : {}
      46                 :             : 
      47                 :        2210 : PathProbeCandidate::PathProbeCandidate (CandidateType type, TyTy::BaseType *ty,
      48                 :             :                                         location_t locus,
      49                 :        2210 :                                         ImplItemCandidate impl)
      50                 :        2210 :   : type (type), ty (ty), locus (locus), item (impl)
      51                 :        2210 : {}
      52                 :             : 
      53                 :        1857 : PathProbeCandidate::PathProbeCandidate (CandidateType type, TyTy::BaseType *ty,
      54                 :             :                                         location_t locus,
      55                 :        1857 :                                         TraitItemCandidate trait)
      56                 :        1857 :   : type (type), ty (ty), locus (locus), item (trait)
      57                 :        1857 : {}
      58                 :             : 
      59                 :             : std::string
      60                 :           0 : PathProbeCandidate::as_string () const
      61                 :             : {
      62                 :           0 :   return "PathProbe candidate TODO - as_string";
      63                 :             : }
      64                 :             : 
      65                 :             : bool
      66                 :        1585 : PathProbeCandidate::is_enum_candidate () const
      67                 :             : {
      68                 :        1585 :   return type == ENUM_VARIANT;
      69                 :             : }
      70                 :             : 
      71                 :             : bool
      72                 :        5496 : PathProbeCandidate::is_impl_candidate () const
      73                 :             : {
      74                 :        5496 :   return type == IMPL_CONST || type == IMPL_TYPE_ALIAS || type == IMPL_FUNC;
      75                 :             : }
      76                 :             : 
      77                 :             : bool
      78                 :           0 : PathProbeCandidate::is_trait_candidate () const
      79                 :             : {
      80                 :           0 :   return type == TRAIT_ITEM_CONST || type == TRAIT_TYPE_ALIAS
      81                 :           0 :          || type == TRAIT_FUNC;
      82                 :             : }
      83                 :             : 
      84                 :             : bool
      85                 :           0 : PathProbeCandidate::is_full_trait_item_candidate () const
      86                 :             : {
      87                 :           0 :   return is_trait_candidate () && item.trait.impl == nullptr;
      88                 :             : }
      89                 :             : 
      90                 :             : PathProbeCandidate
      91                 :           0 : PathProbeCandidate::get_error ()
      92                 :             : {
      93                 :           0 :   return PathProbeCandidate (ERROR, nullptr, UNDEF_LOCATION,
      94                 :           0 :                              ImplItemCandidate{nullptr, nullptr});
      95                 :             : }
      96                 :             : 
      97                 :             : bool
      98                 :           0 : PathProbeCandidate::is_error () const
      99                 :             : {
     100                 :           0 :   return type == ERROR;
     101                 :             : }
     102                 :             : 
     103                 :             : DefId
     104                 :        2472 : PathProbeCandidate::get_defid () const
     105                 :             : {
     106                 :        2472 :   switch (type)
     107                 :             :     {
     108                 :           0 :     case ENUM_VARIANT:
     109                 :           0 :       return item.enum_field.variant->get_defid ();
     110                 :         928 :       break;
     111                 :             : 
     112                 :         928 :     case IMPL_CONST:
     113                 :         928 :     case IMPL_TYPE_ALIAS:
     114                 :         928 :     case IMPL_FUNC:
     115                 :         928 :       return item.impl.impl_item->get_impl_mappings ().get_defid ();
     116                 :        1544 :       break;
     117                 :             : 
     118                 :        1544 :     case TRAIT_ITEM_CONST:
     119                 :        1544 :     case TRAIT_TYPE_ALIAS:
     120                 :        1544 :     case TRAIT_FUNC:
     121                 :        1544 :       return item.trait.item_ref->get_mappings ().get_defid ();
     122                 :           0 :       break;
     123                 :             : 
     124                 :           0 :     case ERROR:
     125                 :           0 :     default:
     126                 :           0 :       return UNKNOWN_DEFID;
     127                 :             :     }
     128                 :             : 
     129                 :             :   return UNKNOWN_DEFID;
     130                 :             : }
     131                 :             : 
     132                 :             : bool
     133                 :         301 : PathProbeCandidate::operator< (const PathProbeCandidate &c) const
     134                 :             : {
     135                 :         301 :   return get_defid () < c.get_defid ();
     136                 :             : }
     137                 :             : 
     138                 :             : // PathProbeType
     139                 :             : 
     140                 :        2838 : PathProbeType::PathProbeType (const TyTy::BaseType *receiver,
     141                 :             :                               const HIR::PathIdentSegment &query,
     142                 :        2838 :                               DefId specific_trait_id)
     143                 :        2838 :   : TypeCheckBase (), receiver (receiver), search (query),
     144                 :        2838 :     current_impl (nullptr), specific_trait_id (specific_trait_id)
     145                 :        2838 : {}
     146                 :             : 
     147                 :             : std::set<PathProbeCandidate>
     148                 :        2424 : PathProbeType::Probe (const TyTy::BaseType *receiver,
     149                 :             :                       const HIR::PathIdentSegment &segment_name,
     150                 :             :                       bool probe_impls, bool probe_bounds,
     151                 :             :                       bool ignore_mandatory_trait_items,
     152                 :             :                       DefId specific_trait_id)
     153                 :             : {
     154                 :        2424 :   PathProbeType probe (receiver, segment_name, specific_trait_id);
     155                 :        2424 :   if (probe_impls)
     156                 :             :     {
     157                 :         897 :       if (receiver->get_kind () == TyTy::TypeKind::ADT)
     158                 :             :         {
     159                 :         615 :           const TyTy::ADTType *adt
     160                 :             :             = static_cast<const TyTy::ADTType *> (receiver);
     161                 :         615 :           if (adt->is_enum ())
     162                 :           5 :             probe.process_enum_item_for_candiates (adt);
     163                 :             :         }
     164                 :             : 
     165                 :         897 :       probe.process_impl_items_for_candidates ();
     166                 :             :     }
     167                 :             : 
     168                 :        2424 :   if (!probe_bounds)
     169                 :        1586 :     return probe.candidates;
     170                 :             : 
     171                 :         838 :   if (!probe.is_reciever_generic ())
     172                 :             :     {
     173                 :          56 :       std::vector<std::pair<TraitReference *, HIR::ImplBlock *>> probed_bounds
     174                 :          56 :         = TypeBoundsProbe::Probe (receiver);
     175                 :         196 :       for (auto &candidate : probed_bounds)
     176                 :             :         {
     177                 :         140 :           const TraitReference *trait_ref = candidate.first;
     178                 :         280 :           if (specific_trait_id != UNKNOWN_DEFID)
     179                 :             :             {
     180                 :           0 :               if (trait_ref->get_mappings ().get_defid () != specific_trait_id)
     181                 :           0 :                 continue;
     182                 :             :             }
     183                 :             : 
     184                 :         140 :           HIR::ImplBlock *impl = candidate.second;
     185                 :         140 :           probe.process_associated_trait_for_candidates (
     186                 :             :             trait_ref, impl, ignore_mandatory_trait_items);
     187                 :             :         }
     188                 :          56 :     }
     189                 :             : 
     190                 :        1808 :   for (const TyTy::TypeBoundPredicate &predicate :
     191                 :        1808 :        receiver->get_specified_bounds ())
     192                 :             :     {
     193                 :         970 :       const TraitReference *trait_ref = predicate.get ();
     194                 :        1940 :       if (specific_trait_id != UNKNOWN_DEFID)
     195                 :             :         {
     196                 :           0 :           if (trait_ref->get_mappings ().get_defid () != specific_trait_id)
     197                 :           0 :             continue;
     198                 :             :         }
     199                 :             : 
     200                 :         970 :       probe.process_predicate_for_candidates (predicate,
     201                 :             :                                               ignore_mandatory_trait_items);
     202                 :             :     }
     203                 :             : 
     204                 :         838 :   return probe.candidates;
     205                 :        2424 : }
     206                 :             : 
     207                 :             : void
     208                 :         901 : PathProbeType::visit (HIR::TypeAlias &alias)
     209                 :             : {
     210                 :         901 :   Identifier name = alias.get_new_type_name ();
     211                 :         901 :   if (search.as_string ().compare (name.as_string ()) == 0)
     212                 :             :     {
     213                 :         121 :       HirId tyid = alias.get_mappings ().get_hirid ();
     214                 :         121 :       TyTy::BaseType *ty = nullptr;
     215                 :         121 :       bool ok = query_type (tyid, &ty);
     216                 :         121 :       rust_assert (ok);
     217                 :             : 
     218                 :         121 :       PathProbeCandidate::ImplItemCandidate impl_item_candidate{&alias,
     219                 :         121 :                                                                 current_impl};
     220                 :         121 :       PathProbeCandidate candidate{
     221                 :             :         PathProbeCandidate::CandidateType::IMPL_TYPE_ALIAS, ty,
     222                 :         121 :         alias.get_locus (), impl_item_candidate};
     223                 :         121 :       candidates.insert (std::move (candidate));
     224                 :             :     }
     225                 :         901 : }
     226                 :             : 
     227                 :             : void
     228                 :          50 : PathProbeType::visit (HIR::ConstantItem &constant)
     229                 :             : {
     230                 :          50 :   Identifier name = constant.get_identifier ();
     231                 :          50 :   if (search.as_string ().compare (name.as_string ()) == 0)
     232                 :             :     {
     233                 :          24 :       HirId tyid = constant.get_mappings ().get_hirid ();
     234                 :          24 :       TyTy::BaseType *ty = nullptr;
     235                 :          24 :       bool ok = query_type (tyid, &ty);
     236                 :          24 :       rust_assert (ok);
     237                 :             : 
     238                 :          24 :       PathProbeCandidate::ImplItemCandidate impl_item_candidate{&constant,
     239                 :          24 :                                                                 current_impl};
     240                 :          24 :       PathProbeCandidate candidate{
     241                 :             :         PathProbeCandidate::CandidateType::IMPL_CONST, ty,
     242                 :          24 :         constant.get_locus (), impl_item_candidate};
     243                 :          24 :       candidates.insert (std::move (candidate));
     244                 :             :     }
     245                 :          50 : }
     246                 :             : 
     247                 :             : void
     248                 :        3485 : PathProbeType::visit (HIR::Function &function)
     249                 :             : {
     250                 :        3485 :   Identifier name = function.get_function_name ();
     251                 :        3485 :   if (search.as_string ().compare (name.as_string ()) == 0)
     252                 :             :     {
     253                 :         937 :       HirId tyid = function.get_mappings ().get_hirid ();
     254                 :         937 :       TyTy::BaseType *ty = nullptr;
     255                 :         937 :       bool ok = query_type (tyid, &ty);
     256                 :         937 :       rust_assert (ok);
     257                 :             : 
     258                 :         937 :       PathProbeCandidate::ImplItemCandidate impl_item_candidate{&function,
     259                 :         937 :                                                                 current_impl};
     260                 :         937 :       PathProbeCandidate candidate{PathProbeCandidate::CandidateType::IMPL_FUNC,
     261                 :             :                                    ty, function.get_locus (),
     262                 :         937 :                                    impl_item_candidate};
     263                 :         937 :       candidates.insert (std::move (candidate));
     264                 :             :     }
     265                 :        3485 : }
     266                 :             : 
     267                 :             : void
     268                 :           5 : PathProbeType::process_enum_item_for_candiates (const TyTy::ADTType *adt)
     269                 :             : {
     270                 :           5 :   if (specific_trait_id != UNKNOWN_DEFID)
     271                 :           2 :     return;
     272                 :             : 
     273                 :           5 :   TyTy::VariantDef *v;
     274                 :           5 :   if (!adt->lookup_variant (search.as_string (), &v))
     275                 :             :     return;
     276                 :             : 
     277                 :           3 :   PathProbeCandidate::EnumItemCandidate enum_item_candidate{adt, v};
     278                 :           3 :   PathProbeCandidate candidate{PathProbeCandidate::CandidateType::ENUM_VARIANT,
     279                 :           3 :                                receiver->clone (),
     280                 :           3 :                                mappings->lookup_location (adt->get_ty_ref ()),
     281                 :           3 :                                enum_item_candidate};
     282                 :           3 :   candidates.insert (std::move (candidate));
     283                 :             : }
     284                 :             : 
     285                 :             : void
     286                 :         897 : PathProbeType::process_impl_items_for_candidates ()
     287                 :             : {
     288                 :         897 :   mappings->iterate_impl_items (
     289                 :         897 :     [&] (HirId id, HIR::ImplItem *item, HIR::ImplBlock *impl) mutable -> bool {
     290                 :       19738 :       process_impl_item_candidate (id, item, impl);
     291                 :       19738 :       return true;
     292                 :             :     });
     293                 :         897 : }
     294                 :             : 
     295                 :             : void
     296                 :       24152 : PathProbeType::process_impl_item_candidate (HirId id, HIR::ImplItem *item,
     297                 :             :                                             HIR::ImplBlock *impl)
     298                 :             : {
     299                 :       24152 :   current_impl = impl;
     300                 :       24152 :   HirId impl_ty_id = impl->get_type ()->get_mappings ().get_hirid ();
     301                 :       24152 :   TyTy::BaseType *impl_block_ty = nullptr;
     302                 :       24152 :   if (!query_type (impl_ty_id, &impl_block_ty))
     303                 :       19716 :     return;
     304                 :             : 
     305                 :       24152 :   if (!receiver->can_eq (impl_block_ty, false))
     306                 :             :     {
     307                 :       20438 :       if (!impl_block_ty->can_eq (receiver, false))
     308                 :             :         return;
     309                 :             :     }
     310                 :             : 
     311                 :             :   // lets visit the impl_item
     312                 :        4436 :   item->accept_vis (*this);
     313                 :             : }
     314                 :             : 
     315                 :             : void
     316                 :         140 : PathProbeType::process_associated_trait_for_candidates (
     317                 :             :   const TraitReference *trait_ref, HIR::ImplBlock *impl,
     318                 :             :   bool ignore_mandatory_trait_items)
     319                 :             : {
     320                 :         140 :   const TraitItemReference *trait_item_ref = nullptr;
     321                 :         140 :   if (!trait_ref->lookup_trait_item (search.as_string (), &trait_item_ref))
     322                 :          70 :     return;
     323                 :             : 
     324                 :          70 :   bool trait_item_needs_implementation = !trait_item_ref->is_optional ();
     325                 :          70 :   if (ignore_mandatory_trait_items && trait_item_needs_implementation)
     326                 :             :     return;
     327                 :             : 
     328                 :          70 :   PathProbeCandidate::CandidateType candidate_type;
     329                 :          70 :   switch (trait_item_ref->get_trait_item_type ())
     330                 :             :     {
     331                 :             :     case TraitItemReference::TraitItemType::FN:
     332                 :             :       candidate_type = PathProbeCandidate::CandidateType::TRAIT_FUNC;
     333                 :             :       break;
     334                 :             :     case TraitItemReference::TraitItemType::CONST:
     335                 :             :       candidate_type = PathProbeCandidate::CandidateType::TRAIT_ITEM_CONST;
     336                 :             :       break;
     337                 :             :     case TraitItemReference::TraitItemType::TYPE:
     338                 :             :       candidate_type = PathProbeCandidate::CandidateType::TRAIT_TYPE_ALIAS;
     339                 :             :       break;
     340                 :             : 
     341                 :           0 :     case TraitItemReference::TraitItemType::ERROR:
     342                 :           0 :     default:
     343                 :           0 :       rust_unreachable ();
     344                 :          70 :       break;
     345                 :             :     }
     346                 :             : 
     347                 :          70 :   const TyTy::TypeBoundPredicate p (*trait_ref, BoundPolarity::RegularBound,
     348                 :         140 :                                     UNDEF_LOCATION);
     349                 :          70 :   TyTy::TypeBoundPredicateItem item (&p, trait_item_ref);
     350                 :             : 
     351                 :          70 :   TyTy::BaseType *trait_item_tyty = item.get_raw_item ()->get_tyty ();
     352                 :          70 :   if (receiver->get_kind () != TyTy::DYNAMIC)
     353                 :          70 :     trait_item_tyty = item.get_tyty_for_receiver (receiver);
     354                 :             : 
     355                 :          70 :   PathProbeCandidate::TraitItemCandidate trait_item_candidate{trait_ref,
     356                 :             :                                                               trait_item_ref,
     357                 :          70 :                                                               impl};
     358                 :          70 :   PathProbeCandidate candidate{candidate_type, trait_item_tyty,
     359                 :             :                                trait_item_ref->get_locus (),
     360                 :          70 :                                trait_item_candidate};
     361                 :          70 :   candidates.insert (std::move (candidate));
     362                 :             : }
     363                 :             : 
     364                 :             : void
     365                 :         970 : PathProbeType::process_predicate_for_candidates (
     366                 :             :   const TyTy::TypeBoundPredicate &predicate, bool ignore_mandatory_trait_items)
     367                 :             : {
     368                 :         970 :   const TraitReference *trait_ref = predicate.get ();
     369                 :             : 
     370                 :         970 :   TyTy::TypeBoundPredicateItem item
     371                 :         970 :     = predicate.lookup_associated_item (search.as_string ());
     372                 :         970 :   if (item.is_error ())
     373                 :         167 :     return;
     374                 :             : 
     375                 :         803 :   if (ignore_mandatory_trait_items && item.needs_implementation ())
     376                 :             :     return;
     377                 :             : 
     378                 :         803 :   const TraitItemReference *trait_item_ref = item.get_raw_item ();
     379                 :         803 :   PathProbeCandidate::CandidateType candidate_type;
     380                 :         803 :   switch (trait_item_ref->get_trait_item_type ())
     381                 :             :     {
     382                 :             :     case TraitItemReference::TraitItemType::FN:
     383                 :             :       candidate_type = PathProbeCandidate::CandidateType::TRAIT_FUNC;
     384                 :             :       break;
     385                 :             :     case TraitItemReference::TraitItemType::CONST:
     386                 :             :       candidate_type = PathProbeCandidate::CandidateType::TRAIT_ITEM_CONST;
     387                 :             :       break;
     388                 :             :     case TraitItemReference::TraitItemType::TYPE:
     389                 :             :       candidate_type = PathProbeCandidate::CandidateType::TRAIT_TYPE_ALIAS;
     390                 :             :       break;
     391                 :             : 
     392                 :           0 :     case TraitItemReference::TraitItemType::ERROR:
     393                 :           0 :     default:
     394                 :           0 :       rust_unreachable ();
     395                 :         803 :       break;
     396                 :             :     }
     397                 :             : 
     398                 :         803 :   TyTy::BaseType *trait_item_tyty = item.get_raw_item ()->get_tyty ();
     399                 :         803 :   if (receiver->get_kind () != TyTy::DYNAMIC)
     400                 :         710 :     trait_item_tyty = item.get_tyty_for_receiver (receiver);
     401                 :             : 
     402                 :         803 :   PathProbeCandidate::TraitItemCandidate trait_item_candidate{trait_ref,
     403                 :             :                                                               trait_item_ref,
     404                 :         803 :                                                               nullptr};
     405                 :         803 :   PathProbeCandidate candidate{candidate_type, trait_item_tyty,
     406                 :             :                                trait_item_ref->get_locus (),
     407                 :         803 :                                trait_item_candidate};
     408                 :         803 :   candidates.insert (std::move (candidate));
     409                 :             : }
     410                 :             : 
     411                 :             : std::vector<std::pair<const TraitReference *, HIR::ImplBlock *>>
     412                 :           0 : PathProbeType::union_bounds (
     413                 :             :   const std::vector<std::pair</*const*/ TraitReference *, HIR::ImplBlock *>> a,
     414                 :             :   const std::vector<std::pair<const TraitReference *, HIR::ImplBlock *>> b)
     415                 :             :   const
     416                 :             : {
     417                 :           0 :   std::map<DefId, std::pair<const TraitReference *, HIR::ImplBlock *>> mapper;
     418                 :           0 :   for (auto &ref : a)
     419                 :             :     {
     420                 :           0 :       mapper.insert ({ref.first->get_mappings ().get_defid (), ref});
     421                 :             :     }
     422                 :           0 :   for (auto &ref : b)
     423                 :             :     {
     424                 :           0 :       mapper.insert ({ref.first->get_mappings ().get_defid (), ref});
     425                 :             :     }
     426                 :             : 
     427                 :           0 :   std::vector<std::pair<const TraitReference *, HIR::ImplBlock *>> union_set;
     428                 :           0 :   for (auto it = mapper.begin (); it != mapper.end (); it++)
     429                 :             :     {
     430                 :           0 :       union_set.push_back ({it->second.first, it->second.second});
     431                 :             :     }
     432                 :           0 :   return union_set;
     433                 :           0 : }
     434                 :             : 
     435                 :             : bool
     436                 :         838 : PathProbeType::is_reciever_generic () const
     437                 :             : {
     438                 :         838 :   const TyTy::BaseType *root = receiver->get_root ();
     439                 :         838 :   bool receiver_is_type_param = root->get_kind () == TyTy::TypeKind::PARAM;
     440                 :         838 :   bool receiver_is_dyn = root->get_kind () == TyTy::TypeKind::DYNAMIC;
     441                 :         838 :   return receiver_is_type_param || receiver_is_dyn;
     442                 :             : }
     443                 :             : 
     444                 :             : // PathProbImplTrait
     445                 :             : 
     446                 :         414 : PathProbeImplTrait::PathProbeImplTrait (const TyTy::BaseType *receiver,
     447                 :             :                                         const HIR::PathIdentSegment &query,
     448                 :         414 :                                         const TraitReference *trait_reference)
     449                 :             :   : PathProbeType (receiver, query, UNKNOWN_DEFID),
     450                 :         414 :     trait_reference (trait_reference)
     451                 :         414 : {}
     452                 :             : 
     453                 :             : std::set<PathProbeCandidate>
     454                 :         414 : PathProbeImplTrait::Probe (const TyTy::BaseType *receiver,
     455                 :             :                            const HIR::PathIdentSegment &segment_name,
     456                 :             :                            const TraitReference *trait_reference)
     457                 :             : {
     458                 :         414 :   PathProbeImplTrait probe (receiver, segment_name, trait_reference);
     459                 :             :   // iterate all impls for this trait and receiver
     460                 :             :   // then search for possible candidates using base class behaviours
     461                 :         414 :   probe.process_trait_impl_items_for_candidates ();
     462                 :         414 :   return probe.candidates;
     463                 :         414 : }
     464                 :             : 
     465                 :             : void
     466                 :         414 : PathProbeImplTrait::process_trait_impl_items_for_candidates ()
     467                 :             : {
     468                 :         414 :   mappings->iterate_impl_items (
     469                 :         414 :     [&] (HirId id, HIR::ImplItem *item, HIR::ImplBlock *impl) mutable -> bool {
     470                 :             :       // just need to check if this is an impl block for this trait the next
     471                 :             :       // function checks the receiver
     472                 :        8192 :       if (!impl->has_trait_ref ())
     473                 :             :         return true;
     474                 :             : 
     475                 :        6260 :       TraitReference *resolved
     476                 :        6260 :         = TraitResolver::Lookup (*(impl->get_trait_ref ().get ()));
     477                 :        6260 :       if (!trait_reference->is_equal (*resolved))
     478                 :             :         return true;
     479                 :             : 
     480                 :        4414 :       process_impl_item_candidate (id, item, impl);
     481                 :        4414 :       return true;
     482                 :             :     });
     483                 :         414 : }
     484                 :             : 
     485                 :             : } // namespace Resolver
     486                 :             : } // 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.