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

Replace Idents with Names outside of libsyntax + Idents/Names cleanup (Part 2) #28642

Merged
merged 2 commits into from
Sep 26, 2015

Conversation

petrochenkov
Copy link
Contributor

This PR removes random remaining Idents outside of libsyntax and performs general cleanup
In particular, interfaces of Name and Ident are tidied up, Names and Idents being small Copy aggregates are always passed to functions by value, and Idents are never used as keys in maps, because Ident comparisons are tricky.

Although this PR closes #6993 there's still work related to it:

  • Name can be made NonZero to compress numerous Option<Name>s and Option<Ident>s but it requires const unsafe functions.
  • Implementation of PartialEq on Ident should be eliminated and replaced with explicit hygienic, non-hygienic or member-wise comparisons.
  • Finally, large parts of AST can potentially be converted to Names in the same way as HIR to clearly separate identifiers used in hygienic and non-hygienic contexts.

r? @nrc

Make sure Name, SyntaxContext and Ident are passed by value
Make sure Idents don't serve as keys (or parts of keys) in maps, Ident comparison is not well defined
@nrc
Copy link
Member

nrc commented Sep 24, 2015

Could you file issues for the remaining work you identified please? (It sounds really useful and I wouldn't want it to be forgotten).

@nrc
Copy link
Member

nrc commented Sep 25, 2015

@bors: r+

@bors
Copy link
Contributor

bors commented Sep 25, 2015

📌 Commit f284cbc has been approved by nrc

@petrochenkov
Copy link
Contributor Author

@nrc
The issues are filed.

@bors
Copy link
Contributor

bors commented Sep 26, 2015

⌛ Testing commit f284cbc with merge 2e88c36...

bors added a commit that referenced this pull request Sep 26, 2015
This PR removes random remaining `Ident`s outside of libsyntax and performs general cleanup
In particular, interfaces of `Name` and `Ident` are tidied up, `Name`s and `Ident`s being small `Copy` aggregates are always passed to functions by value, and `Ident`s are never used as keys in maps, because `Ident` comparisons are tricky.

Although this PR closes #6993 there's still work related to it:
- `Name` can be made `NonZero` to compress numerous `Option<Name>`s and `Option<Ident>`s but it requires const unsafe functions.
- Implementation of `PartialEq` on `Ident` should be eliminated and replaced with explicit hygienic, non-hygienic or member-wise comparisons.
- Finally, large parts of AST can potentially be converted to `Name`s in the same way as HIR to clearly separate identifiers used in hygienic and non-hygienic contexts.

r? @nrc
@bors bors merged commit f284cbc into rust-lang:master Sep 26, 2015
@petrochenkov petrochenkov deleted the name3 branch September 26, 2015 21:18
@Manishearth
Copy link
Member

Why was impl<T: AsRef<str>> PartialEq<T> for Name removed?

@petrochenkov
Copy link
Contributor Author

@Manishearth
It was used in few places + making the roundtrip through the interner, required to obtain the string, a bit more explicit seemed like a good idea. Is it often needed in plugins?

@Manishearth
Copy link
Member

Yeah, but if it's doing something that should be explicit that's fine by me.

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.

After libsyntax, idents should be replaced by Names
4 participants