Skip to content

Commit

Permalink
Make removal suggestion not verbose
Browse files Browse the repository at this point in the history
  • Loading branch information
estebank committed Feb 14, 2023
1 parent 5d63e10 commit bd176ee
Show file tree
Hide file tree
Showing 16 changed files with 136 additions and 196 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1167,7 +1167,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
Some(format!("provide the argument{}", if plural { "s" } else { "" }))
}
SuggestionText::Remove(plural) => {
err.multipart_suggestion_verbose(
err.multipart_suggestion(
&format!("remove the extra argument{}", if plural { "s" } else { "" }),
suggestions,
Applicability::HasPlaceholders,
Expand Down
11 changes: 4 additions & 7 deletions tests/ui/alloc-error/alloc-error-handler-bad-signature-3.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,17 @@ LL | fn oom() -> ! {
| _-^^^^^^^^^^^^
LL | | loop {}
LL | | }
| |_- unexpected argument of type `core::alloc::Layout`
| | -
| | |
| |_unexpected argument of type `core::alloc::Layout`
| help: remove the extra argument
|
note: function defined here
--> $DIR/alloc-error-handler-bad-signature-3.rs:10:4
|
LL | fn oom() -> ! {
| ^^^
= note: this error originates in the attribute macro `alloc_error_handler` (in Nightly builds, run with -Z macro-backtrace for more info)
help: remove the extra argument
|
LL - fn oom() -> ! {
LL - loop {}
LL - }
|

error: aborting due to previous error

Expand Down
10 changes: 4 additions & 6 deletions tests/ui/argument-suggestions/basic.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,16 @@ error[E0061]: this function takes 0 arguments but 1 argument was supplied
--> $DIR/basic.rs:21:5
|
LL | extra("");
| ^^^^^ -- unexpected argument of type `&'static str`
| ^^^^^ --
| |
| unexpected argument of type `&'static str`
| help: remove the extra argument
|
note: function defined here
--> $DIR/basic.rs:14:4
|
LL | fn extra() {}
| ^^^^^
help: remove the extra argument
|
LL - extra("");
LL + extra();
|

error[E0061]: this function takes 1 argument but 0 arguments were supplied
--> $DIR/basic.rs:22:5
Expand Down
40 changes: 16 additions & 24 deletions tests/ui/argument-suggestions/exotic-calls.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,69 +2,61 @@ error[E0057]: this function takes 0 arguments but 1 argument was supplied
--> $DIR/exotic-calls.rs:2:5
|
LL | t(1i32);
| ^ ---- unexpected argument of type `i32`
| ^ ----
| |
| unexpected argument of type `i32`
| help: remove the extra argument
|
note: callable defined here
--> $DIR/exotic-calls.rs:1:11
|
LL | fn foo<T: Fn()>(t: T) {
| ^^^^
help: remove the extra argument
|
LL - t(1i32);
LL + t();
|

error[E0057]: this function takes 0 arguments but 1 argument was supplied
--> $DIR/exotic-calls.rs:7:5
|
LL | t(1i32);
| ^ ---- unexpected argument of type `i32`
| ^ ----
| |
| unexpected argument of type `i32`
| help: remove the extra argument
|
note: type parameter defined here
--> $DIR/exotic-calls.rs:6:11
|
LL | fn bar(t: impl Fn()) {
| ^^^^^^^^^
help: remove the extra argument
|
LL - t(1i32);
LL + t();
|

error[E0057]: this function takes 0 arguments but 1 argument was supplied
--> $DIR/exotic-calls.rs:16:5
|
LL | baz()(1i32)
| ^^^^^ ---- unexpected argument of type `i32`
| ^^^^^ ----
| |
| unexpected argument of type `i32`
| help: remove the extra argument
|
note: opaque type defined here
--> $DIR/exotic-calls.rs:11:13
|
LL | fn baz() -> impl Fn() {
| ^^^^^^^^^
help: remove the extra argument
|
LL - baz()(1i32)
LL + baz()()
|

error[E0057]: this function takes 0 arguments but 1 argument was supplied
--> $DIR/exotic-calls.rs:22:5
|
LL | x(1i32);
| ^ ---- unexpected argument of type `i32`
| ^ ----
| |
| unexpected argument of type `i32`
| help: remove the extra argument
|
note: closure defined here
--> $DIR/exotic-calls.rs:21:13
|
LL | let x = || {};
| ^^
help: remove the extra argument
|
LL - x(1i32);
LL + x();
|

error: aborting due to 4 previous errors

Expand Down
129 changes: 55 additions & 74 deletions tests/ui/argument-suggestions/extra_arguments.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,52 +2,46 @@ error[E0061]: this function takes 0 arguments but 1 argument was supplied
--> $DIR/extra_arguments.rs:7:3
|
LL | empty("");
| ^^^^^ -- unexpected argument of type `&'static str`
| ^^^^^ --
| |
| unexpected argument of type `&'static str`
| help: remove the extra argument
|
note: function defined here
--> $DIR/extra_arguments.rs:1:4
|
LL | fn empty() {}
| ^^^^^
help: remove the extra argument
|
LL - empty("");
LL + empty();
|

error[E0061]: this function takes 1 argument but 2 arguments were supplied
--> $DIR/extra_arguments.rs:9:3
|
LL | one_arg(1, 1);
| ^^^^^^^ - unexpected argument of type `{integer}`
| ^^^^^^^ ---
| | |
| | unexpected argument of type `{integer}`
| help: remove the extra argument
|
note: function defined here
--> $DIR/extra_arguments.rs:2:4
|
LL | fn one_arg(_a: i32) {}
| ^^^^^^^ -------
help: remove the extra argument
|
LL - one_arg(1, 1);
LL + one_arg(1);
|

error[E0061]: this function takes 1 argument but 2 arguments were supplied
--> $DIR/extra_arguments.rs:10:3
|
LL | one_arg(1, "");
| ^^^^^^^ -- unexpected argument of type `&'static str`
| ^^^^^^^ ----
| | |
| | unexpected argument of type `&'static str`
| help: remove the extra argument
|
note: function defined here
--> $DIR/extra_arguments.rs:2:4
|
LL | fn one_arg(_a: i32) {}
| ^^^^^^^ -------
help: remove the extra argument
|
LL - one_arg(1, "");
LL + one_arg(1);
|

error[E0061]: this function takes 1 argument but 3 arguments were supplied
--> $DIR/extra_arguments.rs:11:3
Expand All @@ -72,69 +66,61 @@ error[E0061]: this function takes 2 arguments but 3 arguments were supplied
--> $DIR/extra_arguments.rs:13:3
|
LL | two_arg_same(1, 1, 1);
| ^^^^^^^^^^^^ - unexpected argument of type `{integer}`
| ^^^^^^^^^^^^ ---
| | |
| | unexpected argument of type `{integer}`
| help: remove the extra argument
|
note: function defined here
--> $DIR/extra_arguments.rs:3:4
|
LL | fn two_arg_same(_a: i32, _b: i32) {}
| ^^^^^^^^^^^^ ------- -------
help: remove the extra argument
|
LL - two_arg_same(1, 1, 1);
LL + two_arg_same(1, 1);
|

error[E0061]: this function takes 2 arguments but 3 arguments were supplied
--> $DIR/extra_arguments.rs:14:3
|
LL | two_arg_same(1, 1, 1.0);
| ^^^^^^^^^^^^ --- unexpected argument of type `{float}`
| ^^^^^^^^^^^^ -----
| | |
| | unexpected argument of type `{float}`
| help: remove the extra argument
|
note: function defined here
--> $DIR/extra_arguments.rs:3:4
|
LL | fn two_arg_same(_a: i32, _b: i32) {}
| ^^^^^^^^^^^^ ------- -------
help: remove the extra argument
|
LL - two_arg_same(1, 1, 1.0);
LL + two_arg_same(1, 1);
|

error[E0061]: this function takes 2 arguments but 3 arguments were supplied
--> $DIR/extra_arguments.rs:16:3
|
LL | two_arg_diff(1, 1, "");
| ^^^^^^^^^^^^ - unexpected argument of type `{integer}`
| ^^^^^^^^^^^^ ---
| | |
| | unexpected argument of type `{integer}`
| help: remove the extra argument
|
note: function defined here
--> $DIR/extra_arguments.rs:4:4
|
LL | fn two_arg_diff(_a: i32, _b: &str) {}
| ^^^^^^^^^^^^ ------- --------
help: remove the extra argument
|
LL - two_arg_diff(1, 1, "");
LL + two_arg_diff(1, "");
|

error[E0061]: this function takes 2 arguments but 3 arguments were supplied
--> $DIR/extra_arguments.rs:17:3
|
LL | two_arg_diff(1, "", "");
| ^^^^^^^^^^^^ -- unexpected argument of type `&'static str`
| ^^^^^^^^^^^^ ----
| | |
| | unexpected argument of type `&'static str`
| help: remove the extra argument
|
note: function defined here
--> $DIR/extra_arguments.rs:4:4
|
LL | fn two_arg_diff(_a: i32, _b: &str) {}
| ^^^^^^^^^^^^ ------- --------
help: remove the extra argument
|
LL - two_arg_diff(1, "", "");
LL + two_arg_diff(1, "");
|

error[E0061]: this function takes 2 arguments but 4 arguments were supplied
--> $DIR/extra_arguments.rs:18:3
Expand Down Expand Up @@ -178,75 +164,70 @@ error[E0061]: this function takes 2 arguments but 3 arguments were supplied
--> $DIR/extra_arguments.rs:22:3
|
LL | two_arg_same(1, 1, "");
| ^^^^^^^^^^^^ -- unexpected argument of type `&'static str`
| ^^^^^^^^^^^^ --------
| | |
| | unexpected argument of type `&'static str`
| help: remove the extra argument
|
note: function defined here
--> $DIR/extra_arguments.rs:3:4
|
LL | fn two_arg_same(_a: i32, _b: i32) {}
| ^^^^^^^^^^^^ ------- -------
help: remove the extra argument
|
LL - two_arg_same(1, 1, "");
LL + two_arg_same(1, 1);
|

error[E0061]: this function takes 2 arguments but 3 arguments were supplied
--> $DIR/extra_arguments.rs:23:3
|
LL | two_arg_diff(1, 1, "");
| ^^^^^^^^^^^^ - unexpected argument of type `{integer}`
| ^^^^^^^^^^^^ ---
| | |
| | unexpected argument of type `{integer}`
| help: remove the extra argument
|
note: function defined here
--> $DIR/extra_arguments.rs:4:4
|
LL | fn two_arg_diff(_a: i32, _b: &str) {}
| ^^^^^^^^^^^^ ------- --------
help: remove the extra argument
|
LL - two_arg_diff(1, 1, "");
LL + two_arg_diff(1, "");
|

error[E0061]: this function takes 2 arguments but 3 arguments were supplied
--> $DIR/extra_arguments.rs:24:3
|
LL | two_arg_same(
| ^^^^^^^^^^^^
...
LL | ""
| -- unexpected argument of type `&'static str`
LL | two_arg_same(
| ^^^^^^^^^^^^
LL | 1,
LL | 1,
| ______-
LL | | ""
| | --
| |_____||
| |help: remove the extra argument
| unexpected argument of type `&'static str`
|
note: function defined here
--> $DIR/extra_arguments.rs:3:4
|
LL | fn two_arg_same(_a: i32, _b: i32) {}
| ^^^^^^^^^^^^ ------- -------
help: remove the extra argument
|
LL - 1,
LL + 1
|

error[E0061]: this function takes 2 arguments but 3 arguments were supplied
--> $DIR/extra_arguments.rs:30:3
|
LL | two_arg_diff(
| ^^^^^^^^^^^^
LL | 1,
LL | 1,
| - unexpected argument of type `{integer}`
LL | two_arg_diff(
| ^^^^^^^^^^^^
LL | 1,
| ______-
LL | | 1,
| | -
| | |
| |_____unexpected argument of type `{integer}`
| help: remove the extra argument
|
note: function defined here
--> $DIR/extra_arguments.rs:4:4
|
LL | fn two_arg_diff(_a: i32, _b: &str) {}
| ^^^^^^^^^^^^ ------- --------
help: remove the extra argument
|
LL - 1,
LL + 1,
|

error: aborting due to 14 previous errors

Expand Down
Loading

0 comments on commit bd176ee

Please sign in to comment.