Fix span collisions from PartialEq derive - #1967
Merged
Merged
Conversation
The PartialEq derive expansion gives every generated node the span of the PartialEq token in the attribute, which crashes the NodeId -> HirId lookup with "expected TyKind::Path, got Ref(...)" (#1818). Mark the test should_panic until that is fixed.
fw-immunant
approved these changes
Aug 5, 2026
fw-immunant
left a comment
Contributor
There was a problem hiding this comment.
The fix makes sense to me. I'd prefer if we removed the extra copy of the explanatory comment being added to snapshots.rs.
The span- and context-based maps used by opt_node_to_hir_id keep only the last node inserted under each key, so same-span siblings (e.g. the signature types of a derive-generated `fn eq`) all resolved to the one surviving HirId. Only trust a lookup if the AST-side reverse map returns the same NodeId; otherwise return None so callers skip the node. The rename_unnamed derive(PartialEq, Eq) test now passes instead of panicking, so drop its should_panic and add its snapshot. Fixes #1818
ahomescu
force-pushed
the
ahomescu/fix_span_derive_eq_collisions
branch
from
August 6, 2026 00:04
d1bed81 to
56f825d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #1818.