Skip to content

Commit 451e030

Browse files
committed
Improve suggestion wording
1 parent 2411692 commit 451e030

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

compiler/rustc_typeck/src/check/pat.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
666666
match binding_parent {
667667
hir::Node::Param(hir::Param { ty_span, .. }) if binding.span.hi() <= ty_span.lo() => {
668668
err.multipart_suggestion_verbose(
669-
format!("to take parameter by ref, move `&{mutability}` to the type"),
669+
format!("to take parameter `{binding}` by reference, move `&{mutability}` to the type"),
670670
vec![
671671
(pat.span.until(inner.span), "".to_owned()),
672672
(ty_span.shrink_to_lo(), format!("&{}", mutbl.prefix_str())),

src/test/ui/mismatched_types/issue-38371.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ LL | fn foo(&_a: Foo) {}
88
|
99
= note: expected struct `Foo`
1010
found reference `&_`
11-
help: to take parameter by ref, move `&` to the type
11+
help: to take parameter `_a` by reference, move `&` to the type
1212
|
1313
LL - fn foo(&_a: Foo) {}
1414
LL + fn foo(_a: &Foo) {}

src/test/ui/mismatched_types/ref-pat-suggestions.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ LL | fn _f0(&_a: u32) {}
88
|
99
= note: expected type `u32`
1010
found reference `&_`
11-
help: to take parameter by ref, move `&` to the type
11+
help: to take parameter `_a` by reference, move `&` to the type
1212
|
1313
LL - fn _f0(&_a: u32) {}
1414
LL + fn _f0(_a: &u32) {}
@@ -24,7 +24,7 @@ LL | fn _f1(&mut _a: u32) {}
2424
|
2525
= note: expected type `u32`
2626
found mutable reference `&mut _`
27-
help: to take parameter by ref, move `&mut` to the type
27+
help: to take parameter `_a` by reference, move `&mut` to the type
2828
|
2929
LL - fn _f1(&mut _a: u32) {}
3030
LL + fn _f1(_a: &mut u32) {}
@@ -206,7 +206,7 @@ LL | let _ = |&_a: u32| ();
206206
|
207207
= note: expected type `u32`
208208
found reference `&_`
209-
help: to take parameter by ref, move `&` to the type
209+
help: to take parameter `_a` by reference, move `&` to the type
210210
|
211211
LL - let _ = |&_a: u32| ();
212212
LL + let _ = |_a: &u32| ();
@@ -222,7 +222,7 @@ LL | let _ = |&mut _a: u32| ();
222222
|
223223
= note: expected type `u32`
224224
found mutable reference `&mut _`
225-
help: to take parameter by ref, move `&mut` to the type
225+
help: to take parameter `_a` by reference, move `&mut` to the type
226226
|
227227
LL - let _ = |&mut _a: u32| ();
228228
LL + let _ = |_a: &mut u32| ();

0 commit comments

Comments
 (0)