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 % 5 5
Test Date: 2025-08-30 13:27:53 Functions: 100.0 % 1 1
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: - 0 0

             Branch data     Line data    Source code
       1                 :             : // Copyright (C) 2020-2025 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                 :       39563 : 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                 :        3777 :   struct predicate_candidate
      51                 :             :   {
      52                 :             :     TyTy::TypeBoundPredicateItem lookup;
      53                 :             :     TyTy::FnType *fntype;
      54                 :             :   };
      55                 :             : 
      56                 :             :   static std::set<MethodCandidate>
      57                 :             :   Probe (TyTy::BaseType *receiver, const HIR::PathIdentSegment &segment_name,
      58                 :             :          bool autoderef_flag = false);
      59                 :             : 
      60                 :             :   static std::set<MethodCandidate>
      61                 :             :   Select (std::set<MethodCandidate> &candidates, TyTy::BaseType *receiver,
      62                 :             :           std::vector<TyTy::BaseType *> arguments);
      63                 :             : 
      64                 :             :   static std::vector<predicate_candidate> get_predicate_items (
      65                 :             :     const HIR::PathIdentSegment &segment_name, const TyTy::BaseType &receiver,
      66                 :             :     const std::vector<TyTy::TypeBoundPredicate> &specified_bounds);
      67                 :             : 
      68                 :             :   struct impl_item_candidate
      69                 :             :   {
      70                 :             :     HIR::Function *item;
      71                 :             :     HIR::ImplBlock *impl_block;
      72                 :             :     TyTy::FnType *ty;
      73                 :             :   };
      74                 :             : 
      75                 :             :   struct trait_item_candidate
      76                 :             :   {
      77                 :             :     const HIR::TraitItemFunc *item;
      78                 :             :     const HIR::Trait *trait;
      79                 :             :     TyTy::FnType *ty;
      80                 :             :     const TraitReference *reference;
      81                 :             :     const TraitItemReference *item_ref;
      82                 :             :   };
      83                 :             : 
      84                 :             : protected:
      85                 :             :   MethodResolver (bool autoderef_flag,
      86                 :             :                   const HIR::PathIdentSegment &segment_name);
      87                 :             : 
      88                 :             :   void try_hook (const TyTy::BaseType &r) override;
      89                 :             : 
      90                 :             :   bool select (TyTy::BaseType &receiver) override;
      91                 :             : 
      92                 :             : private:
      93                 :             :   std::vector<Adjustment>
      94                 :             :   append_adjustments (const std::vector<Adjustment> &adjustments) const;
      95                 :             : 
      96                 :             :   std::vector<impl_item_candidate>
      97                 :             :   assemble_inherent_impl_candidates (const TyTy::BaseType &receiver);
      98                 :             : 
      99                 :             :   void assemble_trait_impl_candidates (
     100                 :             :     const TyTy::BaseType &receiver,
     101                 :             :     std::vector<impl_item_candidate> &impl_candidates,
     102                 :             :     std::vector<trait_item_candidate> &trait_candidates);
     103                 :             : 
     104                 :             :   bool try_select_predicate_candidates (TyTy::BaseType &receiver);
     105                 :             : 
     106                 :             :   bool try_select_inherent_impl_candidates (
     107                 :             :     TyTy::BaseType &receiver,
     108                 :             :     const std::vector<impl_item_candidate> &candidates,
     109                 :             :     bool trait_impl_blocks_only);
     110                 :             : 
     111                 :             :   bool try_select_trait_impl_candidates (
     112                 :             :     TyTy::BaseType &receiver,
     113                 :             :     const std::vector<trait_item_candidate> &candidates);
     114                 :             : 
     115                 :             : private:
     116                 :             :   // search
     117                 :             :   const HIR::PathIdentSegment &segment_name;
     118                 :             :   std::vector<MethodResolver::predicate_candidate> predicate_items;
     119                 :             : 
     120                 :             :   // mutable fields
     121                 :             :   std::set<MethodCandidate> result;
     122                 :             : };
     123                 :             : 
     124                 :             : } // namespace Resolver
     125                 :             : } // namespace Rust
     126                 :             : 
     127                 :             : #endif // RUST_HIR_DOT_OPERATOR
        

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.