From 12ca8dbb4bc22da1b93630c884b75ce254605882 Mon Sep 17 00:00:00 2001 From: Arthur Cohen Date: Thu, 15 Feb 2024 20:58:48 +0100 Subject: ast: Add base nodes for FormatArgs This commit adds a base for creating AST FormatArgs nodes after expanding invocations of `format_args!()`. These nodes will then be expanded to the proper runtime function calls (to core::fmt::rt) during the AST lowering. gcc/rust/ChangeLog: * ast/rust-builtin-ast-nodes.h: New file. * ast/rust-ast-full-decls.h (class FormatArgs): Declare new class. * ast/rust-ast-collector.cc: Handle FormatArgs nodes properly. * ast/rust-ast-collector.h: Likewise. * ast/rust-ast-full.h: Likewise. * ast/rust-ast-visitor.cc: Likewise. * ast/rust-ast-visitor.h: Likewise. * ast/rust-ast.cc: Likewise. * ast/rust-ast.h: Likewise. * expand/rust-derive.h: Likewise. * hir/rust-ast-lower-base.cc: Likewise. * hir/rust-ast-lower-base.h: Likewise. * hir/rust-ast-lower-expr.cc: Likewise. * hir/rust-ast-lower-expr.h: Likewise. * resolve/rust-ast-resolve-base.cc: Likewise. * resolve/rust-ast-resolve-base.h: Likewise. --- gcc/rust/resolve/rust-ast-resolve-base.cc | 6 ++++++ gcc/rust/resolve/rust-ast-resolve-base.h | 3 +++ 2 files changed, 9 insertions(+) (limited to 'gcc/rust/resolve') diff --git a/gcc/rust/resolve/rust-ast-resolve-base.cc b/gcc/rust/resolve/rust-ast-resolve-base.cc index c88bd58..04a0bb6 100644 --- a/gcc/rust/resolve/rust-ast-resolve-base.cc +++ b/gcc/rust/resolve/rust-ast-resolve-base.cc @@ -650,5 +650,11 @@ void ResolverBase::visit (AST::FunctionParam &) {} +void +ResolverBase::visit (AST::FormatArgs &fmt) +{ + rust_sorry_at (0, "unimplemented format_args!() visitor"); +} + } // namespace Resolver } // namespace Rust diff --git a/gcc/rust/resolve/rust-ast-resolve-base.h b/gcc/rust/resolve/rust-ast-resolve-base.h index 9bc6433..3b4d286 100644 --- a/gcc/rust/resolve/rust-ast-resolve-base.h +++ b/gcc/rust/resolve/rust-ast-resolve-base.h @@ -20,6 +20,7 @@ #define RUST_AST_RESOLVE_BASE_H #include "rust-ast-visitor.h" +#include "rust-ast.h" #include "rust-name-resolver.h" #include "rust-diagnostics.h" #include "rust-location.h" @@ -198,6 +199,8 @@ public: void visit (AST::VariadicParam ¶m); void visit (AST::SelfParam ¶m); + void visit (AST::FormatArgs &fmt); + protected: ResolverBase () : resolver (Resolver::get ()), mappings (Analysis::Mappings::get ()), -- cgit v1.1