Skip to content

Commit 7822822

Browse files
committed
change error message
1 parent b1d7430 commit 7822822

File tree

5 files changed

+26
-22
lines changed

5 files changed

+26
-22
lines changed

compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3449,11 +3449,11 @@ fn hint_missing_borrow<'tcx>(
34493449

34503450
if found_ty == expected_ty {
34513451
let hint = if found_refs < expected_refs {
3452-
"consider borrowing here:"
3452+
"consider borrowing the argument"
34533453
} else if found_refs == expected_refs {
34543454
continue;
34553455
} else {
3456-
"consider removing the borrow:"
3456+
"do not borrow the argument"
34573457
};
34583458
err.span_suggestion_verbose(
34593459
arg_span,

src/test/ui/anonymous-higher-ranked-lifetime.stderr

+18-18
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ note: required by a bound in `f1`
1313
|
1414
LL | fn f1<F>(_: F) where F: Fn(&(), &()) {}
1515
| ^^^^^^^^^^^^ required by this bound in `f1`
16-
help: consider borrowing here:
16+
help: consider borrowing the argument
1717
|
1818
LL | f1(|_: &(), _: ()| {});
1919
| ~~~
20-
help: consider borrowing here:
20+
help: consider borrowing the argument
2121
|
2222
LL | f1(|_: (), _: &()| {});
2323
| ~~~
@@ -37,11 +37,11 @@ note: required by a bound in `f2`
3737
|
3838
LL | fn f2<F>(_: F) where F: for<'a> Fn(&'a (), &()) {}
3939
| ^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `f2`
40-
help: consider borrowing here:
40+
help: consider borrowing the argument
4141
|
4242
LL | f2(|_: &'a (), _: ()| {});
4343
| ~~~~~~
44-
help: consider borrowing here:
44+
help: consider borrowing the argument
4545
|
4646
LL | f2(|_: (), _: &()| {});
4747
| ~~~
@@ -61,11 +61,11 @@ note: required by a bound in `f3`
6161
|
6262
LL | fn f3<'a, F>(_: F) where F: Fn(&'a (), &()) {}
6363
| ^^^^^^^^^^^^^^^ required by this bound in `f3`
64-
help: consider borrowing here:
64+
help: consider borrowing the argument
6565
|
6666
LL | f3(|_: &(), _: ()| {});
6767
| ~~~
68-
help: consider borrowing here:
68+
help: consider borrowing the argument
6969
|
7070
LL | f3(|_: (), _: &()| {});
7171
| ~~~
@@ -85,11 +85,11 @@ note: required by a bound in `f4`
8585
|
8686
LL | fn f4<F>(_: F) where F: for<'r> Fn(&(), &'r ()) {}
8787
| ^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `f4`
88-
help: consider borrowing here:
88+
help: consider borrowing the argument
8989
|
9090
LL | f4(|_: &(), _: ()| {});
9191
| ~~~
92-
help: consider borrowing here:
92+
help: consider borrowing the argument
9393
|
9494
LL | f4(|_: (), _: &'r ()| {});
9595
| ~~~~~~
@@ -109,11 +109,11 @@ note: required by a bound in `f5`
109109
|
110110
LL | fn f5<F>(_: F) where F: for<'r> Fn(&'r (), &'r ()) {}
111111
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `f5`
112-
help: consider borrowing here:
112+
help: consider borrowing the argument
113113
|
114114
LL | f5(|_: &'r (), _: ()| {});
115115
| ~~~~~~
116-
help: consider borrowing here:
116+
help: consider borrowing the argument
117117
|
118118
LL | f5(|_: (), _: &'r ()| {});
119119
| ~~~~~~
@@ -133,7 +133,7 @@ note: required by a bound in `g1`
133133
|
134134
LL | fn g1<F>(_: F) where F: Fn(&(), Box<dyn Fn(&())>) {}
135135
| ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `g1`
136-
help: consider borrowing here:
136+
help: consider borrowing the argument
137137
|
138138
LL | g1(|_: &(), _: ()| {});
139139
| ~~~
@@ -153,7 +153,7 @@ note: required by a bound in `g2`
153153
|
154154
LL | fn g2<F>(_: F) where F: Fn(&(), fn(&())) {}
155155
| ^^^^^^^^^^^^^^^^ required by this bound in `g2`
156-
help: consider borrowing here:
156+
help: consider borrowing the argument
157157
|
158158
LL | g2(|_: &(), _: ()| {});
159159
| ~~~
@@ -173,7 +173,7 @@ note: required by a bound in `g3`
173173
|
174174
LL | fn g3<F>(_: F) where F: for<'s> Fn(&'s (), Box<dyn Fn(&())>) {}
175175
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `g3`
176-
help: consider borrowing here:
176+
help: consider borrowing the argument
177177
|
178178
LL | g3(|_: &'s (), _: ()| {});
179179
| ~~~~~~
@@ -193,7 +193,7 @@ note: required by a bound in `g4`
193193
|
194194
LL | fn g4<F>(_: F) where F: Fn(&(), for<'r> fn(&'r ())) {}
195195
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `g4`
196-
help: consider borrowing here:
196+
help: consider borrowing the argument
197197
|
198198
LL | g4(|_: &(), _: ()| {});
199199
| ~~~
@@ -213,11 +213,11 @@ note: required by a bound in `h1`
213213
|
214214
LL | fn h1<F>(_: F) where F: Fn(&(), Box<dyn Fn(&())>, &(), fn(&(), &())) {}
215215
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `h1`
216-
help: consider borrowing here:
216+
help: consider borrowing the argument
217217
|
218218
LL | h1(|_: &(), _: (), _: (), _: ()| {});
219219
| ~~~
220-
help: consider borrowing here:
220+
help: consider borrowing the argument
221221
|
222222
LL | h1(|_: (), _: (), _: &(), _: ()| {});
223223
| ~~~
@@ -237,11 +237,11 @@ note: required by a bound in `h2`
237237
|
238238
LL | fn h2<F>(_: F) where F: for<'t0> Fn(&(), Box<dyn Fn(&())>, &'t0 (), fn(&(), &())) {}
239239
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `h2`
240-
help: consider borrowing here:
240+
help: consider borrowing the argument
241241
|
242242
LL | h2(|_: &(), _: (), _: (), _: ()| {});
243243
| ~~~
244-
help: consider borrowing here:
244+
help: consider borrowing the argument
245245
|
246246
LL | h2(|_: (), _: (), _: &'t0 (), _: ()| {});
247247
| ~~~~~~~

src/test/ui/closures/multiple-fn-bounds.stderr

+4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ note: required by a bound in `foo`
1818
|
1919
LL | fn foo<F: Fn(&char) -> bool + Fn(char) -> bool>(f: F) {
2020
| ^^^^^^^^^^^^^^^^ required by this bound in `foo`
21+
help: do not borrow the argument
22+
|
23+
LL | foo(move |char| v);
24+
| ~~~~
2125

2226
error: aborting due to previous error
2327

src/test/ui/mismatched_types/closure-arg-type-mismatch.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ note: required by a bound in `map`
1313
|
1414
LL | F: FnMut(Self::Item) -> B,
1515
| ^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Iterator::map`
16-
help: consider borrowing here:
16+
help: consider borrowing the argument
1717
|
1818
LL | a.iter().map(|_: &(u32, u32)| 45);
1919
| ~~~~~~~~~~~

src/test/ui/mismatched_types/issue-36053-2.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ note: required by a bound in `filter`
1313
|
1414
LL | P: FnMut(&Self::Item) -> bool,
1515
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Iterator::filter`
16-
help: consider borrowing here:
16+
help: consider borrowing the argument
1717
|
1818
LL | once::<&str>("str").fuse().filter(|a: &&str| true).count();
1919
| ~~~~~

0 commit comments

Comments
 (0)