Skip to content
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

Merged
merged 1 commit into from
Sep 23, 2016

Conversation

eddyb
Copy link
Member

@eddyb eddyb commented Sep 22, 2016

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.

@rust-highfive
Copy link
Collaborator

r? @pnkfelix

(rust_highfive has picked a reviewer for you, use r? to override)

@pnkfelix
Copy link
Member

@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?

@eddyb
Copy link
Member Author

eddyb commented Sep 23, 2016

@pnkfelix The parser errors but it uses the keyword as an identifier and continues compilation.

@pnkfelix
Copy link
Member

@eddyb Hmm, I see. Okay. Its still pretty bizarre but I guess I don't have any solid objection.

@pnkfelix
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Sep 23, 2016

📌 Commit 795b6ad has been approved by pnkfelix

@bors
Copy link
Contributor

bors commented Sep 23, 2016

⌛ Testing commit 795b6ad with merge cb1b1ee...

bors added a commit that referenced this pull request Sep 23, 2016
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants