-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Issue with impl Trait and panic!() #55022
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
Comments
FYI: This also means that fn foo() -> impl Iterator<Item = i32> {
unimplemented!()
} doesn't compile! |
Yeah, I always use |
Clicking through compiler explorer, the original example has never compiled on any stable release (since stabilizing impl trait on 1.26). The error also occurs on traits without associated types trait Bar {}
fn foo() -> impl Bar {
unimplemented!()
}
(It will compile when returning something like |
This is a known design question concerning |
I'm closing this as not-a-bug as we never decided that |
@Centril Yes, they currently won't, but I just assumed that it is uncontroversial that However, if the do-we-want-this-to-work comes first, can you refer me to the appropriate way to open an issue/discussion to figure that out? That would be awesome, thanks! |
There's some discussion in the tracking issue, e.g. starting with #35121 (comment) and probably more in various places (e.g. rust-lang/rfcs#2619). It's far more subtle than "all traits" I think and needs some language design (assuming there's agreement which there might not be). If you want to tackle this I'd read all previous discussions first and then raise an issue on internals.rust-lang.org/. (However, I'm skeptical that this should be a priority for the language and compiler teams). |
Ah, I see the issue is already being discussed. If that's the case I'll just let it rest, seems there are enough people aware of it already. Thanks for the links! :) |
The following code does not compile on nightly (and 1.29.1 stable) (playground):
I expected this code to compile, but instead I get the following error:
This seems like it should work to me.
The text was updated successfully, but these errors were encountered: