You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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
forIdents
compares only names (non-hygienic comparison), but panics if the contexts are different.Hash
for idents is not consistent withPartialEq
and hashes both name and context of anIdent
leading, it can lead to rare random panics ifIdent
s are used as keys inHashMap
s.One solution is to remove implementations of
PartialEq
andHash
fromIdent
and use necessary versions of comparisons explicitly.The text was updated successfully, but these errors were encountered: