From: Philip Herron Date: Sat, 12 Aug 2023 17:23:06 +0000 (+0100) Subject: gccrs: simplify matching possible candidates X-Git-Tag: basepoints/gcc-15~2221 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4459962a83ff5c5b6f3d9f76cb8b6c7a71d300c0;p=thirdparty%2Fgcc.git 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 --- diff --git a/gcc/rust/backend/rust-compile-base.cc b/gcc/rust/backend/rust-compile-base.cc index 91e7d6700d2c..5a0d9a16efde 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,