-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
impl dyn for AnyType fails to compile #50405
Comments
You could use |
Actually, this is failing on stable as well? Uhh.... It's failing in Rust 1.24 (on my computer) and Rust 1.25 (playpen). I don't have older versions of Rust to test with. Update: Using Godbolt, it compiles on Rust 1.22 and fails to compile on Rust 1.23. |
triage: P-high Parsing regression. @petrochenkov seems to be on it =) Also, @Havvy, you are a bad, bad person for trying to do this. 😛 |
We need to increase lookahead to at least 2 tokens to disambiguate (I'll submit a PR soon-ish). But it would still be not enough for precise disambiguation, because So maybe we shouldn't even start increasing lookahead and keep breakage as is? |
Nominating for lang team discussion. |
AFAICT this needs infinite look-ahead to work as a contextual keyword. |
What was the outcome of the lang team discussion? |
Oops! I'll try to leave a more polished comment later :) but the TL;DR was we felt like it was not necessarily worth fixing this. |
Argh. I'm slow. The basic conclusion was that we felt like it was not worth trying to fix this, given the complications that it induces, and given that (as far as we know) no real code in the wild is relying on being able to name a trait However, it occurs to me now in we might want to at least make it a hard error to declare such a trait for clarity. That is, we should not parse |
Thoughts on this @rust-lang/lang or @petrochenkov ?
|
Nominating again both to double check on this final point (lang) and to try and assess a priority (compiler or lang). |
I agree that it makes sense to disallow |
We discussed in the @rust-lang/lang meeting and decided that we should prohibit traits named |
My sense is that this is high priority because of back-compat, hence I am going to mark as |
OK, we've made no progress here. Assigning to myself, I'll try to whip up a patch. |
Almost got this PR prepared. Sorry, kept putting this off. I wound up just banning |
OK, on the PR discussion, we decided to take a somewhat different tack. Basically: you can name traits as |
I'm going to close this issue then. Thanks to @Havvy for bringing it to our attention. =) |
Playpen
Expected: Program
outputs "I'm S!"(missed a println) compiles.Actual:
Since
dyn
is a contextual keyword and still allowed as an identifier, I expect to still be able to implement a trait named "dyn" for various structs. And indeed, if I change the trait name to "dyna", it works.The text was updated successfully, but these errors were encountered: