diff --git a/compiler/rustc_typeck/src/check/pat.rs b/compiler/rustc_typeck/src/check/pat.rs index 836cdb4206a6..5ecdbdadefd0 100644 --- a/compiler/rustc_typeck/src/check/pat.rs +++ b/compiler/rustc_typeck/src/check/pat.rs @@ -666,7 +666,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { match binding_parent { hir::Node::Param(hir::Param { ty_span, .. }) if binding.span.hi() <= ty_span.lo() => { err.multipart_suggestion_verbose( - format!("to take parameter by ref, move `&{mutability}` to the type"), + format!("to take parameter `{binding}` by reference, move `&{mutability}` to the type"), vec![ (pat.span.until(inner.span), "".to_owned()), (ty_span.shrink_to_lo(), format!("&{}", mutbl.prefix_str())), diff --git a/src/test/ui/mismatched_types/issue-38371.stderr b/src/test/ui/mismatched_types/issue-38371.stderr index 5a0146dfd210..003f17cda155 100644 --- a/src/test/ui/mismatched_types/issue-38371.stderr +++ b/src/test/ui/mismatched_types/issue-38371.stderr @@ -8,7 +8,7 @@ LL | fn foo(&_a: Foo) {} | = note: expected struct `Foo` found reference `&_` -help: to take parameter by ref, move `&` to the type +help: to take parameter `_a` by reference, move `&` to the type | LL - fn foo(&_a: Foo) {} LL + fn foo(_a: &Foo) {} diff --git a/src/test/ui/mismatched_types/ref-pat-suggestions.stderr b/src/test/ui/mismatched_types/ref-pat-suggestions.stderr index 6ce1f9602ddb..0516bad49abf 100644 --- a/src/test/ui/mismatched_types/ref-pat-suggestions.stderr +++ b/src/test/ui/mismatched_types/ref-pat-suggestions.stderr @@ -8,7 +8,7 @@ LL | fn _f0(&_a: u32) {} | = note: expected type `u32` found reference `&_` -help: to take parameter by ref, move `&` to the type +help: to take parameter `_a` by reference, move `&` to the type | LL - fn _f0(&_a: u32) {} LL + fn _f0(_a: &u32) {} @@ -24,7 +24,7 @@ LL | fn _f1(&mut _a: u32) {} | = note: expected type `u32` found mutable reference `&mut _` -help: to take parameter by ref, move `&mut` to the type +help: to take parameter `_a` by reference, move `&mut` to the type | LL - fn _f1(&mut _a: u32) {} LL + fn _f1(_a: &mut u32) {} @@ -206,7 +206,7 @@ LL | let _ = |&_a: u32| (); | = note: expected type `u32` found reference `&_` -help: to take parameter by ref, move `&` to the type +help: to take parameter `_a` by reference, move `&` to the type | LL - let _ = |&_a: u32| (); LL + let _ = |_a: &u32| (); @@ -222,7 +222,7 @@ LL | let _ = |&mut _a: u32| (); | = note: expected type `u32` found mutable reference `&mut _` -help: to take parameter by ref, move `&mut` to the type +help: to take parameter `_a` by reference, move `&mut` to the type | LL - let _ = |&mut _a: u32| (); LL + let _ = |_a: &mut u32| ();