LCOV - code coverage report
Current view: top level - gcc/rust/typecheck - rust-hir-dot-operator.cc (source / functions) Coverage Total Hit
Test: gcc.info Lines: 92.2 % 268 247
Test Date: 2026-07-11 15:47:05 Functions: 100.0 % 14 14
Legend: Lines:     hit not hit

            Line data    Source code
       1              : // Copyright (C) 2020-2026 Free Software Foundation, Inc.
       2              : 
       3              : // This file is part of GCC.
       4              : 
       5              : // GCC is free software; you can redistribute it and/or modify it under
       6              : // the terms of the GNU General Public License as published by the Free
       7              : // Software Foundation; either version 3, or (at your option) any later
       8              : // version.
       9              : 
      10              : // GCC is distributed in the hope that it will be useful, but WITHOUT ANY
      11              : // WARRANTY; without even the implied warranty of MERCHANTABILITY or
      12              : // FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
      13              : // for more details.
      14              : 
      15              : // You should have received a copy of the GNU General Public License
      16              : // along with GCC; see the file COPYING3.  If not see
      17              : // <http://www.gnu.org/licenses/>.
      18              : 
      19              : #include "rust-hir-dot-operator.h"
      20              : #include "rust-hir-path-probe.h"
      21              : #include "rust-hir-trait-resolve.h"
      22              : #include "rust-hir-type-check-item.h"
      23              : #include "rust-type-util.h"
      24              : #include "rust-coercion.h"
      25              : 
      26              : namespace Rust {
      27              : namespace Resolver {
      28              : 
      29         5928 : MethodResolver::MethodResolver (bool autoderef_flag,
      30         5928 :                                 const HIR::PathIdentSegment &segment_name)
      31         5928 :   : AutoderefCycle (autoderef_flag), segment_name (segment_name), result ()
      32         5928 : {}
      33              : 
      34              : std::set<MethodCandidate>
      35         5928 : MethodResolver::Probe (TyTy::BaseType *receiver,
      36              :                        const HIR::PathIdentSegment &segment_name,
      37              :                        bool autoderef_flag)
      38              : {
      39         5928 :   MethodResolver resolver (autoderef_flag, segment_name);
      40         5928 :   resolver.cycle (receiver);
      41         5928 :   return resolver.result;
      42         5928 : }
      43              : 
      44              : std::set<MethodCandidate>
      45         2817 : MethodResolver::Select (std::set<MethodCandidate> &candidates,
      46              :                         TyTy::BaseType *receiver,
      47              :                         std::vector<TyTy::BaseType *> arguments)
      48              : {
      49         2817 :   std::set<MethodCandidate> selected;
      50         4475 :   for (auto &candidate : candidates)
      51              :     {
      52         1658 :       TyTy::BaseType *candidate_type = candidate.candidate.ty;
      53         1658 :       rust_assert (candidate_type->get_kind () == TyTy::TypeKind::FNDEF);
      54         1658 :       if (candidate_type == nullptr
      55         1658 :           || candidate_type->get_kind () != TyTy::TypeKind::FNDEF)
      56            0 :         continue;
      57         1658 :       TyTy::FnType &fn = *static_cast<TyTy::FnType *> (candidate_type);
      58              : 
      59              :       // match the number of arguments
      60         1658 :       if (fn.num_params () != (arguments.size () + 1))
      61            0 :         continue;
      62              : 
      63              :       // match the arguments
      64         2957 :       bool failed = false;
      65         2957 :       for (size_t i = 0; i < arguments.size (); i++)
      66              :         {
      67         1326 :           TyTy::BaseType *arg = arguments.at (i);
      68         1326 :           TyTy::BaseType *param = fn.get_params ().at (i + 1).get_type ();
      69         1326 :           TyTy::BaseType *coerced
      70         1326 :             = try_coercion (0, TyTy::TyWithLocation (param),
      71         1326 :                             TyTy::TyWithLocation (arg), UNDEF_LOCATION);
      72         1326 :           if (coerced->get_kind () == TyTy::TypeKind::ERROR)
      73              :             {
      74              :               failed = true;
      75              :               break;
      76              :             }
      77              :         }
      78              : 
      79         1658 :       if (!failed)
      80         1631 :         selected.insert (candidate);
      81              :     }
      82              : 
      83         2817 :   return selected;
      84              : }
      85              : 
      86              : void
      87         6086 : MethodResolver::try_hook (const TyTy::BaseType &r)
      88              : {
      89         6086 :   rust_debug ("MethodResolver::try_hook get_predicate_items: [%s]",
      90              :               r.debug_str ().c_str ());
      91         6086 :   const auto &specified_bounds = r.get_specified_bounds ();
      92         6086 :   predicate_items = get_predicate_items (segment_name, r, specified_bounds);
      93              : 
      94         6086 :   if (predicate_items.size () > 0)
      95              :     return;
      96              : 
      97         5686 :   if (r.get_kind () == TyTy::TypeKind::REF)
      98              :     {
      99         1208 :       const auto &ref = static_cast<const TyTy::ReferenceType &> (r);
     100         1208 :       const auto &element = ref.get_var_element_type ();
     101         1208 :       const auto &element_ty = *element.get_tyty ();
     102         1208 :       const auto &specified_bounds = element_ty.get_specified_bounds ();
     103         1208 :       predicate_items
     104         1208 :         = get_predicate_items (segment_name, element_ty, specified_bounds);
     105              :     }
     106              : }
     107              : 
     108              : std::vector<MethodResolver::impl_item_candidate>
     109         9018 : MethodResolver::assemble_inherent_impl_candidates (
     110              :   const TyTy::BaseType &receiver)
     111              : {
     112         9018 :   std::vector<impl_item_candidate> inherent_impl_fns;
     113         9018 :   const TyTy::BaseType *raw = receiver.destructure ();
     114         9018 :   bool receiver_is_raw_ptr = raw->get_kind () == TyTy::TypeKind::POINTER;
     115         9018 :   bool receiver_is_ref = raw->get_kind () == TyTy::TypeKind::REF;
     116              : 
     117              :   // Assemble inherent impl items (non-trait impl blocks)
     118         9018 :   mappings.iterate_impl_items (
     119         9018 :     [&] (HirId id, HIR::ImplItem *item, HIR::ImplBlock *impl) mutable -> bool {
     120       237555 :       bool is_trait_impl = impl->has_trait_ref ();
     121       237555 :       if (is_trait_impl)
     122              :         return true;
     123              : 
     124        77368 :       bool is_fn
     125        77368 :         = item->get_impl_item_type () == HIR::ImplItem::ImplItemType::FUNCTION;
     126        77368 :       if (!is_fn)
     127              :         return true;
     128              : 
     129        77368 :       HIR::Function *func = static_cast<HIR::Function *> (item);
     130        77368 :       if (!func->is_method ())
     131              :         return true;
     132              : 
     133        59885 :       bool name_matches = func->get_function_name ().as_string ().compare (
     134       119770 :                             segment_name.to_string ())
     135        59885 :                           == 0;
     136        59885 :       if (!name_matches)
     137              :         return true;
     138              : 
     139         6903 :       TyTy::BaseType *ty = nullptr;
     140         6903 :       if (!query_type (func->get_mappings ().get_hirid (), &ty))
     141              :         return true;
     142         6903 :       if (ty == nullptr || ty->get_kind () == TyTy::TypeKind::ERROR)
     143            0 :         return true;
     144         6903 :       if (ty->get_kind () != TyTy::TypeKind::FNDEF)
     145              :         return true;
     146              : 
     147         6903 :       TyTy::FnType *fnty = static_cast<TyTy::FnType *> (ty);
     148         6903 :       const TyTy::BaseType *impl_self
     149         6903 :         = TypeCheckItem::ResolveImplBlockSelf (*impl);
     150              : 
     151              :       // see:
     152              :       // https://gcc-rust.zulipchat.com/#narrow/stream/266897-general/topic/Method.20Resolution/near/338646280
     153              :       // https://github.com/rust-lang/rust/blob/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/compiler/rustc_typeck/src/check/method/probe.rs#L650-L660
     154         6903 :       bool impl_self_is_ptr = impl_self->get_kind () == TyTy::TypeKind::POINTER;
     155         6903 :       bool impl_self_is_ref = impl_self->get_kind () == TyTy::TypeKind::REF;
     156         6903 :       if (receiver_is_raw_ptr && impl_self_is_ptr)
     157              :         {
     158          508 :           const TyTy::PointerType &sptr
     159              :             = *static_cast<const TyTy::PointerType *> (impl_self);
     160          508 :           const TyTy::PointerType &ptr
     161          508 :             = *static_cast<const TyTy::PointerType *> (raw);
     162              : 
     163              :           // we could do this via lang-item assemblies if we refactor this
     164          508 :           bool mut_match = sptr.mutability () == ptr.mutability ();
     165          508 :           if (!mut_match)
     166              :             return true;
     167              :         }
     168         6395 :       else if (receiver_is_ref && impl_self_is_ref)
     169              :         {
     170            0 :           const TyTy::ReferenceType &sptr
     171              :             = *static_cast<const TyTy::ReferenceType *> (impl_self);
     172            0 :           const TyTy::ReferenceType &ptr
     173            0 :             = *static_cast<const TyTy::ReferenceType *> (raw);
     174              : 
     175              :           // we could do this via lang-item assemblies if we refactor this
     176            0 :           bool mut_match = sptr.mutability () == ptr.mutability ();
     177            0 :           if (!mut_match)
     178              :             return true;
     179              :         }
     180              : 
     181         6794 :       inherent_impl_fns.emplace_back (func, impl, fnty);
     182              : 
     183         6794 :       return true;
     184              :     });
     185              : 
     186         9018 :   return inherent_impl_fns;
     187              : }
     188              : 
     189              : void
     190         9018 : MethodResolver::assemble_trait_impl_candidates (
     191              :   const TyTy::BaseType &receiver,
     192              :   std::vector<impl_item_candidate> &impl_candidates,
     193              :   std::vector<trait_item_candidate> &trait_candidates)
     194              : {
     195         9018 :   const TyTy::BaseType *raw = receiver.destructure ();
     196         9018 :   bool receiver_is_raw_ptr = raw->get_kind () == TyTy::TypeKind::POINTER;
     197         9018 :   bool receiver_is_ref = raw->get_kind () == TyTy::TypeKind::REF;
     198              : 
     199         9018 :   mappings.iterate_impl_blocks ([&] (HirId id,
     200              :                                      HIR::ImplBlock *impl) mutable -> bool {
     201       132195 :     bool is_trait_impl = impl->has_trait_ref ();
     202       132195 :     if (!is_trait_impl)
     203              :       return true;
     204              : 
     205              :     // look for impl implementation else lookup the associated trait item
     206       242422 :     for (auto &impl_item : impl->get_impl_items ())
     207              :       {
     208       149746 :         bool is_fn = impl_item->get_impl_item_type ()
     209       149746 :                      == HIR::ImplItem::ImplItemType::FUNCTION;
     210       149746 :         if (!is_fn)
     211       129983 :           continue;
     212              : 
     213       115566 :         HIR::Function *func = static_cast<HIR::Function *> (impl_item.get ());
     214       115566 :         if (!func->is_method ())
     215         6745 :           continue;
     216              : 
     217       108821 :         bool name_matches = func->get_function_name ().as_string ().compare (
     218       217642 :                               segment_name.to_string ())
     219       108821 :                             == 0;
     220       108821 :         if (!name_matches)
     221        88803 :           continue;
     222              : 
     223        20018 :         TyTy::BaseType *ty = nullptr;
     224        20018 :         if (!query_type (func->get_mappings ().get_hirid (), &ty))
     225            0 :           continue;
     226        20018 :         if (ty == nullptr || ty->get_kind () == TyTy::TypeKind::ERROR)
     227            0 :           continue;
     228        20018 :         if (ty->get_kind () != TyTy::TypeKind::FNDEF)
     229            0 :           continue;
     230              : 
     231        20018 :         TyTy::FnType *fnty = static_cast<TyTy::FnType *> (ty);
     232        20018 :         const TyTy::BaseType *impl_self
     233        20018 :           = TypeCheckItem::ResolveImplBlockSelf (*impl);
     234              : 
     235              :         // see:
     236              :         // https://gcc-rust.zulipchat.com/#narrow/stream/266897-general/topic/Method.20Resolution/near/338646280
     237              :         // https://github.com/rust-lang/rust/blob/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/compiler/rustc_typeck/src/check/method/probe.rs#L650-L660
     238        20018 :         bool impl_self_is_ptr
     239        20018 :           = impl_self->get_kind () == TyTy::TypeKind::POINTER;
     240        20018 :         bool impl_self_is_ref = impl_self->get_kind () == TyTy::TypeKind::REF;
     241        20018 :         if (receiver_is_raw_ptr && impl_self_is_ptr)
     242              :           {
     243            0 :             const TyTy::PointerType &sptr
     244              :               = *static_cast<const TyTy::PointerType *> (impl_self);
     245            0 :             const TyTy::PointerType &ptr
     246            0 :               = *static_cast<const TyTy::PointerType *> (raw);
     247              : 
     248              :             // we could do this via lang-item assemblies if we refactor this
     249            0 :             bool mut_match = sptr.mutability () == ptr.mutability ();
     250            0 :             if (!mut_match)
     251            0 :               continue;
     252              :           }
     253        20018 :         else if (receiver_is_ref && impl_self_is_ref)
     254              :           {
     255          545 :             const TyTy::ReferenceType &sptr
     256              :               = *static_cast<const TyTy::ReferenceType *> (impl_self);
     257          545 :             const TyTy::ReferenceType &ptr
     258          545 :               = *static_cast<const TyTy::ReferenceType *> (raw);
     259              : 
     260              :             // we could do this via lang-item assemblies if we refactor this
     261          545 :             bool mut_match = sptr.mutability () == ptr.mutability ();
     262          545 :             if (!mut_match)
     263          255 :               continue;
     264              :           }
     265              : 
     266        19763 :         impl_candidates.emplace_back (func, impl, fnty);
     267        19763 :         return true;
     268              :       }
     269              : 
     270        92676 :     TraitReference *trait_ref = TraitResolver::Resolve (impl->get_trait_ref ());
     271        92676 :     rust_assert (!trait_ref->is_error ());
     272              : 
     273        92676 :     auto item_ref
     274       185352 :       = trait_ref->lookup_trait_item (segment_name.to_string (),
     275        92676 :                                       TraitItemReference::TraitItemType::FN);
     276        92676 :     if (item_ref->is_error ())
     277              :       return true;
     278              : 
     279        15570 :     const HIR::Trait *trait = trait_ref->get_hir_trait_ref ();
     280        15570 :     HIR::TraitItem *item = item_ref->get_hir_trait_item ();
     281        15570 :     if (item->get_item_kind () != HIR::TraitItem::TraitItemKind::FUNC)
     282              :       return true;
     283              : 
     284        15570 :     HIR::TraitItemFunc *func = static_cast<HIR::TraitItemFunc *> (item);
     285        15570 :     if (!func->get_decl ().is_method ())
     286              :       return true;
     287              : 
     288        15567 :     TyTy::BaseType *ty = item_ref->get_tyty ();
     289        15567 :     if (ty == nullptr || ty->get_kind () != TyTy::TypeKind::FNDEF)
     290            0 :       return true;
     291        15567 :     TyTy::FnType *fnty = static_cast<TyTy::FnType *> (ty);
     292              : 
     293        15567 :     trait_candidates.emplace_back (func, trait, fnty, trait_ref, item_ref);
     294              : 
     295        15567 :     return true;
     296              :   });
     297         9018 : }
     298              : 
     299              : bool
     300         9018 : MethodResolver::try_select_predicate_candidates (TyTy::BaseType &receiver)
     301              : {
     302         9018 :   bool found_possible_candidate = false;
     303        10576 :   for (const auto &predicate : predicate_items)
     304              :     {
     305         1558 :       const TyTy::FnType *fn = predicate.fntype;
     306         3116 :       if (!fn->is_method ())
     307            0 :         continue;
     308              : 
     309         1558 :       TyTy::BaseType *fn_self = fn->get_self_type ();
     310         1558 :       rust_debug ("dot-operator predicate fn_self={%s} can_eq receiver={%s}",
     311              :                   fn_self->debug_str ().c_str (),
     312              :                   receiver.debug_str ().c_str ());
     313              : 
     314         1558 :       auto res
     315              :         = TypeCoercionRules::TryCoerce (&receiver, fn_self, UNDEF_LOCATION,
     316         1558 :                                         false /*allow-autoderef*/);
     317         1558 :       bool ok = !res.is_error ();
     318         1558 :       if (ok)
     319              :         {
     320         1312 :           std::vector<Adjustment> adjs = append_adjustments (res.adjustments);
     321         1312 :           const TraitReference *trait_ref
     322         1312 :             = predicate.lookup.get_parent ()->get ();
     323         1312 :           const TraitItemReference *trait_item
     324         1312 :             = predicate.lookup.get_raw_item ();
     325              : 
     326         1312 :           PathProbeCandidate::TraitItemCandidate c{trait_ref, trait_item,
     327         1312 :                                                    nullptr};
     328         1312 :           auto try_result = MethodCandidate{
     329              :             PathProbeCandidate (PathProbeCandidate::CandidateType::TRAIT_FUNC,
     330              :                                 fn->clone (), trait_item->get_locus (), c),
     331         1312 :             adjs};
     332         1312 :           result.insert (std::move (try_result));
     333         1312 :           found_possible_candidate = true;
     334         1312 :         }
     335         1558 :     }
     336         9018 :   return found_possible_candidate;
     337              : }
     338              : 
     339              : bool
     340        13838 : MethodResolver::try_select_inherent_impl_candidates (
     341              :   TyTy::BaseType &receiver, const std::vector<impl_item_candidate> &candidates,
     342              :   bool trait_impl_blocks_only)
     343              : {
     344        13838 :   bool found_possible_candidate = false;
     345        54421 :   for (auto &impl_item : candidates)
     346              :     {
     347        40583 :       bool is_trait_impl_block = impl_item.impl_block->has_trait_ref ();
     348        40583 :       if (trait_impl_blocks_only && !is_trait_impl_block)
     349        17528 :         continue;
     350        39716 :       if (!trait_impl_blocks_only && is_trait_impl_block)
     351        16661 :         continue;
     352              : 
     353        23055 :       TyTy::FnType *fn = impl_item.ty;
     354        46110 :       if (!fn->is_method ())
     355            0 :         continue;
     356              : 
     357        23055 :       TyTy::BaseType *fn_self = fn->get_self_type ();
     358              : 
     359         6794 :       const char *debug_prefix
     360        23055 :         = trait_impl_blocks_only ? "trait_impl_item" : "impl_item";
     361        23055 :       rust_debug ("dot-operator %s fn_self={%s} can_eq receiver={%s}",
     362              :                   debug_prefix, fn_self->debug_str ().c_str (),
     363              :                   receiver.debug_str ().c_str ());
     364              : 
     365        23055 :       auto res
     366              :         = TypeCoercionRules::TryCoerce (&receiver, fn_self, UNDEF_LOCATION,
     367        23055 :                                         false /*allow-autoderef*/);
     368        23055 :       bool ok = !res.is_error ();
     369        23055 :       if (ok)
     370              :         {
     371         4536 :           std::vector<Adjustment> adjs = append_adjustments (res.adjustments);
     372         4536 :           PathProbeCandidate::ImplItemCandidate c{impl_item.item,
     373         4536 :                                                   impl_item.impl_block};
     374         4536 :           auto try_result = MethodCandidate{
     375              :             PathProbeCandidate (PathProbeCandidate::CandidateType::IMPL_FUNC,
     376         4536 :                                 fn, impl_item.item->get_locus (), c),
     377         4536 :             adjs};
     378         4536 :           result.insert (std::move (try_result));
     379         4536 :           found_possible_candidate = true;
     380         4536 :         }
     381        23055 :     }
     382        13838 :   return found_possible_candidate;
     383              : }
     384              : 
     385              : bool
     386         3323 : MethodResolver::try_select_trait_impl_candidates (
     387              :   TyTy::BaseType &receiver, const std::vector<trait_item_candidate> &candidates)
     388              : {
     389         3323 :   bool found_possible_candidate = false;
     390        10525 :   for (auto trait_item : candidates)
     391              :     {
     392         7202 :       TyTy::FnType *fn = trait_item.ty;
     393        14404 :       if (!fn->is_method ())
     394            0 :         continue;
     395              : 
     396         7202 :       TyTy::BaseType *fn_self = fn->get_self_type ();
     397         7202 :       rust_debug ("dot-operator trait_item fn_self={%s} can_eq receiver={%s}",
     398              :                   fn_self->debug_str ().c_str (),
     399              :                   receiver.debug_str ().c_str ());
     400              : 
     401         7202 :       auto res
     402              :         = TypeCoercionRules::TryCoerce (&receiver, fn_self, UNDEF_LOCATION,
     403         7202 :                                         false /*allow-autoderef*/);
     404         7202 :       bool ok = !res.is_error ();
     405         7202 :       if (ok)
     406              :         {
     407          531 :           std::vector<Adjustment> adjs = append_adjustments (res.adjustments);
     408          531 :           PathProbeCandidate::TraitItemCandidate c{trait_item.reference,
     409              :                                                    trait_item.item_ref,
     410          531 :                                                    nullptr};
     411          531 :           auto try_result = MethodCandidate{
     412              :             PathProbeCandidate (PathProbeCandidate::CandidateType::TRAIT_FUNC,
     413          531 :                                 fn, trait_item.item->get_locus (), c),
     414          531 :             adjs};
     415          531 :           result.insert (std::move (try_result));
     416          531 :           found_possible_candidate = true;
     417          531 :         }
     418         7202 :     }
     419         3323 :   return found_possible_candidate;
     420              : }
     421              : 
     422              : bool
     423         9018 : MethodResolver::select (TyTy::BaseType &receiver)
     424              : {
     425        18036 :   rust_debug ("MethodResolver::select reciever=[%s] path=[%s]",
     426              :               receiver.debug_str ().c_str (),
     427              :               segment_name.to_string ().c_str ());
     428              : 
     429              :   // Assemble candidates
     430         9018 :   std::vector<impl_item_candidate> inherent_impl_fns
     431         9018 :     = assemble_inherent_impl_candidates (receiver);
     432         9018 :   std::vector<impl_item_candidate> trait_impl_fns;
     433         9018 :   std::vector<trait_item_candidate> trait_fns;
     434         9018 :   assemble_trait_impl_candidates (receiver, trait_impl_fns, trait_fns);
     435              : 
     436              :   // Combine inherent and trait impl functions
     437         9018 :   inherent_impl_fns.insert (inherent_impl_fns.end (), trait_impl_fns.begin (),
     438              :                             trait_impl_fns.end ());
     439              : 
     440              :   // https://github.com/rust-lang/rust/blob/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/compiler/rustc_typeck/src/check/method/probe.rs#L580-L694
     441              : 
     442         9018 :   rust_debug ("inherent_impl_fns found {%lu}, trait_fns found {%lu}, "
     443              :               "predicate_items found {%lu}",
     444              :               (unsigned long) inherent_impl_fns.size (),
     445              :               (unsigned long) trait_fns.size (),
     446              :               (unsigned long) predicate_items.size ());
     447              : 
     448              :   // Try selection in the priority order defined by Rust's method resolution:
     449              : 
     450              :   // 1. Try predicate candidates first (highest priority)
     451         9018 :   if (try_select_predicate_candidates (receiver))
     452              :     return true;
     453              : 
     454              :   // 2. Try inherent impl functions (non-trait impl blocks)
     455         7706 :   if (try_select_inherent_impl_candidates (receiver, inherent_impl_fns, false))
     456              :     return true;
     457              : 
     458              :   // 3. Try inherent impl functions from trait impl blocks
     459         6132 :   if (try_select_inherent_impl_candidates (receiver, inherent_impl_fns, true))
     460              :     return true;
     461              : 
     462              :   // 4. Try trait functions (lowest priority)
     463         3323 :   return try_select_trait_impl_candidates (receiver, trait_fns);
     464         9018 : }
     465              : 
     466              : std::vector<MethodResolver::predicate_candidate>
     467         7294 : MethodResolver::get_predicate_items (
     468              :   const HIR::PathIdentSegment &segment_name, const TyTy::BaseType &receiver,
     469              :   const std::vector<TyTy::TypeBoundPredicate> &specified_bounds)
     470              : {
     471         7294 :   std::vector<predicate_candidate> predicate_items;
     472         9609 :   for (auto &bound : specified_bounds)
     473              :     {
     474         2315 :       tl::optional<TyTy::TypeBoundPredicateItem> lookup
     475         2315 :         = bound.lookup_associated_item (segment_name.to_string ());
     476         2315 :       if (!lookup.has_value ())
     477          999 :         continue;
     478              : 
     479         1316 :       TyTy::BaseType *ty = lookup->get_tyty_for_receiver (&receiver);
     480         1316 :       if (ty->get_kind () == TyTy::TypeKind::FNDEF)
     481              :         {
     482         1316 :           TyTy::FnType *fnty = static_cast<TyTy::FnType *> (ty);
     483         3944 :           if (fnty->is_method ())
     484         1312 :             predicate_items.emplace_back (lookup.value (), fnty);
     485              :         }
     486         2315 :     }
     487              : 
     488         7294 :   return predicate_items;
     489              : }
     490              : 
     491              : std::vector<Adjustment>
     492         6379 : MethodResolver::append_adjustments (const std::vector<Adjustment> &adjs) const
     493              : {
     494         6379 :   std::vector<Adjustment> combined;
     495         6379 :   combined.reserve (adjustments.size () + adjs.size ());
     496              : 
     497         9277 :   for (const auto &a : adjustments)
     498         2898 :     combined.push_back (a);
     499         6449 :   for (const auto &a : adjs)
     500           70 :     combined.push_back (a);
     501              : 
     502         6379 :   return combined;
     503              : }
     504              : 
     505              : } // namespace Resolver
     506              : } // 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.