-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix incorrect suggestion for extra argument with a type error
- Loading branch information
1 parent
49ff390
commit 9f32459
Showing
3 changed files
with
171 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
tests/ui/argument-suggestions/suggest-better-removing-issue-126246.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
fn add_one(x: i32) -> i32 { | ||
x + 1 | ||
} | ||
|
||
fn add_two(x: i32, y: i32) -> i32 { | ||
x + y | ||
} | ||
|
||
fn main() { | ||
add_one(2, 2); //~ ERROR this function takes 1 argument but 2 arguments were supplied | ||
add_one(no_such_local, 10); //~ ERROR cannot find value `no_such_local` in this scope | ||
//~| ERROR this function takes 1 argument but 2 arguments were supplied | ||
add_one(10, no_such_local); //~ ERROR cannot find value `no_such_local` in this scope | ||
//~| ERROR this function takes 1 argument but 2 arguments were supplied | ||
add_two(10, no_such_local, 10); //~ ERROR cannot find value `no_such_local` in this scope | ||
//~| ERROR this function takes 2 arguments but 3 arguments were supplied | ||
add_two(no_such_local, 10, 10); //~ ERROR cannot find value `no_such_local` in this scope | ||
//~| ERROR this function takes 2 arguments but 3 arguments were supplied | ||
add_two(10, 10, no_such_local); //~ ERROR cannot find value `no_such_local` in this scope | ||
//~| ERROR this function takes 2 arguments but 3 arguments were supplied | ||
} |
124 changes: 124 additions & 0 deletions
124
tests/ui/argument-suggestions/suggest-better-removing-issue-126246.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
error[E0425]: cannot find value `no_such_local` in this scope | ||
--> $DIR/suggest-better-removing-issue-126246.rs:11:13 | ||
| | ||
LL | add_one(no_such_local, 10); | ||
| ^^^^^^^^^^^^^ not found in this scope | ||
|
||
error[E0425]: cannot find value `no_such_local` in this scope | ||
--> $DIR/suggest-better-removing-issue-126246.rs:13:17 | ||
| | ||
LL | add_one(10, no_such_local); | ||
| ^^^^^^^^^^^^^ not found in this scope | ||
|
||
error[E0425]: cannot find value `no_such_local` in this scope | ||
--> $DIR/suggest-better-removing-issue-126246.rs:15:17 | ||
| | ||
LL | add_two(10, no_such_local, 10); | ||
| ^^^^^^^^^^^^^ not found in this scope | ||
|
||
error[E0425]: cannot find value `no_such_local` in this scope | ||
--> $DIR/suggest-better-removing-issue-126246.rs:17:13 | ||
| | ||
LL | add_two(no_such_local, 10, 10); | ||
| ^^^^^^^^^^^^^ not found in this scope | ||
|
||
error[E0425]: cannot find value `no_such_local` in this scope | ||
--> $DIR/suggest-better-removing-issue-126246.rs:19:21 | ||
| | ||
LL | add_two(10, 10, no_such_local); | ||
| ^^^^^^^^^^^^^ not found in this scope | ||
|
||
error[E0061]: this function takes 1 argument but 2 arguments were supplied | ||
--> $DIR/suggest-better-removing-issue-126246.rs:10:5 | ||
| | ||
LL | add_one(2, 2); | ||
| ^^^^^^^ --- | ||
| | | | ||
| | unexpected argument of type `{integer}` | ||
| help: remove the extra argument | ||
| | ||
note: function defined here | ||
--> $DIR/suggest-better-removing-issue-126246.rs:1:4 | ||
| | ||
LL | fn add_one(x: i32) -> i32 { | ||
| ^^^^^^^ ------ | ||
|
||
error[E0061]: this function takes 1 argument but 2 arguments were supplied | ||
--> $DIR/suggest-better-removing-issue-126246.rs:11:5 | ||
| | ||
LL | add_one(no_such_local, 10); | ||
| ^^^^^^^ --------------- | ||
| | | ||
| unexpected argument | ||
| help: remove the extra argument | ||
| | ||
note: function defined here | ||
--> $DIR/suggest-better-removing-issue-126246.rs:1:4 | ||
| | ||
LL | fn add_one(x: i32) -> i32 { | ||
| ^^^^^^^ ------ | ||
|
||
error[E0061]: this function takes 1 argument but 2 arguments were supplied | ||
--> $DIR/suggest-better-removing-issue-126246.rs:13:5 | ||
| | ||
LL | add_one(10, no_such_local); | ||
| ^^^^^^^ --------------- | ||
| | | | ||
| | unexpected argument | ||
| help: remove the extra argument | ||
| | ||
note: function defined here | ||
--> $DIR/suggest-better-removing-issue-126246.rs:1:4 | ||
| | ||
LL | fn add_one(x: i32) -> i32 { | ||
| ^^^^^^^ ------ | ||
|
||
error[E0061]: this function takes 2 arguments but 3 arguments were supplied | ||
--> $DIR/suggest-better-removing-issue-126246.rs:15:5 | ||
| | ||
LL | add_two(10, no_such_local, 10); | ||
| ^^^^^^^ --------------- | ||
| | | | ||
| | unexpected argument | ||
| help: remove the extra argument | ||
| | ||
note: function defined here | ||
--> $DIR/suggest-better-removing-issue-126246.rs:5:4 | ||
| | ||
LL | fn add_two(x: i32, y: i32) -> i32 { | ||
| ^^^^^^^ ------ ------ | ||
|
||
error[E0061]: this function takes 2 arguments but 3 arguments were supplied | ||
--> $DIR/suggest-better-removing-issue-126246.rs:17:5 | ||
| | ||
LL | add_two(no_such_local, 10, 10); | ||
| ^^^^^^^ --------------- | ||
| | | ||
| unexpected argument | ||
| help: remove the extra argument | ||
| | ||
note: function defined here | ||
--> $DIR/suggest-better-removing-issue-126246.rs:5:4 | ||
| | ||
LL | fn add_two(x: i32, y: i32) -> i32 { | ||
| ^^^^^^^ ------ ------ | ||
|
||
error[E0061]: this function takes 2 arguments but 3 arguments were supplied | ||
--> $DIR/suggest-better-removing-issue-126246.rs:19:5 | ||
| | ||
LL | add_two(10, 10, no_such_local); | ||
| ^^^^^^^ --------------- | ||
| | | | ||
| | unexpected argument | ||
| help: remove the extra argument | ||
| | ||
note: function defined here | ||
--> $DIR/suggest-better-removing-issue-126246.rs:5:4 | ||
| | ||
LL | fn add_two(x: i32, y: i32) -> i32 { | ||
| ^^^^^^^ ------ ------ | ||
|
||
error: aborting due to 11 previous errors | ||
|
||
Some errors have detailed explanations: E0061, E0425. | ||
For more information about an error, try `rustc --explain E0061`. |