From d1ab6c2ae3fa0726d5f8b5a92b66faa09c72b893 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Sat, 10 Jun 2023 22:51:00 +0000 Subject: [PATCH] Do not suggest adjusting trait signature on type mismatch --- .../src/traits/error_reporting/suggestions.rs | 4 ++++ tests/ui/typeck/mismatched-map-under-self.stderr | 5 ----- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs index 7efef2364a6..73a45322c4f 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs @@ -3959,6 +3959,10 @@ fn hint_missing_borrow<'tcx>( found_node: Node<'_>, err: &mut Diagnostic, ) { + if matches!(found_node, Node::TraitItem(..)) { + return; + } + let found_args = match found.kind() { ty::FnPtr(f) => infcx.instantiate_binder_with_placeholders(*f).inputs().iter(), kind => { diff --git a/tests/ui/typeck/mismatched-map-under-self.stderr b/tests/ui/typeck/mismatched-map-under-self.stderr index 65ef5456268..51491407c49 100644 --- a/tests/ui/typeck/mismatched-map-under-self.stderr +++ b/tests/ui/typeck/mismatched-map-under-self.stderr @@ -30,11 +30,6 @@ LL | self.map(Insertable::values).unwrap_or_default() found function signature `for<'a> fn(&'a _) -> _` note: required by a bound in `Option::::map` --> $SRC_DIR/core/src/option.rs:LL:COL -help: consider adjusting the signature so it does not borrow its argument - | -LL - fn values(&self) -> Self::Values; -LL + fn values(self) -> Self::Values; - | error: aborting due to 2 previous errors