Skip to content

Commit 8e9a366

Browse files
committed
Use verbose style for argument removal suggestion
1 parent c422581 commit 8e9a366

17 files changed

+264
-180
lines changed

compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1384,7 +1384,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
13841384
Some(format!("provide the argument{}", if plural { "s" } else { "" }))
13851385
}
13861386
SuggestionText::Remove(plural) => {
1387-
err.multipart_suggestion(
1387+
err.multipart_suggestion_verbose(
13881388
format!("remove the extra argument{}", if plural { "s" } else { "" }),
13891389
suggestions,
13901390
Applicability::HasPlaceholders,

tests/ui/argument-suggestions/basic.stderr

+6-4
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,18 @@ error[E0061]: this function takes 0 arguments but 1 argument was supplied
1616
--> $DIR/basic.rs:21:5
1717
|
1818
LL | extra("");
19-
| ^^^^^ --
20-
| |
21-
| unexpected argument of type `&'static str`
22-
| help: remove the extra argument
19+
| ^^^^^ -- unexpected argument of type `&'static str`
2320
|
2421
note: function defined here
2522
--> $DIR/basic.rs:14:4
2623
|
2724
LL | fn extra() {}
2825
| ^^^^^
26+
help: remove the extra argument
27+
|
28+
LL - extra("");
29+
LL + extra();
30+
|
2931

3032
error[E0061]: this function takes 1 argument but 0 arguments were supplied
3133
--> $DIR/basic.rs:22:5

tests/ui/argument-suggestions/exotic-calls.stderr

+24-16
Original file line numberDiff line numberDiff line change
@@ -2,61 +2,69 @@ error[E0057]: this function takes 0 arguments but 1 argument was supplied
22
--> $DIR/exotic-calls.rs:2:5
33
|
44
LL | t(1i32);
5-
| ^ ----
6-
| |
7-
| unexpected argument of type `i32`
8-
| help: remove the extra argument
5+
| ^ ---- unexpected argument of type `i32`
96
|
107
note: callable defined here
118
--> $DIR/exotic-calls.rs:1:11
129
|
1310
LL | fn foo<T: Fn()>(t: T) {
1411
| ^^^^
12+
help: remove the extra argument
13+
|
14+
LL - t(1i32);
15+
LL + t();
16+
|
1517

1618
error[E0057]: this function takes 0 arguments but 1 argument was supplied
1719
--> $DIR/exotic-calls.rs:7:5
1820
|
1921
LL | t(1i32);
20-
| ^ ----
21-
| |
22-
| unexpected argument of type `i32`
23-
| help: remove the extra argument
22+
| ^ ---- unexpected argument of type `i32`
2423
|
2524
note: type parameter defined here
2625
--> $DIR/exotic-calls.rs:6:11
2726
|
2827
LL | fn bar(t: impl Fn()) {
2928
| ^^^^^^^^^
29+
help: remove the extra argument
30+
|
31+
LL - t(1i32);
32+
LL + t();
33+
|
3034

3135
error[E0057]: this function takes 0 arguments but 1 argument was supplied
3236
--> $DIR/exotic-calls.rs:16:5
3337
|
3438
LL | baz()(1i32)
35-
| ^^^^^ ----
36-
| |
37-
| unexpected argument of type `i32`
38-
| help: remove the extra argument
39+
| ^^^^^ ---- unexpected argument of type `i32`
3940
|
4041
note: opaque type defined here
4142
--> $DIR/exotic-calls.rs:11:13
4243
|
4344
LL | fn baz() -> impl Fn() {
4445
| ^^^^^^^^^
46+
help: remove the extra argument
47+
|
48+
LL - baz()(1i32)
49+
LL + baz()()
50+
|
4551

4652
error[E0057]: this function takes 0 arguments but 1 argument was supplied
4753
--> $DIR/exotic-calls.rs:22:5
4854
|
4955
LL | x(1i32);
50-
| ^ ----
51-
| |
52-
| unexpected argument of type `i32`
53-
| help: remove the extra argument
56+
| ^ ---- unexpected argument of type `i32`
5457
|
5558
note: closure defined here
5659
--> $DIR/exotic-calls.rs:21:13
5760
|
5861
LL | let x = || {};
5962
| ^^
63+
help: remove the extra argument
64+
|
65+
LL - x(1i32);
66+
LL + x();
67+
|
6068

6169
error: aborting due to 4 previous errors
6270

0 commit comments

Comments
 (0)