-
Notifications
You must be signed in to change notification settings - Fork 14.1k
Better error for missing tuple pattern in args #45069
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
Changes from 4 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,16 @@ | ||
| error[E0593]: closure takes 0 arguments but 2 arguments are required | ||
| error[E0593]: closure is expected to take 2 arguments, but it takes 0 arguments | ||
| --> $DIR/closure-arg-count.rs:15:15 | ||
| | | ||
| 15 | [1, 2, 3].sort_by(|| panic!()); | ||
| | ^^^^^^^ ----------- takes 0 arguments | ||
| | ^^^^^^^ -- takes 0 arguments | ||
| | | | ||
| | expected closure that takes 2 arguments | ||
|
|
||
| error[E0593]: closure takes 1 argument but 2 arguments are required | ||
| error[E0593]: closure is expected to take 2 arguments, but it takes 1 argument | ||
| --> $DIR/closure-arg-count.rs:16:15 | ||
| | | ||
| 16 | [1, 2, 3].sort_by(|tuple| panic!()); | ||
| | ^^^^^^^ ---------------- takes 1 argument | ||
| | ^^^^^^^ ------- takes 1 argument | ||
| | | | ||
| | expected closure that takes 2 arguments | ||
|
|
||
|
|
@@ -23,23 +23,47 @@ error[E0308]: mismatched types | |
| = note: expected type `&{integer}` | ||
| found type `(_, _)` | ||
|
|
||
| error[E0593]: closure takes 1 argument but 2 arguments are required | ||
| error[E0593]: closure is expected to take 2 arguments, but it takes 1 argument | ||
| --> $DIR/closure-arg-count.rs:17:15 | ||
| | | ||
| 17 | [1, 2, 3].sort_by(|(tuple, tuple2)| panic!()); | ||
| | ^^^^^^^ -------------------------- takes 1 argument | ||
| | ^^^^^^^ ----------------- takes 1 argument | ||
| | | | ||
| | expected closure that takes 2 arguments | ||
|
|
||
| error[E0593]: closure takes 0 arguments but 1 argument is required | ||
| error[E0593]: closure is expected to take 1 argument, but it takes 0 arguments | ||
| --> $DIR/closure-arg-count.rs:18:5 | ||
| | | ||
| 18 | f(|| panic!()); | ||
| | ^ ----------- takes 0 arguments | ||
| | ^ -- takes 0 arguments | ||
| | | | ||
| | expected closure that takes 1 argument | ||
| | | ||
| = note: required by `f` | ||
|
|
||
| error: aborting due to 5 previous errors | ||
| error[E0593]: closure is expected to take a single tuple as argument, but it takes 2 distinct arguments | ||
| --> $DIR/closure-arg-count.rs:20:53 | ||
| | | ||
| 20 | let _it = vec![1, 2, 3].into_iter().enumerate().map(|i, x| i); | ||
| | ^^^ ------ help: consider changing to: `|(i, x)|` | ||
|
||
| | | | ||
| | expected closure that takes 1 argument, a 2-tuple | ||
|
||
|
|
||
| error[E0593]: closure is expected to take a single tuple as argument, but it takes 2 distinct arguments | ||
| --> $DIR/closure-arg-count.rs:21:53 | ||
| | | ||
| 21 | let _it = vec![1, 2, 3].into_iter().enumerate().map(|i: usize, x| i); | ||
| | ^^^ ------------- help: consider changing to: `|(i, x): (usize, _)|` | ||
|
||
| | | | ||
| | expected closure that takes 1 argument, a 2-tuple | ||
|
|
||
| error[E0593]: closure is expected to take a single tuple as argument, but it takes 3 distinct arguments | ||
| --> $DIR/closure-arg-count.rs:22:53 | ||
| | | ||
| 22 | let _it = vec![1, 2, 3].into_iter().enumerate().map(|i, x, y| i); | ||
| | ^^^ --------- takes 3 distinct arguments | ||
| | | | ||
| | expected closure that takes 1 argument, a 2-tuple | ||
|
|
||
| error: aborting due to 8 previous errors | ||
|
|
||
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.
Why does this say "FIXME"?
Uh oh!
There was an error while loading. Please reload this page.
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.
This PR improves message for "expected |(x, y)|, found |x, y|" case but not "expected |x, y|, found |(x, y)|" case. In the latter case,
found_trait_refshould beFnMut<((_, _),)>, but it becomesFnMut<(_,)>and I don't know how to fix.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.
@nikomatsakis, I believe @sinkuu is referring to the following case:
We should create an issue after this PR lands to track that case.