forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#86493 - Smittyvb:ctor-typeck-error, r=david…
…twco Say "this enum variant takes"/"this struct takes" instead of "this function takes" This makes error messages for functions with incorrect argument counts adapt if they refer to a struct or enum variant: ``` error[E0061]: this enum variant takes 1 argument but 0 arguments were supplied --> $DIR/struct-enum-wrong-args.rs:7:13 | LL | let _ = Ok(); | ^^-- supplied 0 arguments | | | expected 1 argument error[E0061]: this struct takes 1 argument but 0 arguments were supplied --> $DIR/struct-enum-wrong-args.rs:8:13 | LL | let _ = Wrapper(); | ^^^^^^^-- supplied 0 arguments | | | expected 1 argument ``` Fixes rust-lang#86481.
- Loading branch information
Showing
5 changed files
with
107 additions
and
6 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
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
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
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,14 @@ | ||
// Regression test of #86481. | ||
struct Wrapper(i32); | ||
struct DoubleWrapper(i32, i32); | ||
|
||
fn main() { | ||
let _ = Some(3, 2); //~ ERROR this enum variant takes | ||
let _ = Ok(3, 6, 2); //~ ERROR this enum variant takes | ||
let _ = Ok(); //~ ERROR this enum variant takes | ||
let _ = Wrapper(); //~ ERROR this struct takes | ||
let _ = Wrapper(5, 2); //~ ERROR this struct takes | ||
let _ = DoubleWrapper(); //~ ERROR this struct takes | ||
let _ = DoubleWrapper(5); //~ ERROR this struct takes | ||
let _ = DoubleWrapper(5, 2, 7); //~ ERROR this struct takes | ||
} |
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,67 @@ | ||
error[E0061]: this enum variant takes 1 argument but 2 arguments were supplied | ||
--> $DIR/struct-enum-wrong-args.rs:6:13 | ||
| | ||
LL | let _ = Some(3, 2); | ||
| ^^^^ - - supplied 2 arguments | ||
| | | ||
| expected 1 argument | ||
|
||
error[E0061]: this enum variant takes 1 argument but 3 arguments were supplied | ||
--> $DIR/struct-enum-wrong-args.rs:7:13 | ||
| | ||
LL | let _ = Ok(3, 6, 2); | ||
| ^^ - - - supplied 3 arguments | ||
| | | ||
| expected 1 argument | ||
|
||
error[E0061]: this enum variant takes 1 argument but 0 arguments were supplied | ||
--> $DIR/struct-enum-wrong-args.rs:8:13 | ||
| | ||
LL | let _ = Ok(); | ||
| ^^-- supplied 0 arguments | ||
| | | ||
| expected 1 argument | ||
|
||
error[E0061]: this struct takes 1 argument but 0 arguments were supplied | ||
--> $DIR/struct-enum-wrong-args.rs:9:13 | ||
| | ||
LL | let _ = Wrapper(); | ||
| ^^^^^^^-- supplied 0 arguments | ||
| | | ||
| expected 1 argument | ||
|
||
error[E0061]: this struct takes 1 argument but 2 arguments were supplied | ||
--> $DIR/struct-enum-wrong-args.rs:10:13 | ||
| | ||
LL | let _ = Wrapper(5, 2); | ||
| ^^^^^^^ - - supplied 2 arguments | ||
| | | ||
| expected 1 argument | ||
|
||
error[E0061]: this struct takes 2 arguments but 0 arguments were supplied | ||
--> $DIR/struct-enum-wrong-args.rs:11:13 | ||
| | ||
LL | let _ = DoubleWrapper(); | ||
| ^^^^^^^^^^^^^-- supplied 0 arguments | ||
| | | ||
| expected 2 arguments | ||
|
||
error[E0061]: this struct takes 2 arguments but 1 argument was supplied | ||
--> $DIR/struct-enum-wrong-args.rs:12:13 | ||
| | ||
LL | let _ = DoubleWrapper(5); | ||
| ^^^^^^^^^^^^^ - supplied 1 argument | ||
| | | ||
| expected 2 arguments | ||
|
||
error[E0061]: this struct takes 2 arguments but 3 arguments were supplied | ||
--> $DIR/struct-enum-wrong-args.rs:13:13 | ||
| | ||
LL | let _ = DoubleWrapper(5, 2, 7); | ||
| ^^^^^^^^^^^^^ - - - supplied 3 arguments | ||
| | | ||
| expected 2 arguments | ||
|
||
error: aborting due to 8 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0061`. |