Skip to content

Conversation

powerboat9
Copy link
Collaborator

This should help detect issues like #3444

This should help detect issues like
Rust-GCC#3444.

gcc/rust/ChangeLog:

	* ast/rust-ast.h (Stmt::get_node_id): Make virtual.
	(Type::get_node_id): Likewise.
	(AssociatedItem::get_node_id): New virtual member function.
	* ast/rust-expr.h (TypeCastExpr::get_casted_expr_ptr): New
	member function.
	(TypeCastExpr::get_type_to_cast_to_ptr): Likewise.
	(ClosureExprInner::get_definition_expr_ptr): Likewise.
	* ast/rust-item.h (TypeAlias::get_node_id): New member function
	to override AssociatedItem::get_node_id.
	(ConstantItem::get_node_id): Likewise.
	* expand/rust-expand-visitor.cc
	(ExpandVisitor::maybe_expand_expr): Adjust
	macro_invoc_expect_id.
	(ExpandVisitor::maybe_expand_type): Likewise and add an overload
	for std::unique_ptr<TypeNoBounds>.
	(ExpandVisitor::visit): Check macro_invoc_expect_id and
	generally improve visitors so that the testsuite will still
	pass.
	* expand/rust-expand-visitor.h (ExpandVisitor::ExpandVisitor):
	Initialize member variable macro_invoc_expect_id.
	(ExpandVisitor::maybe_expand_type): Add an overload for
	std::unique_ptr<TypeNoBounds>.
	(ExpandVisitor::expand_macro_children): Adjust
	macro_invoc_expect_id.
	(ExpandVisitor::visit): Add an overload for TypeCastExpr.
	(ExpandVisitor::macro_invoc_expect_id): New member variable.

gcc/testsuite/ChangeLog:

	* rust/compile/macros/mbe/macro49.rs: Add missing lang items.

Signed-off-by: Owen Avery <[email protected]>
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.

this looks good to me, thanks! note that I think it would be worth reworking this visitor to have a more generic "ExternalVisitor" framework which can replace pointers like we do here and in the desugars

@CohenArthur CohenArthur added this pull request to the merge queue Aug 11, 2025
Merged via the queue into Rust-GCC:master with commit 5b7a0d7 Aug 11, 2025
13 checks passed
@powerboat9 powerboat9 deleted the check-expand-2 branch August 11, 2025 12:52
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