]> git.ipfire.org Git - thirdparty/gcc.git/commit
gccrs: Add checks to ExpandVisitor
authorOwen Avery <powerboat9.gamer@gmail.com>
Sat, 9 Aug 2025 22:33:58 +0000 (18:33 -0400)
committerArthur Cohen <arthur.cohen@embecosm.com>
Thu, 30 Oct 2025 19:58:37 +0000 (20:58 +0100)
commit8c54e7eeec04a924f6ea63b51e52e24b1fdae95f
treed1fe1dc7510038cdf5e5b9bd7e26ad1521e20e56
parent94dd658d803a454c67aac12284d8cff020485310
gccrs: Add checks to ExpandVisitor

This should help detect issues like
https://github.com/Rust-GCC/gccrs/issues/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 <powerboat9.gamer@gmail.com>
gcc/rust/ast/rust-ast.h
gcc/rust/ast/rust-expr.h
gcc/rust/ast/rust-item.h
gcc/rust/expand/rust-expand-visitor.cc
gcc/rust/expand/rust-expand-visitor.h
gcc/testsuite/rust/compile/macros/mbe/macro49.rs