[gcc r14-7918] gccrs: simplify matching possible candidates

Arthur Cohen cohenarthur@gcc.gnu.org
Tue Jan 16 18:07:15 GMT 2024


https://gcc.gnu.org/g:4459962a83ff5c5b6f3d9f76cb8b6c7a71d300c0

commit r14-7918-g4459962a83ff5c5b6f3d9f76cb8b6c7a71d300c0
Author: Philip Herron <herron.philip@googlemail.com>
Date:   Sat Aug 12 18:23:06 2023 +0100

    gccrs: simplify matching possible candidates
    
    We do extra checking after the fact here to ensure its a valid candidate
    and in the case there is only one candidate lets just go for it.
    
    Addresses #1895
    
    gcc/rust/ChangeLog:
    
            * backend/rust-compile-base.cc (HIRCompileBase::resolve_method_address):
            use the single candidate
    
    Signed-off-by: Philip Herron <herron.philip@googlemail.com>

Diff:
---
 gcc/rust/backend/rust-compile-base.cc | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/gcc/rust/backend/rust-compile-base.cc b/gcc/rust/backend/rust-compile-base.cc
index 91e7d6700d2..5a0d9a16efd 100644
--- a/gcc/rust/backend/rust-compile-base.cc
+++ b/gcc/rust/backend/rust-compile-base.cc
@@ -843,6 +843,12 @@ HIRCompileBase::resolve_method_address (TyTy::FnType *fntype,
   // look for the exact fntype
   for (auto &candidate : filteredFunctionCandidates)
     {
+      if (filteredFunctionCandidates.size () == 1)
+	{
+	  selectedCandidate = &candidate;
+	  break;
+	}
+
       bool compatable
 	= Resolver::types_compatable (TyTy::TyWithLocation (candidate.ty),
 				      TyTy::TyWithLocation (fntype), expr_locus,


More information about the Gcc-cvs mailing list