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

libsyntax: Implementation of PartialEq on Ident is not well behaved #28658

Closed
petrochenkov opened this issue Sep 25, 2015 · 0 comments
Closed
Labels
A-parser Area: The parsing of Rust source code to an AST.

Comments

@petrochenkov
Copy link
Contributor

Spawned from #28642

There's no one true way to compare Idents. They can be compared non-hygienically (id1.name == id2.name), hygienically (mtwt::resolve(id1) == mtwt::resolve(id2)), or even member-wise (id1.name == id2.name && id1.ctxt== id2.ctxt) depending on the situation.
Currently PartialEq for Idents compares only names (non-hygienic comparison), but panics if the contexts are different. Hash for idents is not consistent with PartialEq and hashes both name and context of an Ident leading, it can lead to rare random panics if Idents are used as keys in HashMaps.
One solution is to remove implementations of PartialEq and Hash from Ident and use necessary versions of comparisons explicitly.

@steveklabnik steveklabnik added the A-parser Area: The parsing of Rust source code to an AST. label Sep 28, 2015
bors added a commit that referenced this issue Oct 6, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-parser Area: The parsing of Rust source code to an AST.
Projects
None yet
Development

No branches or pull requests

2 participants