diff --git a/src/librustc_typeck/check/_match.rs b/src/librustc_typeck/check/_match.rs index 88168a6950be..f5aa2e6ea5ce 100644 --- a/src/librustc_typeck/check/_match.rs +++ b/src/librustc_typeck/check/_match.rs @@ -535,19 +535,9 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { err.help(&format!("did you mean `{}: &{}`?", snippet, expected)); } } - hir::Node::Expr(hir::Expr { node: hir::ExprKind::Match(..), .. }) => { - // rely on match ergonomics - if let Ok(snippet) = tcx.sess.source_map().span_to_snippet(inner.span) { - err.span_suggestion( - pat.span, - "you can rely on match ergonomics and remove the explicit borrow", - snippet, - Applicability::MaybeIncorrect, - ); - } - } + hir::Node::Expr(hir::Expr { node: hir::ExprKind::Match(..), .. }) | hir::Node::Pat(_) => { - // nested `&&pat` + // rely on match ergonomics or it might be nested `&&pat` if let Ok(snippet) = tcx.sess.source_map().span_to_snippet(inner.span) { err.span_suggestion( pat.span, diff --git a/src/test/ui/suggestions/match-ergonomics.stderr b/src/test/ui/suggestions/match-ergonomics.stderr index 9915eeb34fac..b7497be6ceb3 100644 --- a/src/test/ui/suggestions/match-ergonomics.stderr +++ b/src/test/ui/suggestions/match-ergonomics.stderr @@ -26,14 +26,13 @@ error[E0308]: mismatched types --> $DIR/match-ergonomics.rs:29:9 | LL | &v => {}, - | ^^ expected i32, found reference + | ^^ + | | + | expected i32, found reference + | help: you can probably remove the explicit borrow: `v` | = note: expected type `i32` found type `&_` -help: you can rely on match ergonomics and remove the explicit borrow - | -LL | v => {}, - | ^ error[E0308]: mismatched types --> $DIR/match-ergonomics.rs:40:13