Closed
Description
Spawned from #28642
There's no one true way to compare Ident
s. 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 Ident
s are used as keys in HashMap
s.
One solution is to remove implementations of PartialEq
and Hash
from Ident
and use necessary versions of comparisons explicitly.