From: Philip Herron <[email protected]>
gcc/rust/ChangeLog:
* typecheck/rust-hir-path-probe.cc (PathProbeType::Probe): filter
Signed-off-by: Philip Herron <[email protected]>
---
This change was merged into the gccrs repository and is posted here for
upstream visibility and potential drive-by review, as requested by GCC
release managers.
Each commit email contains a link to its details on github from where you can
find the Pull-Request and associated discussions.
Commit on github:
https://github.com/Rust-GCC/gccrs/commit/26d050d9f27ed8436c08fcb70d3a688c73c1294c
The commit has NOT been mentioned in any issue.
The commit has been mentioned in the following pull-request(s):
- https://github.com/Rust-GCC/gccrs/pull/4816
gcc/rust/typecheck/rust-hir-path-probe.cc | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/gcc/rust/typecheck/rust-hir-path-probe.cc
b/gcc/rust/typecheck/rust-hir-path-probe.cc
index d8ff6ff62..4245e8a38 100644
--- a/gcc/rust/typecheck/rust-hir-path-probe.cc
+++ b/gcc/rust/typecheck/rust-hir-path-probe.cc
@@ -17,6 +17,7 @@
// <http://www.gnu.org/licenses/>.
#include "rust-hir-path-probe.h"
+#include "rust-hir-item.h"
#include "rust-hir-trait-resolve.h"
#include "rust-type-util.h"
#include "rust-hir-type-bounds.h"
@@ -151,6 +152,8 @@ PathProbeType::Probe (TyTy::BaseType *receiver,
bool ignore_mandatory_trait_items,
DefId specific_trait_id)
{
+ Analysis::Mappings &mappings = Analysis::Mappings::get ();
+
PathProbeType probe (receiver, segment_name, specific_trait_id);
if (probe_impls)
{
@@ -170,8 +173,20 @@ PathProbeType::Probe (TyTy::BaseType *receiver,
if (!probe.is_receiver_generic ())
{
- std::vector<std::pair<TraitReference *, HIR::ImplBlock *>> probed_bounds
- = TypeBoundsProbe::Probe (receiver);
+ HIR::Trait *associated_trait = nullptr;
+ if (specific_trait_id != UNKNOWN_DEFID)
+ {
+ auto item_lookup = mappings.lookup_defid (specific_trait_id);
+ if (item_lookup.has_value ())
+ {
+ HIR::Item *item = item_lookup.value ();
+ rust_assert (item->get_item_kind ()
+ == HIR::Item::ItemKind::Trait);
+ associated_trait = static_cast<HIR::Trait *> (item);
+ }
+ }
+
+ auto probed_bounds = TypeBoundsProbe::Probe (receiver, associated_trait);
for (auto &candidate : probed_bounds)
{
const TraitReference *trait_ref = candidate.first;
--
2.55.0