]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: simplify matching possible candidates
authorPhilip Herron <herron.philip@googlemail.com>
Sat, 12 Aug 2023 17:23:06 +0000 (18:23 +0100)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 16 Jan 2024 18:00:30 +0000 (19:00 +0100)
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>
gcc/rust/backend/rust-compile-base.cc

index 91e7d6700d2c741d9aabd4cb26d9549443edbe8e..5a0d9a16efde2901edb6d2c6020bf6c5c6a39595 100644 (file)
@@ -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,