From 13a79183b4a565e98e7b2d105f14458bc103ab1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Wed, 7 Aug 2024 21:24:49 +0000 Subject: [PATCH] Ignore auto-deref for multiple crate version note As per the case presented in #128569, we should be showing the extra info even if auto-deref is involved. --- .../rustc_hir_typeck/src/method/suggest.rs | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/compiler/rustc_hir_typeck/src/method/suggest.rs b/compiler/rustc_hir_typeck/src/method/suggest.rs index c85fb574bace..f95f324056af 100644 --- a/compiler/rustc_hir_typeck/src/method/suggest.rs +++ b/compiler/rustc_hir_typeck/src/method/suggest.rs @@ -3491,21 +3491,21 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // self types and rely on the suggestion to `use` the trait from // `suggest_valid_traits`. let did = Some(pick.item.container_id(self.tcx)); - let skip = skippable.contains(&did); - if pick.autoderefs == 0 && !skip { - suggest = self.detect_and_explain_multiple_crate_versions( - err, - pick.item.def_id, + if skippable.contains(&did) { + continue; + } + suggest = self.detect_and_explain_multiple_crate_versions( + err, + pick.item.def_id, + pick.item.ident(self.tcx).span, + rcvr.hir_id.owner, + *rcvr_ty, + ); + if pick.autoderefs == 0 && suggest { + err.span_label( pick.item.ident(self.tcx).span, - rcvr.hir_id.owner, - *rcvr_ty, + format!("the method is available for `{rcvr_ty}` here"), ); - if suggest { - err.span_label( - pick.item.ident(self.tcx).span, - format!("the method is available for `{rcvr_ty}` here"), - ); - } } break; }