Skip to content

Commit

Permalink
Improve suggestion wording
Browse files Browse the repository at this point in the history
  • Loading branch information
WaffleLapkin committed Jun 13, 2022
1 parent 2411692 commit 451e030
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_typeck/src/check/pat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())),
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/mismatched_types/issue-38371.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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) {}
Expand Down
8 changes: 4 additions & 4 deletions src/test/ui/mismatched_types/ref-pat-suggestions.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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) {}
Expand All @@ -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) {}
Expand Down Expand Up @@ -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| ();
Expand All @@ -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| ();
Expand Down

0 comments on commit 451e030

Please sign in to comment.