aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/backend/rust-compile-resolve-path.cc
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2022-10-06 13:07:50 +0000
committerGitHub <noreply@github.com>2022-10-06 13:07:50 +0000
commitb4096017e3b9ca499b56988b67e05667a02ca202 (patch)
treecf7011c7659af1416f4a109f81bc264f4686ecef /gcc/rust/backend/rust-compile-resolve-path.cc
parentadaf4561d63f08714f8c289bef0f4c5649fb6829 (diff)
parenta7d2643d9b09af9f5c5c670626becaa0c0fc1481 (diff)
downloadgcc-b4096017e3b9ca499b56988b67e05667a02ca202.zip
gcc-b4096017e3b9ca499b56988b67e05667a02ca202.tar.gz
gcc-b4096017e3b9ca499b56988b67e05667a02ca202.tar.bz2
Merge #1562
1562: Support looking up super trait items during path resolution r=philberty a=philberty 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 vector of unique items based on DefId. Ideally we should use move to a std::set for this. The final patch actually updates the trait reference lookup functions to revert to looking up relevant super traits when required. Fixes #1555 Co-authored-by: Philip Herron <philip.herron@embecosm.com>
Diffstat (limited to 'gcc/rust/backend/rust-compile-resolve-path.cc')
-rw-r--r--gcc/rust/backend/rust-compile-resolve-path.cc8
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 ());
}
}
}