Remove Hash
and Eq
from AstNodeRef
for types not implementing Eq
or Hash
#16100
+44
−20
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This is a follow up to #15763 (comment)
It reverts the change to using ptr equality for
AstNodeRef
s, which in turn removes theEq
,PartialEq
, andHash
implementations forAstNodeRef
s parametrized with AST nodes.Cheap comparisons shouldn't be needed because the node field is generally marked as
[#tracked]
and#[no_eq]
and removing the implementations even enforces that thoseattributes are set on all
AstNodeRef
fields (which is good).The only downside this has is that we technically wouldn't have to mark the
Unpack::target
as#[tracked]
becausethe
target
field is accessed in every query acceptingUnpack
as an argument.Overall, enforcing the use of
#[tracked]
seems like a good trade off, espacially considering that it's very likely thatwe'd probably forget to mark the
Unpack::target
field as tracked if we add a newUnpack
query that doesn't access the target.Test Plan
cargo test