-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Don't let a type parameter named "Self" unchanged past HIR lowering. #36649
Conversation
r? @pnkfelix (rust_highfive has picked a reviewer for you, use r? to override) |
@eddyb I'm surprised; can't we catch the error here during parsing, rather than taking this (IMO strange) workaround? Is the parser not set up to do so? Or am I not thinking about this the right way? |
@pnkfelix The parser errors but it uses the keyword as an identifier and continues compilation. |
@eddyb Hmm, I see. Okay. Its still pretty bizarre but I guess I don't have any solid objection. |
@bors r+ |
📌 Commit 795b6ad has been approved by |
Don't let a type parameter named "Self" unchanged past HIR lowering. Fixes #36638 by rewriting `Self` type parameters (which are a parse error) to a `gensym("Self")`. Background: #35605 introduced code across rustc that determines `Self` by its keyword name. Reverting the sanity checks around that would inadvertently cause confusion between the true `Self` of a `trait` and other type parameters named `Self` (which have caused parse errors already). I do not like to use `gensym`, and we may do something different here in the future, but this should work.
Fixes #36638 by rewriting
Self
type parameters (which are a parse error) to agensym("Self")
.Background: #35605 introduced code across rustc that determines
Self
by its keyword name.Reverting the sanity checks around that would inadvertently cause confusion between the true
Self
of atrait
and other type parameters namedSelf
(which have caused parse errors already).I do not like to use
gensym
, and we may do something different here in the future, but this should work.