diff options
author | Philip Herron <philip.herron@embecosm.com> | 2022-10-05 17:24:26 +0100 |
---|---|---|
committer | Philip Herron <philip.herron@embecosm.com> | 2022-10-06 14:07:16 +0100 |
commit | e033f1705dde104c44d69cec87cb728dba596c6f (patch) | |
tree | 073a1393a65f414b83a4874fed6503f799a174cf /gcc/rust/backend/rust-compile-resolve-path.cc | |
parent | fc746fd620118f91bb8bfc139c7be3fb2356e820 (diff) | |
download | gcc-e033f1705dde104c44d69cec87cb728dba596c6f.zip gcc-e033f1705dde104c44d69cec87cb728dba596c6f.tar.gz gcc-e033f1705dde104c44d69cec87cb728dba596c6f.tar.bz2 |
Ensure uniqueness on Path probe's
When we lookup names in paths such as Foo::bar, foo is a type we resolve
and then we lookup 'bar' based on what type Foo is which includes probing
relevant bounds of this type. We currently return a vector of possible
candidates and this patch changes it so that we return a set of unique
items based on DefId.
Addresses #1555
Diffstat (limited to 'gcc/rust/backend/rust-compile-resolve-path.cc')
-rw-r--r-- | gcc/rust/backend/rust-compile-resolve-path.cc | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/gcc/rust/backend/rust-compile-resolve-path.cc b/gcc/rust/backend/rust-compile-resolve-path.cc index 4fb3d54..f89da2b 100644 --- a/gcc/rust/backend/rust-compile-resolve-path.cc +++ b/gcc/rust/backend/rust-compile-resolve-path.cc @@ -251,7 +251,7 @@ HIRCompileBase::query_compile (HirId ref, TyTy::BaseType *lookup, // item so its up to us to figure out if this path should resolve // to an trait-impl-block-item or if it can be defaulted to the // trait-impl-item's definition - std::vector<Resolver::PathProbeCandidate> candidates + auto candidates = Resolver::PathProbeImplTrait::Probe (receiver, final_segment, trait_ref); if (candidates.size () == 0) @@ -270,7 +270,9 @@ HIRCompileBase::query_compile (HirId ref, TyTy::BaseType *lookup, } else { - Resolver::PathProbeCandidate &candidate = candidates.at (0); + rust_assert (candidates.size () == 1); + + auto candidate = *candidates.begin (); rust_assert (candidate.is_impl_candidate ()); HIR::ImplBlock *impl = candidate.item.impl.parent; @@ -288,8 +290,6 @@ HIRCompileBase::query_compile (HirId ref, TyTy::BaseType *lookup, else return CompileInherentImplItem::Compile (impl_item, ctx, lookup, true, expr_locus); - - lookup->set_ty_ref (impl_item->get_impl_mappings ().get_hirid ()); } } } |