-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Say "this enum variant takes"/"this struct takes" instead of "this function takes" #86493
Merged
Conversation
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
r? @davidtwco (rust-highfive has picked a reviewer for you, use r? to override) |
rust-highfive
added
the
S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.
label
Jun 20, 2021
JohnTitor
approved these changes
Jun 21, 2021
davidtwco
approved these changes
Jun 21, 2021
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, r=me after resolving existing review comments.
@bors r+ |
📌 Commit b8a7bfb has been approved by |
bors
added
S-waiting-on-bors
Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
and removed
S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.
labels
Jun 21, 2021
JohnTitor
added a commit
to JohnTitor/rust
that referenced
this pull request
Jun 21, 2021
…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.
This was referenced Jun 21, 2021
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Jun 22, 2021
Rollup of 11 pull requests Successful merges: - rust-lang#85054 (Revert SGX inline asm syntax) - rust-lang#85182 (Move `available_concurrency` implementation to `sys`) - rust-lang#86037 (Add `io::Cursor::{remaining, remaining_slice, is_empty}`) - rust-lang#86114 (Reopen rust-lang#79692 (Format symbols under shared frames)) - rust-lang#86297 (Allow to pass arguments to rustdoc-gui tool) - rust-lang#86334 (Resolve type aliases to the type they point to in intra-doc links) - rust-lang#86367 (Fix comment about rustc_inherit_overflow_checks in abs().) - rust-lang#86381 (Add regression test for issue rust-lang#39161) - rust-lang#86387 (Remove `#[allow(unused_lifetimes)]` which is now unnecessary) - rust-lang#86398 (Add regression test for issue rust-lang#54685) - rust-lang#86493 (Say "this enum variant takes"/"this struct takes" instead of "this function takes") Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
matthiaskrgr
added a commit
to matthiaskrgr/rust
that referenced
this pull request
Jan 28, 2022
…=camelid Suggest tuple-parentheses for enum variants This follows on from rust-lang#86493 / rust-lang#86481, making the parentheses suggestion. To summarise, given the following code: ```rust fn f() -> Option<(i32, i8)> { Some(1, 2) } ``` The current output is: ``` error[E0061]: this enum variant takes 1 argument but 2 arguments were supplied --> b.rs:2:5 | 2 | Some(1, 2) | ^^^^ - - supplied 2 arguments | | | expected 1 argument error: aborting due to previous error For more information about this error, try `rustc --explain E0061`. ``` With this change, `rustc` will now suggest parentheses when: - The callee is expecting a single tuple argument - The number of arguments passed matches the element count in the above tuple - The arguments' types match the tuple's fields ``` error[E0061]: this enum variant takes 1 argument but 2 arguments were supplied --> b.rs:2:5 | 2 | Some(1, 2) | ^^^^ - - supplied 2 arguments | help: use parentheses to construct a tuple | 2 | Some((1, 2)) | + + ```
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Jan 28, 2022
…amelid Suggest tuple-parentheses for enum variants This follows on from rust-lang#86493 / rust-lang#86481, making the parentheses suggestion. To summarise, given the following code: ```rust fn f() -> Option<(i32, i8)> { Some(1, 2) } ``` The current output is: ``` error[E0061]: this enum variant takes 1 argument but 2 arguments were supplied --> b.rs:2:5 | 2 | Some(1, 2) | ^^^^ - - supplied 2 arguments | | | expected 1 argument error: aborting due to previous error For more information about this error, try `rustc --explain E0061`. ``` With this change, `rustc` will now suggest parentheses when: - The callee is expecting a single tuple argument - The number of arguments passed matches the element count in the above tuple - The arguments' types match the tuple's fields ``` error[E0061]: this enum variant takes 1 argument but 2 arguments were supplied --> b.rs:2:5 | 2 | Some(1, 2) | ^^^^ - - supplied 2 arguments | help: use parentheses to construct a tuple | 2 | Some((1, 2)) | + + ```
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
S-waiting-on-bors
Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This makes error messages for functions with incorrect argument counts adapt if they refer to a struct or enum variant:
Fixes #86481.