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: 81.1 % 53 43
Test Date: 2026-10-03 16:17:38 Functions: 86.7 % 15 13
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-path-probe.h"
      20              : #include "rust-hir-item.h"
      21              : #include "rust-hir-trait-resolve.h"
      22              : #include "rust-type-util.h"
      23              : #include "rust-hir-type-bounds.h"
      24              : #include "rust-hir-full.h"
      25              : 
      26              : namespace Rust {
      27              : namespace Resolver {
      28              : 
      29              : // PathProbeCandidate
      30              : 
      31            1 : PathProbeCandidate::Candidate::Candidate (EnumItemCandidate enum_field)
      32            1 :   : enum_field (enum_field)
      33            1 : {}
      34              : 
      35         7473 : PathProbeCandidate::Candidate::Candidate (ImplItemCandidate impl) : impl (impl)
      36         7473 : {}
      37              : 
      38         2332 : PathProbeCandidate::Candidate::Candidate (TraitItemCandidate trait)
      39         2332 :   : trait (trait)
      40         2332 : {}
      41              : 
      42            1 : PathProbeCandidate::PathProbeCandidate (CandidateType type, TyTy::BaseType *ty,
      43              :                                         location_t locus,
      44              :                                         EnumItemCandidate enum_field)
      45            1 :   : type (type), ty (ty), locus (locus), item (enum_field)
      46            1 : {}
      47              : 
      48         7473 : PathProbeCandidate::PathProbeCandidate (CandidateType type, TyTy::BaseType *ty,
      49              :                                         location_t locus,
      50              :                                         ImplItemCandidate impl)
      51         7473 :   : type (type), ty (ty), locus (locus), item (impl)
      52         7473 : {}
      53              : 
      54         2332 : PathProbeCandidate::PathProbeCandidate (CandidateType type, TyTy::BaseType *ty,
      55              :                                         location_t locus,
      56              :                                         TraitItemCandidate trait)
      57         2332 :   : type (type), ty (ty), locus (locus), item (trait)
      58         2332 : {}
      59              : 
      60              : std::string
      61            0 : PathProbeCandidate::as_string () const
      62              : {
      63            0 :   return "PathProbe candidate TODO - as_string";
      64              : }
      65              : 
      66              : bool
      67         1552 : PathProbeCandidate::is_enum_candidate () const
      68              : {
      69         1552 :   return type == ENUM_VARIANT;
      70              : }
      71              : 
      72              : bool
      73        10479 : PathProbeCandidate::is_impl_candidate () const
      74              : {
      75        10479 :   return type == IMPL_CONST || type == IMPL_TYPE_ALIAS || type == IMPL_FUNC;
      76              : }
      77              : 
      78              : bool
      79           24 : PathProbeCandidate::is_trait_candidate () const
      80              : {
      81           24 :   return type == TRAIT_ITEM_CONST || type == TRAIT_TYPE_ALIAS
      82           24 :          || type == TRAIT_FUNC;
      83              : }
      84              : 
      85              : bool
      86            0 : PathProbeCandidate::is_full_trait_item_candidate () const
      87              : {
      88            0 :   return is_trait_candidate () && item.trait.impl == nullptr;
      89              : }
      90              : 
      91              : PathProbeCandidate
      92          173 : PathProbeCandidate::get_error ()
      93              : {
      94          173 :   return PathProbeCandidate (ERROR, nullptr, UNDEF_LOCATION,
      95          173 :                              ImplItemCandidate{nullptr, nullptr});
      96              : }
      97              : 
      98              : bool
      99         1970 : PathProbeCandidate::is_error () const
     100              : {
     101         1970 :   return type == ERROR;
     102              : }
     103              : 
     104              : DefId
     105         9910 : PathProbeCandidate::get_defid () const
     106              : {
     107         9910 :   switch (type)
     108              :     {
     109            0 :     case ENUM_VARIANT:
     110            0 :       return item.enum_field.variant->get_defid ();
     111         9490 :       break;
     112              : 
     113         9490 :     case IMPL_CONST:
     114         9490 :     case IMPL_TYPE_ALIAS:
     115         9490 :     case IMPL_FUNC:
     116         9490 :       return item.impl.impl_item->get_impl_mappings ().get_defid ();
     117          420 :       break;
     118              : 
     119          420 :     case TRAIT_ITEM_CONST:
     120          420 :     case TRAIT_TYPE_ALIAS:
     121          420 :     case TRAIT_FUNC:
     122          420 :       return item.trait.item_ref->get_mappings ().get_defid ();
     123            0 :       break;
     124              : 
     125            0 :     case ERROR:
     126            0 :     default:
     127            0 :       return UNKNOWN_DEFID;
     128              :     }
     129              : 
     130              :   return UNKNOWN_DEFID;
     131              : }
     132              : 
     133              : bool
     134          271 : PathProbeCandidate::operator< (const PathProbeCandidate &c) const
     135              : {
     136          271 :   return get_defid () < c.get_defid ();
     137              : }
     138              : 
     139              : } // namespace Resolver
     140              : } // 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.