Skip to content

Fix span collisions from PartialEq derive - #1967

Merged
ahomescu merged 2 commits into
masterfrom
ahomescu/fix_span_derive_eq_collisions
Aug 6, 2026
Merged

Fix span collisions from PartialEq derive#1967
ahomescu merged 2 commits into
masterfrom
ahomescu/fix_span_derive_eq_collisions

Conversation

@ahomescu

@ahomescu ahomescu commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Fixes #1818.

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 fw-immunant left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix makes sense to me. I'd prefer if we removed the extra copy of the explanatory comment being added to snapshots.rs.

Comment thread c2rust-refactor/tests/snapshots.rs Outdated
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
ahomescu force-pushed the ahomescu/fix_span_derive_eq_collisions branch from d1bed81 to 56f825d Compare August 6, 2026 00:04
@ahomescu
ahomescu merged commit 8fac483 into master Aug 6, 2026
11 checks passed
@ahomescu
ahomescu deleted the ahomescu/fix_span_derive_eq_collisions branch August 6, 2026 00:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactorer crashes if the processed code has derive(PartialEq, Eq)

2 participants