diff options
| author | Tinco Andringa <mail@tinco.nl> | 2018-07-11 15:19:32 +0200 |
|---|---|---|
| committer | Tinco Andringa <mail@tinco.nl> | 2018-09-10 12:33:37 +0200 |
| commit | c3afb16e1608929a816d6c0e2a0118185199aef1 (patch) | |
| tree | 65c1eeacf1972ad17c40407efd04091156aac7e1 /src/libsyntax/parse | |
| parent | b8d45da2747c0b0943f48854e653ebe0d1ba60c9 (diff) | |
| download | rust-c3afb16e1608929a816d6c0e2a0118185199aef1.tar.gz rust-c3afb16e1608929a816d6c0e2a0118185199aef1.zip | |
Track whether module declarations are inline (fixes #12590)
Diffstat (limited to 'src/libsyntax/parse')
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index f57fca2cfcf..12156522242 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -6252,6 +6252,7 @@ impl<'a> Parser<'a> { Ok(ast::Mod { inner: inner_lo.to(hi), items, + inline: true }) } @@ -6287,8 +6288,10 @@ impl<'a> Parser<'a> { // This mod is in an external file. Let's go get it! let ModulePathSuccess { path, directory_ownership, warn } = self.submod_path(id, &outer_attrs, id_span)?; - let (module, mut attrs) = + let (mut module, mut attrs) = self.eval_src_mod(path, directory_ownership, id.to_string(), id_span)?; + // Record that we fetched the mod from an external file + module.inline = false; if warn { let attr = Attribute { id: attr::mk_attr_id(), @@ -6301,9 +6304,13 @@ impl<'a> Parser<'a> { attr::mark_known(&attr); attrs.push(attr); } - Ok((id, module, Some(attrs))) + Ok((id, ItemKind::Mod(module), Some(attrs))) } else { - let placeholder = ast::Mod { inner: syntax_pos::DUMMY_SP, items: Vec::new() }; + let placeholder = ast::Mod { + inner: syntax_pos::DUMMY_SP, + items: Vec::new(), + inline: false + }; Ok((id, ItemKind::Mod(placeholder), None)) } } else { @@ -6503,7 +6510,7 @@ impl<'a> Parser<'a> { directory_ownership: DirectoryOwnership, name: String, id_sp: Span) - -> PResult<'a, (ast::ItemKind, Vec<Attribute> )> { + -> PResult<'a, (ast::Mod, Vec<Attribute> )> { let mut included_mod_stack = self.sess.included_mod_stack.borrow_mut(); if let Some(i) = included_mod_stack.iter().position(|p| *p == path) { let mut err = String::from("circular modules: "); @@ -6525,7 +6532,7 @@ impl<'a> Parser<'a> { let mod_attrs = p0.parse_inner_attributes()?; let m0 = p0.parse_mod_items(&token::Eof, mod_inner_lo)?; self.sess.included_mod_stack.borrow_mut().pop(); - Ok((ast::ItemKind::Mod(m0), mod_attrs)) + Ok((m0, mod_attrs)) } /// Parse a function declaration from a foreign module |
