Skip to content

Use X macros to simplify ASTVisitor inheritance #3990

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

ASTVisitor itself is left as-is for now, as a sanity check against the contents of rust-ast-visitable.h. This should slightly reduce the amount of repetition involved with inheriting from ASTVisitor, which might help us deal with the footgun that is ExpandVisitor later.

Any ideas for generally solving ExpandVisitor problems à la #3445? I suppose having ExpandVisitor inherit from ASTVisitor instead of DefaultASTVisitor might help, but it doesn't seem ideal. Maybe transforming DefaultASTVisitor into some kind of complex template so it can be specialized to operate as an in-place visitor?

ASTVisitor itself is left as-is for now, as a sanity check against the
contents of "rust-ast-visitable.h". This should slightly reduce the
amount of repetition involved with inheriting from ASTVisitor, which
might help us deal with the footgun that is ExpandVisitor later.

gcc/rust/ChangeLog:

	* ast/rust-ast-collector.h (CollectItem::visit): Use
	"rust-ast-visitable.h" to simplify visitor method declarations.
	* ast/rust-ast-visitor.h (DefaultASTVisitor::visit): Likewise.
	* ast/rust-ast-visitable.h: New file.

Signed-off-by: Owen Avery <[email protected]>
@powerboat9
Copy link
Collaborator Author

powerboat9 commented Jul 19, 2025

I came up with something awesome (in the archaic sense)

Edit: this was referring to some template metaprogramming which didn't pan out

Copy link
Member

@CohenArthur CohenArthur left a comment

Choose a reason for hiding this comment

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

at the same time I really like it and really hate it lmao. I think this is good for when we add new nodes, it will save a lot of time

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.

2 participants