Skip to content

Commit b7c9aaa

Browse files
committed
gccrs: Revert "nr1.0: Remove support in expansion phase"
This reverts commit 3e52769. gcc/rust/ChangeLog: * expand/rust-macro-expand.cc (MacroExpander::expand_crate): revert * expand/rust-macro-expand.h (struct MacroExpander): likewise Signed-off-by: Philip Herron <[email protected]>
1 parent 9a44e41 commit b7c9aaa

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

gcc/rust/expand/rust-macro-expand.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,10 @@
2727
#include "rust-macro.h"
2828
#include "rust-parse.h"
2929
#include "rust-cfg-strip.h"
30+
#include "rust-early-name-resolver.h"
3031
#include "rust-proc-macro.h"
3132
#include "rust-token-tree-desugar.h"
3233

33-
// flag_assume_builtin_offset_of
34-
#include "options.h"
35-
3634
namespace Rust {
3735

3836
AST::Fragment
@@ -337,6 +335,9 @@ MacroExpander::expand_invoc (AST::MacroInvocation &invoc,
337335
void
338336
MacroExpander::expand_crate ()
339337
{
338+
NodeId scope_node_id = crate.get_node_id ();
339+
resolver->get_macro_scope ().push (scope_node_id);
340+
340341
/* fill macro/decorator map from init list? not sure where init list comes
341342
* from? */
342343

gcc/rust/expand/rust-macro-expand.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
#include "rust-ast.h"
2828
#include "rust-macro.h"
2929
#include "rust-hir-map.h"
30+
#include "rust-early-name-resolver.h"
31+
#include "rust-name-resolver.h"
3032
#include "rust-macro-invoc-lexer.h"
3133
#include "rust-proc-macro-invoc-lexer.h"
3234
#include "rust-token-converter.h"
@@ -299,7 +301,8 @@ struct MacroExpander
299301
: cfg (cfg), crate (crate), session (session),
300302
sub_stack (SubstitutionScope ()),
301303
expanded_fragment (AST::Fragment::create_error ()),
302-
has_changed_flag (false), mappings (Analysis::Mappings::get ())
304+
has_changed_flag (false), resolver (Resolver::Resolver::get ()),
305+
mappings (Analysis::Mappings::get ())
303306
{}
304307

305308
~MacroExpander () = default;
@@ -511,6 +514,7 @@ struct MacroExpander
511514
tl::optional<AST::MacroInvocation &> last_invoc;
512515

513516
public:
517+
Resolver::Resolver *resolver;
514518
Analysis::Mappings &mappings;
515519
};
516520

0 commit comments

Comments
 (0)