gcc/rust/ChangeLog:
* rust-session-manager.cc (Session::compile_crate): Create name
resolution
context for Session::expansion and subsequent name resolution passes.
(Session::expansion): Take name resolution context as a parameter
instead.
* rust-session-manager.h (Session::expansion): Fix declaration.
---
gcc/rust/rust-session-manager.cc | 14 +++++++++-----
gcc/rust/rust-session-manager.h | 3 ++-
2 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/gcc/rust/rust-session-manager.cc b/gcc/rust/rust-session-manager.cc
index ea99d019f64..40adeb20de4 100644
--- a/gcc/rust/rust-session-manager.cc
+++ b/gcc/rust/rust-session-manager.cc
@@ -42,6 +42,7 @@
#include "rust-early-name-resolver.h"
#include "rust-name-resolution-context.h"
#include "rust-early-name-resolver-2.0.h"
+#include "rust-late-name-resolver-2.0.h"
#include "rust-cfg-strip.h"
#include "rust-expand-visitor.h"
#include "rust-unicode.h"
@@ -591,8 +592,10 @@ Session::compile_crate (const char *filename)
if (last_step == CompileOptions::CompileStep::Expansion)
return;
+ auto name_resolution_ctx = Resolver2_0::NameResolutionContext ();
// expansion pipeline stage
- expansion (parsed_crate);
+
+ expansion (parsed_crate, name_resolution_ctx);
rust_debug ("\033[0;31mSUCCESSFULLY FINISHED EXPANSION \033[0m");
if (options.dump_option_enabled (CompileOptions::EXPANSION_DUMP))
{
@@ -617,7 +620,10 @@ Session::compile_crate (const char *filename)
return;
// resolution pipeline stage
- Resolver::NameResolution::Resolve (parsed_crate);
+ if (flag_name_resolution_2_0)
+ Resolver2_0::Late (name_resolution_ctx).go (parsed_crate);
+ else
+ Resolver::NameResolution::Resolve (parsed_crate);
if (options.dump_option_enabled (CompileOptions::RESOLUTION_DUMP))
{
@@ -881,7 +887,7 @@ Session::injection (AST::Crate &crate)
}
void
-Session::expansion (AST::Crate &crate)
+Session::expansion (AST::Crate &crate, Resolver2_0::NameResolutionContext &ctx)
{
rust_debug ("started expansion");
@@ -908,8 +914,6 @@ Session::expansion (AST::Crate &crate)
if (saw_errors ())
break;
- auto ctx = Resolver2_0::NameResolutionContext ();
-
if (flag_name_resolution_2_0)
{
Resolver2_0::Early early (ctx);
diff --git a/gcc/rust/rust-session-manager.h b/gcc/rust/rust-session-manager.h
index 41aad607905..9a5691f45ee 100644
--- a/gcc/rust/rust-session-manager.h
+++ b/gcc/rust/rust-session-manager.h
@@ -24,6 +24,7 @@
#include "rust-backend.h"
#include "rust-hir-map.h"
#include "safe-ctype.h"
+#include "rust-name-resolution-context.h"
#include "config.h"
#include "rust-system.h"
@@ -413,7 +414,7 @@ private:
/* Expansion pipeline stage. TODO maybe move to another object? Expands all
* macros, maybe build test harness in future, AST validation, maybe create
* macro crate (if not rustdoc).*/
- void expansion (AST::Crate &crate);
+ void expansion (AST::Crate &crate, Resolver2_0::NameResolutionContext &ctx);
// handle cfg_option
bool handle_cfg_option (std::string &data);
--
2.45.2