derive: Implement reconstruct_path helper for cmp#4395
derive: Implement reconstruct_path helper for cmp#4395Pasta-coder wants to merge 1 commit intoRust-GCC:masterfrom
Conversation
CohenArthur
left a comment
There was a problem hiding this comment.
So I'm not necessarily against these changes, but the goal with this comment here was to do something like #3799 but for other base classes. I think we can merge this but I'd rather see the entire thing being implemented
|
thank you for the review . will modify accordingly . |
35e4800 to
84223c7
Compare
|
@CohenArthur Thanks for the review ! I've refactored the implementation to follow the established thankyou . |
84223c7 to
78363a6
Compare
c85f3df to
7e759df
Compare
This patch implements the `reconstruct` pattern for the `Path` hierarchy and its constituents (segments, generic args, qualified paths). Previously, derive expansion macros (like `derive(PartialEq)`) had to manually rebuild paths field-by-field to ensure fresh NodeIDs. This change moves that logic into the AST classes themselves, allowing paths to be deeply reconstructed uniformly. This ensures that expanded code has unique NodeIDs, which is critical for correct name resolution. gcc/rust/ChangeLog: * ast/rust-path.h (GenericArgsBinding::reconstruct): New method. (GenericArg::reconstruct): New method. (GenericArgs::reconstruct): New method. (PathExprSegment::reconstruct): New method. (PathInExpression::reconstruct): New method. (TypePathSegmentGeneric::reconstruct_impl): New method. (TypePathFunction::reconstruct): New method. (TypePathSegmentFunction::reconstruct_impl): New method. (QualifiedPathType::reconstruct): New method. (QualifiedPathInExpression::reconstruct): New method. (QualifiedPathInType::reconstruct_impl): New method. * expand/rust-derive-cmp-common.cc (EnumMatchBuilder::tuple): Use path.reconstruct(). (EnumMatchBuilder::strukt): Use path.reconstruct(). Signed-off-by: Jayant Chauhan <0001jayant@gmail.com>
7e759df to
7b27b33
Compare
|
The changes implement also tagging @powerboat9 to get reviews . thankyou . |
This patch introduces a local helper to clone
PathInExpression objects. This allows removing duplicate calls to , fulfilling the TODOs in EnumMatchBuilder.
This ensures the self and other paths are identical without reconstructing them from strings twice.
gcc/rust/ChangeLog: