Improve suggestion wording

This commit is contained in:
Maybe Waffle 2022-06-13 13:31:47 +04:00
parent 2411692ab6
commit 451e0301d8
3 changed files with 6 additions and 6 deletions

View file

@ -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())),

View file

@ -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) {}

View file

@ -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| ();