aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/resolve/rust-ast-resolve.cc
diff options
context:
space:
mode:
authorPhilip Herron <philip.herron@embecosm.com>2022-06-03 13:13:35 +0100
committerPhilip Herron <philip.herron@embecosm.com>2022-06-10 17:09:34 +0100
commitfc3ef6c4b1fad0d88a65043df8102437416b1df3 (patch)
tree2ec71d2e2b0a412ab1cc6647fd9607a13c0f51ef /gcc/rust/resolve/rust-ast-resolve.cc
parente6d32d59f1e6524df667262c509910e44151bbf2 (diff)
downloadgcc-fc3ef6c4b1fad0d88a65043df8102437416b1df3.zip
gcc-fc3ef6c4b1fad0d88a65043df8102437416b1df3.tar.gz
gcc-fc3ef6c4b1fad0d88a65043df8102437416b1df3.tar.bz2
Refactor how we track the current module scope id
This adds a module scope stack to the resolver class such that we don't have to continually update our constructors but are able to track it as part of this context class instead. Addresses #1227
Diffstat (limited to 'gcc/rust/resolve/rust-ast-resolve.cc')
-rw-r--r--gcc/rust/resolve/rust-ast-resolve.cc13
1 files changed, 11 insertions, 2 deletions
diff --git a/gcc/rust/resolve/rust-ast-resolve.cc b/gcc/rust/resolve/rust-ast-resolve.cc
index 945ff28..8465162 100644
--- a/gcc/rust/resolve/rust-ast-resolve.cc
+++ b/gcc/rust/resolve/rust-ast-resolve.cc
@@ -81,20 +81,29 @@ NameResolution::go (AST::Crate &crate)
= CanonicalPath::new_seg (scope_node_id, crate_name);
crate_prefix.set_crate_num (cnum);
+ // setup the root scope
+ resolver->push_new_module_scope (scope_node_id);
+
// first gather the top-level namespace names then we drill down so this
// allows for resolving forward declarations since an impl block might have
// a Self type Foo which is defined after the impl block for example.
for (auto it = crate.items.begin (); it != crate.items.end (); it++)
ResolveTopLevel::go (it->get (), CanonicalPath::create_empty (),
- crate_prefix, scope_node_id);
+ crate_prefix);
// FIXME remove this
if (saw_errors ())
- return;
+ {
+ resolver->pop_module_scope ();
+ return;
+ }
// next we can drill down into the items and their scopes
for (auto it = crate.items.begin (); it != crate.items.end (); it++)
ResolveItem::go (it->get (), CanonicalPath::create_empty (), crate_prefix);
+
+ // done
+ resolver->pop_module_scope ();
}
// rust-ast-resolve-struct-expr-field.h