aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/parse/rust-parse-impl.h
diff options
context:
space:
mode:
authorBen Boeckel <mathstuf@gmail.com>2021-10-31 19:59:37 -0400
committerBen Boeckel <mathstuf@gmail.com>2021-11-03 07:09:01 -0400
commit1657ee53d578d68c7d807312b1063ffd804d7ef9 (patch)
tree502c1c87dc290c7301907a46791c4b2996697cbb /gcc/rust/parse/rust-parse-impl.h
parent09af9b16b436606fa8ced0aa6cc111555bdc3da7 (diff)
downloadgcc-1657ee53d578d68c7d807312b1063ffd804d7ef9.zip
gcc-1657ee53d578d68c7d807312b1063ffd804d7ef9.tar.gz
gcc-1657ee53d578d68c7d807312b1063ffd804d7ef9.tar.bz2
rust: track inline module scopes for module file resolution
The set of inline modules is required to find the expected location of a module file. Track this information with an RAII object (`InlineModuleStackScope`) and pass it down to any out-of-line modules so that, when requested, the set of inline modules can be added to the search path. Signed-off-by: Ben Boeckel <mathstuf@gmail.com>
Diffstat (limited to 'gcc/rust/parse/rust-parse-impl.h')
-rw-r--r--gcc/rust/parse/rust-parse-impl.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h
index 52aba4f..7f0db1b 100644
--- a/gcc/rust/parse/rust-parse-impl.h
+++ b/gcc/rust/parse/rust-parse-impl.h
@@ -2104,14 +2104,18 @@ Parser<ManagedTokenSource>::parse_module (AST::Visibility vis,
// Construct an external module
return std::unique_ptr<AST::Module> (
new AST::Module (std::move (name), std::move (vis),
- std::move (outer_attrs), locus,
- lexer.get_filename ()));
+ std::move (outer_attrs), locus, lexer.get_filename (),
+ inline_module_stack));
case LEFT_CURLY: {
lexer.skip_token ();
// parse inner attributes
AST::AttrVec inner_attrs = parse_inner_attributes ();
+ std::string module_path_name
+ = extract_module_path (inner_attrs, outer_attrs, name);
+ InlineModuleStackScope scope (*this, std::move (module_path_name));
+
// parse items
std::vector<std::unique_ptr<AST::Item>> items;
const_TokenPtr tok = lexer.peek_token ();