about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection/src
diff options
context:
space:
mode:
authorMatthias Krüger <476013+matthiaskrgr@users.noreply.github.com>2025-04-25 07:50:27 +0200
committerGitHub <noreply@github.com>2025-04-25 07:50:27 +0200
commit3c08a50a15e414d1fb80810b35b050aaf97e9b1c (patch)
treefc124bc62e181a2053f3e7bbecd92862f4c5ab7b /compiler/rustc_trait_selection/src
parente534fad2e57c6f50931da937b9bbca07574e8eee (diff)
parent1d0b3be659fe7128f4a66f593729e9c0627ed90a (diff)
downloadrust-3c08a50a15e414d1fb80810b35b050aaf97e9b1c.tar.gz
rust-3c08a50a15e414d1fb80810b35b050aaf97e9b1c.zip
Rollup merge of #140278 - compiler-errors:name-based-comparison, r=nnethercote
Don't use item name to look up associated item from trait item

This fix should be self-justifying b/c the fact that we were using identifiers here was kinda sus anyways, esp b/c we have a failproof way of doing the comparison :) I'll leave some info about why this repro needs a macro.

Fixes https://github.com/rust-lang/rust/issues/140259

r? `@nnethercote`
Diffstat (limited to 'compiler/rustc_trait_selection/src')
-rw-r--r--compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs12
1 files changed, 5 insertions, 7 deletions
diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs
index df6e8fc4503..4330f1f2292 100644
--- a/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs
+++ b/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs
@@ -1523,19 +1523,17 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
                     return None;
                 };
 
-                let trait_assoc_item = self.tcx.opt_associated_item(proj.projection_term.def_id)?;
-                let trait_assoc_ident = trait_assoc_item.ident(self.tcx);
-
                 let mut associated_items = vec![];
                 self.tcx.for_each_relevant_impl(
                     self.tcx.trait_of_item(proj.projection_term.def_id)?,
                     proj.projection_term.self_ty(),
                     |impl_def_id| {
                         associated_items.extend(
-                            self.tcx
-                                .associated_items(impl_def_id)
-                                .in_definition_order()
-                                .find(|assoc| assoc.ident(self.tcx) == trait_assoc_ident),
+                            self.tcx.associated_items(impl_def_id).in_definition_order().find(
+                                |assoc| {
+                                    assoc.trait_item_def_id == Some(proj.projection_term.def_id)
+                                },
+                            ),
                         );
                     },
                 );