Skip to content

Commit bd176ee

Browse files
committed
Make removal suggestion not verbose
1 parent 5d63e10 commit bd176ee

16 files changed

+136
-196
lines changed

compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1167,7 +1167,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
11671167
Some(format!("provide the argument{}", if plural { "s" } else { "" }))
11681168
}
11691169
SuggestionText::Remove(plural) => {
1170-
err.multipart_suggestion_verbose(
1170+
err.multipart_suggestion(
11711171
&format!("remove the extra argument{}", if plural { "s" } else { "" }),
11721172
suggestions,
11731173
Applicability::HasPlaceholders,

tests/ui/alloc-error/alloc-error-handler-bad-signature-3.stderr

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,17 @@ LL | fn oom() -> ! {
77
| _-^^^^^^^^^^^^
88
LL | | loop {}
99
LL | | }
10-
| |_- unexpected argument of type `core::alloc::Layout`
10+
| | -
11+
| | |
12+
| |_unexpected argument of type `core::alloc::Layout`
13+
| help: remove the extra argument
1114
|
1215
note: function defined here
1316
--> $DIR/alloc-error-handler-bad-signature-3.rs:10:4
1417
|
1518
LL | fn oom() -> ! {
1619
| ^^^
1720
= note: this error originates in the attribute macro `alloc_error_handler` (in Nightly builds, run with -Z macro-backtrace for more info)
18-
help: remove the extra argument
19-
|
20-
LL - fn oom() -> ! {
21-
LL - loop {}
22-
LL - }
23-
|
2421

2522
error: aborting due to previous error
2623

tests/ui/argument-suggestions/basic.stderr

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

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

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

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,69 +2,61 @@ 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-
| ^ ---- unexpected argument of type `i32`
5+
| ^ ----
6+
| |
7+
| unexpected argument of type `i32`
8+
| help: remove the extra argument
69
|
710
note: callable defined here
811
--> $DIR/exotic-calls.rs:1:11
912
|
1013
LL | fn foo<T: Fn()>(t: T) {
1114
| ^^^^
12-
help: remove the extra argument
13-
|
14-
LL - t(1i32);
15-
LL + t();
16-
|
1715

1816
error[E0057]: this function takes 0 arguments but 1 argument was supplied
1917
--> $DIR/exotic-calls.rs:7:5
2018
|
2119
LL | t(1i32);
22-
| ^ ---- unexpected argument of type `i32`
20+
| ^ ----
21+
| |
22+
| unexpected argument of type `i32`
23+
| help: remove the extra argument
2324
|
2425
note: type parameter defined here
2526
--> $DIR/exotic-calls.rs:6:11
2627
|
2728
LL | fn bar(t: impl Fn()) {
2829
| ^^^^^^^^^
29-
help: remove the extra argument
30-
|
31-
LL - t(1i32);
32-
LL + t();
33-
|
3430

3531
error[E0057]: this function takes 0 arguments but 1 argument was supplied
3632
--> $DIR/exotic-calls.rs:16:5
3733
|
3834
LL | baz()(1i32)
39-
| ^^^^^ ---- unexpected argument of type `i32`
35+
| ^^^^^ ----
36+
| |
37+
| unexpected argument of type `i32`
38+
| help: remove the extra argument
4039
|
4140
note: opaque type defined here
4241
--> $DIR/exotic-calls.rs:11:13
4342
|
4443
LL | fn baz() -> impl Fn() {
4544
| ^^^^^^^^^
46-
help: remove the extra argument
47-
|
48-
LL - baz()(1i32)
49-
LL + baz()()
50-
|
5145

5246
error[E0057]: this function takes 0 arguments but 1 argument was supplied
5347
--> $DIR/exotic-calls.rs:22:5
5448
|
5549
LL | x(1i32);
56-
| ^ ---- unexpected argument of type `i32`
50+
| ^ ----
51+
| |
52+
| unexpected argument of type `i32`
53+
| help: remove the extra argument
5754
|
5855
note: closure defined here
5956
--> $DIR/exotic-calls.rs:21:13
6057
|
6158
LL | let x = || {};
6259
| ^^
63-
help: remove the extra argument
64-
|
65-
LL - x(1i32);
66-
LL + x();
67-
|
6860

6961
error: aborting due to 4 previous errors
7062

tests/ui/argument-suggestions/extra_arguments.stderr

Lines changed: 55 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -2,52 +2,46 @@ error[E0061]: this function takes 0 arguments but 1 argument was supplied
22
--> $DIR/extra_arguments.rs:7:3
33
|
44
LL | empty("");
5-
| ^^^^^ -- unexpected argument of type `&'static str`
5+
| ^^^^^ --
6+
| |
7+
| unexpected argument of type `&'static str`
8+
| help: remove the extra argument
69
|
710
note: function defined here
811
--> $DIR/extra_arguments.rs:1:4
912
|
1013
LL | fn empty() {}
1114
| ^^^^^
12-
help: remove the extra argument
13-
|
14-
LL - empty("");
15-
LL + empty();
16-
|
1715

1816
error[E0061]: this function takes 1 argument but 2 arguments were supplied
1917
--> $DIR/extra_arguments.rs:9:3
2018
|
2119
LL | one_arg(1, 1);
22-
| ^^^^^^^ - unexpected argument of type `{integer}`
20+
| ^^^^^^^ ---
21+
| | |
22+
| | unexpected argument of type `{integer}`
23+
| help: remove the extra argument
2324
|
2425
note: function defined here
2526
--> $DIR/extra_arguments.rs:2:4
2627
|
2728
LL | fn one_arg(_a: i32) {}
2829
| ^^^^^^^ -------
29-
help: remove the extra argument
30-
|
31-
LL - one_arg(1, 1);
32-
LL + one_arg(1);
33-
|
3430

3531
error[E0061]: this function takes 1 argument but 2 arguments were supplied
3632
--> $DIR/extra_arguments.rs:10:3
3733
|
3834
LL | one_arg(1, "");
39-
| ^^^^^^^ -- unexpected argument of type `&'static str`
35+
| ^^^^^^^ ----
36+
| | |
37+
| | unexpected argument of type `&'static str`
38+
| help: remove the extra argument
4039
|
4140
note: function defined here
4241
--> $DIR/extra_arguments.rs:2:4
4342
|
4443
LL | fn one_arg(_a: i32) {}
4544
| ^^^^^^^ -------
46-
help: remove the extra argument
47-
|
48-
LL - one_arg(1, "");
49-
LL + one_arg(1);
50-
|
5145

5246
error[E0061]: this function takes 1 argument but 3 arguments were supplied
5347
--> $DIR/extra_arguments.rs:11:3
@@ -72,69 +66,61 @@ error[E0061]: this function takes 2 arguments but 3 arguments were supplied
7266
--> $DIR/extra_arguments.rs:13:3
7367
|
7468
LL | two_arg_same(1, 1, 1);
75-
| ^^^^^^^^^^^^ - unexpected argument of type `{integer}`
69+
| ^^^^^^^^^^^^ ---
70+
| | |
71+
| | unexpected argument of type `{integer}`
72+
| help: remove the extra argument
7673
|
7774
note: function defined here
7875
--> $DIR/extra_arguments.rs:3:4
7976
|
8077
LL | fn two_arg_same(_a: i32, _b: i32) {}
8178
| ^^^^^^^^^^^^ ------- -------
82-
help: remove the extra argument
83-
|
84-
LL - two_arg_same(1, 1, 1);
85-
LL + two_arg_same(1, 1);
86-
|
8779

8880
error[E0061]: this function takes 2 arguments but 3 arguments were supplied
8981
--> $DIR/extra_arguments.rs:14:3
9082
|
9183
LL | two_arg_same(1, 1, 1.0);
92-
| ^^^^^^^^^^^^ --- unexpected argument of type `{float}`
84+
| ^^^^^^^^^^^^ -----
85+
| | |
86+
| | unexpected argument of type `{float}`
87+
| help: remove the extra argument
9388
|
9489
note: function defined here
9590
--> $DIR/extra_arguments.rs:3:4
9691
|
9792
LL | fn two_arg_same(_a: i32, _b: i32) {}
9893
| ^^^^^^^^^^^^ ------- -------
99-
help: remove the extra argument
100-
|
101-
LL - two_arg_same(1, 1, 1.0);
102-
LL + two_arg_same(1, 1);
103-
|
10494

10595
error[E0061]: this function takes 2 arguments but 3 arguments were supplied
10696
--> $DIR/extra_arguments.rs:16:3
10797
|
10898
LL | two_arg_diff(1, 1, "");
109-
| ^^^^^^^^^^^^ - unexpected argument of type `{integer}`
99+
| ^^^^^^^^^^^^ ---
100+
| | |
101+
| | unexpected argument of type `{integer}`
102+
| help: remove the extra argument
110103
|
111104
note: function defined here
112105
--> $DIR/extra_arguments.rs:4:4
113106
|
114107
LL | fn two_arg_diff(_a: i32, _b: &str) {}
115108
| ^^^^^^^^^^^^ ------- --------
116-
help: remove the extra argument
117-
|
118-
LL - two_arg_diff(1, 1, "");
119-
LL + two_arg_diff(1, "");
120-
|
121109

122110
error[E0061]: this function takes 2 arguments but 3 arguments were supplied
123111
--> $DIR/extra_arguments.rs:17:3
124112
|
125113
LL | two_arg_diff(1, "", "");
126-
| ^^^^^^^^^^^^ -- unexpected argument of type `&'static str`
114+
| ^^^^^^^^^^^^ ----
115+
| | |
116+
| | unexpected argument of type `&'static str`
117+
| help: remove the extra argument
127118
|
128119
note: function defined here
129120
--> $DIR/extra_arguments.rs:4:4
130121
|
131122
LL | fn two_arg_diff(_a: i32, _b: &str) {}
132123
| ^^^^^^^^^^^^ ------- --------
133-
help: remove the extra argument
134-
|
135-
LL - two_arg_diff(1, "", "");
136-
LL + two_arg_diff(1, "");
137-
|
138124

139125
error[E0061]: this function takes 2 arguments but 4 arguments were supplied
140126
--> $DIR/extra_arguments.rs:18:3
@@ -178,75 +164,70 @@ error[E0061]: this function takes 2 arguments but 3 arguments were supplied
178164
--> $DIR/extra_arguments.rs:22:3
179165
|
180166
LL | two_arg_same(1, 1, "");
181-
| ^^^^^^^^^^^^ -- unexpected argument of type `&'static str`
167+
| ^^^^^^^^^^^^ --------
168+
| | |
169+
| | unexpected argument of type `&'static str`
170+
| help: remove the extra argument
182171
|
183172
note: function defined here
184173
--> $DIR/extra_arguments.rs:3:4
185174
|
186175
LL | fn two_arg_same(_a: i32, _b: i32) {}
187176
| ^^^^^^^^^^^^ ------- -------
188-
help: remove the extra argument
189-
|
190-
LL - two_arg_same(1, 1, "");
191-
LL + two_arg_same(1, 1);
192-
|
193177

194178
error[E0061]: this function takes 2 arguments but 3 arguments were supplied
195179
--> $DIR/extra_arguments.rs:23:3
196180
|
197181
LL | two_arg_diff(1, 1, "");
198-
| ^^^^^^^^^^^^ - unexpected argument of type `{integer}`
182+
| ^^^^^^^^^^^^ ---
183+
| | |
184+
| | unexpected argument of type `{integer}`
185+
| help: remove the extra argument
199186
|
200187
note: function defined here
201188
--> $DIR/extra_arguments.rs:4:4
202189
|
203190
LL | fn two_arg_diff(_a: i32, _b: &str) {}
204191
| ^^^^^^^^^^^^ ------- --------
205-
help: remove the extra argument
206-
|
207-
LL - two_arg_diff(1, 1, "");
208-
LL + two_arg_diff(1, "");
209-
|
210192

211193
error[E0061]: this function takes 2 arguments but 3 arguments were supplied
212194
--> $DIR/extra_arguments.rs:24:3
213195
|
214-
LL | two_arg_same(
215-
| ^^^^^^^^^^^^
216-
...
217-
LL | ""
218-
| -- unexpected argument of type `&'static str`
196+
LL | two_arg_same(
197+
| ^^^^^^^^^^^^
198+
LL | 1,
199+
LL | 1,
200+
| ______-
201+
LL | | ""
202+
| | --
203+
| |_____||
204+
| |help: remove the extra argument
205+
| unexpected argument of type `&'static str`
219206
|
220207
note: function defined here
221208
--> $DIR/extra_arguments.rs:3:4
222209
|
223210
LL | fn two_arg_same(_a: i32, _b: i32) {}
224211
| ^^^^^^^^^^^^ ------- -------
225-
help: remove the extra argument
226-
|
227-
LL - 1,
228-
LL + 1
229-
|
230212

231213
error[E0061]: this function takes 2 arguments but 3 arguments were supplied
232214
--> $DIR/extra_arguments.rs:30:3
233215
|
234-
LL | two_arg_diff(
235-
| ^^^^^^^^^^^^
236-
LL | 1,
237-
LL | 1,
238-
| - unexpected argument of type `{integer}`
216+
LL | two_arg_diff(
217+
| ^^^^^^^^^^^^
218+
LL | 1,
219+
| ______-
220+
LL | | 1,
221+
| | -
222+
| | |
223+
| |_____unexpected argument of type `{integer}`
224+
| help: remove the extra argument
239225
|
240226
note: function defined here
241227
--> $DIR/extra_arguments.rs:4:4
242228
|
243229
LL | fn two_arg_diff(_a: i32, _b: &str) {}
244230
| ^^^^^^^^^^^^ ------- --------
245-
help: remove the extra argument
246-
|
247-
LL - 1,
248-
LL + 1,
249-
|
250231

251232
error: aborting due to 14 previous errors
252233

0 commit comments

Comments
 (0)