-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Fix nonsense non-tupled Fn
trait error
#99942
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Changes from all 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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#![feature(unboxed_closures)] | ||
|
||
fn a<F: Fn<usize>>(f: F) {} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't we just report that a tuple is expected and bail out? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well making this a hard error in #99943, so I don't want to just introduce a special case error logic here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, reporting that a tuple is expected and bailing out is not gonna work when you have a generic |
||
|
||
fn main() { | ||
a(|_: usize| {}); | ||
//~^ ERROR mismatched types | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
error[E0308]: mismatched types | ||
--> $DIR/non-tupled-arg-mismatch.rs:6:5 | ||
| | ||
LL | a(|_: usize| {}); | ||
| ^ types differ | ||
| | ||
= note: expected trait `Fn<usize>` | ||
found trait `Fn<(usize,)>` | ||
note: required by a bound in `a` | ||
--> $DIR/non-tupled-arg-mismatch.rs:3:9 | ||
| | ||
LL | fn a<F: Fn<usize>>(f: F) {} | ||
| ^^^^^^^^^ required by this bound in `a` | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0308`. |
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 do we keep a single
ArgKind::empty()
, like 1-tuples, instead of an empty vec?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.
No particular reason, I can fix that I guess.
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.
Oh, I know why. This code also handles
Generator<T>
which takes a generic argument that isn't a tupled set of arguments.