LCOV - code coverage report
Current view: top level - gcc/rust/typecheck - rust-hir-dot-operator.h (source / functions) Coverage Total Hit
Test: gcc.info Lines: 100.0 % 12 12
Test Date: 2026-02-28 14:20:25 Functions: 100.0 % 1 1
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              : #ifndef RUST_HIR_DOT_OPERATOR
      20              : #define RUST_HIR_DOT_OPERATOR
      21              : 
      22              : #include "rust-hir-path-probe.h"
      23              : 
      24              : namespace Rust {
      25              : namespace Resolver {
      26              : 
      27        39643 : struct MethodCandidate
      28              : {
      29              :   PathProbeCandidate candidate;
      30              :   std::vector<Adjustment> adjustments;
      31              : 
      32              :   static MethodCandidate get_error ()
      33              :   {
      34              :     return {PathProbeCandidate::get_error (), {}};
      35              :   }
      36              : 
      37              :   bool is_error () const { return candidate.is_error (); }
      38              : 
      39         5142 :   DefId get_defid () const { return candidate.get_defid (); }
      40              : 
      41         2571 :   bool operator< (const MethodCandidate &c) const
      42              :   {
      43         2571 :     return get_defid () < c.get_defid ();
      44              :   }
      45              : };
      46              : 
      47              : class MethodResolver : private TypeCheckBase, protected AutoderefCycle
      48              : {
      49              : public:
      50         1262 :   struct predicate_candidate
      51              :   {
      52         1262 :     predicate_candidate (TyTy::TypeBoundPredicateItem lookup,
      53              :                          TyTy::FnType *fntype)
      54         1262 :       : lookup (lookup), fntype (fntype)
      55              :     {}
      56              :     TyTy::TypeBoundPredicateItem lookup;
      57              :     TyTy::FnType *fntype;
      58              :   };
      59              : 
      60              :   static std::set<MethodCandidate>
      61              :   Probe (TyTy::BaseType *receiver, const HIR::PathIdentSegment &segment_name,
      62              :          bool autoderef_flag = false);
      63              : 
      64              :   static std::set<MethodCandidate>
      65              :   Select (std::set<MethodCandidate> &candidates, TyTy::BaseType *receiver,
      66              :           std::vector<TyTy::BaseType *> arguments);
      67              : 
      68              :   static std::vector<predicate_candidate> get_predicate_items (
      69              :     const HIR::PathIdentSegment &segment_name, const TyTy::BaseType &receiver,
      70              :     const std::vector<TyTy::TypeBoundPredicate> &specified_bounds);
      71              : 
      72              :   struct impl_item_candidate
      73              :   {
      74        26447 :     impl_item_candidate (HIR::Function *item, HIR::ImplBlock *impl_block,
      75              :                          TyTy::FnType *ty)
      76        26447 :       : item (item), impl_block (impl_block), ty (ty)
      77              :     {}
      78              : 
      79              :     HIR::Function *item;
      80              :     HIR::ImplBlock *impl_block;
      81              :     TyTy::FnType *ty;
      82              :   };
      83              : 
      84              :   struct trait_item_candidate
      85              :   {
      86        15561 :     trait_item_candidate (const HIR::TraitItemFunc *item,
      87              :                           const HIR::Trait *trait, TyTy::FnType *ty,
      88              :                           const TraitReference *reference,
      89              :                           const TraitItemReference *item_ref)
      90        15561 :       : item (item), trait (trait), ty (ty), reference (reference),
      91        15561 :         item_ref (item_ref)
      92              :     {}
      93              :     const HIR::TraitItemFunc *item;
      94              :     const HIR::Trait *trait;
      95              :     TyTy::FnType *ty;
      96              :     const TraitReference *reference;
      97              :     const TraitItemReference *item_ref;
      98              :   };
      99              : 
     100              : protected:
     101              :   MethodResolver (bool autoderef_flag,
     102              :                   const HIR::PathIdentSegment &segment_name);
     103              : 
     104              :   void try_hook (const TyTy::BaseType &r) override;
     105              : 
     106              :   bool select (TyTy::BaseType &receiver) override;
     107              : 
     108              : private:
     109              :   std::vector<Adjustment>
     110              :   append_adjustments (const std::vector<Adjustment> &adjustments) const;
     111              : 
     112              :   std::vector<impl_item_candidate>
     113              :   assemble_inherent_impl_candidates (const TyTy::BaseType &receiver);
     114              : 
     115              :   void assemble_trait_impl_candidates (
     116              :     const TyTy::BaseType &receiver,
     117              :     std::vector<impl_item_candidate> &impl_candidates,
     118              :     std::vector<trait_item_candidate> &trait_candidates);
     119              : 
     120              :   bool try_select_predicate_candidates (TyTy::BaseType &receiver);
     121              : 
     122              :   bool try_select_inherent_impl_candidates (
     123              :     TyTy::BaseType &receiver,
     124              :     const std::vector<impl_item_candidate> &candidates,
     125              :     bool trait_impl_blocks_only);
     126              : 
     127              :   bool try_select_trait_impl_candidates (
     128              :     TyTy::BaseType &receiver,
     129              :     const std::vector<trait_item_candidate> &candidates);
     130              : 
     131              : private:
     132              :   // search
     133              :   const HIR::PathIdentSegment &segment_name;
     134              :   std::vector<MethodResolver::predicate_candidate> predicate_items;
     135              : 
     136              :   // mutable fields
     137              :   std::set<MethodCandidate> result;
     138              : };
     139              : 
     140              : } // namespace Resolver
     141              : } // namespace Rust
     142              : 
     143              : #endif // RUST_HIR_DOT_OPERATOR
        

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.