Skip to content

Fix some duplicate node id issues #3787

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

powerboat9
Copy link
Collaborator

No description provided.

gcc/rust/ChangeLog:

	* ast/rust-ast.h
	(Type::reset_node_id): New member function.
	* ast/rust-path.h
	(TypePathSegment::reset_node_id): New member function.
	* expand/rust-node-id-fix-visitor.cc: New file.
	* expand/rust-node-id-fix-visitor.h: New file.
	* Make-lang.in: Add rust-node-id-fix-visitor.o.
	* expand/rust-derive-default.cc: Include
	"rust-node-id-fix-visitor.h".
	(DeriveDefault::visit_struct): Use NodeIdFixVisitor::fix.
	(DeriveDefault::visit_tuple): Likewise.
	* expand/rust-derive-eq.cc: Include
	"rust-node-id-fix-visitor.h".
	(DeriveEq::go): Use NodeIdFixVisitor::fix.

gcc/testsuite/ChangeLog:

	* rust/compile/nr2/exclude: Remove entries.

Signed-off-by: Owen Avery <[email protected]>
@powerboat9 powerboat9 requested review from CohenArthur, P-E-P and philberty and removed request for CohenArthur and P-E-P May 9, 2025 16:21
@philberty
Copy link
Member

Hmm this smells like the a derive/desguar is cloning a node-id they should have unique ones. We've had these issues before early on.

@philberty
Copy link
Member

It would be better if we can drill down in on where these dups are comming from rather than add a pass to fix them

@powerboat9
Copy link
Collaborator Author

It looks like the duplication is mostly coming from clone_type calls, and it seems like other callers depend on clone_type preserving node id

@philberty
Copy link
Member

Hmm yeah need to see why thats being called that rings a bell from a good while back... do you mind if i take a look into this too

@philberty
Copy link
Member

Oh wait i think i see what you mean a bit more...

@philberty
Copy link
Member

i found the fixes for this: #3792

We actually have a few stray clones going on that need fixed. I think its better to finish filling out the builder than making a new pass to add new getters/setters on the AST.

Copy link
Member

@P-E-P P-E-P left a comment

Choose a reason for hiding this comment

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

I agree with @philberty, you're treating the symptoms rather than the disease. Those node ids shouldn't have been duplicated in the first place.

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.

3 participants