diff options
| author | bors <bors@rust-lang.org> | 2018-09-27 09:51:12 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2018-09-27 09:51:12 +0000 |
| commit | c4501a0f1d8dade87bfcdfd0102d96fb15b93713 (patch) | |
| tree | f1a907fc1d298597d6ed81f90274006c7679f24c /src/libsyntax/parse | |
| parent | e999ebdb971a0bde03ec3fdfff901ac6613fcfa0 (diff) | |
| parent | b985e91e434a26302f06333414224422f85a1d8b (diff) | |
| download | rust-c4501a0f1d8dade87bfcdfd0102d96fb15b93713.tar.gz rust-c4501a0f1d8dade87bfcdfd0102d96fb15b93713.zip | |
Auto merge of #52319 - tinco:issue_12590, r=pnkfelix
Track whether module declarations are inline (fixes #12590) To track whether module declarations are inline I added a field `inline: bool` to `ast::Mod`. The main use case is for pretty to know whether it should render the items associated with the module, but perhaps there are use cases for this information to not be forgotten in the AST.
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 d6cbe47a66e..5571a18b596 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -6297,6 +6297,7 @@ impl<'a> Parser<'a> { Ok(ast::Mod { inner: inner_lo.to(hi), items, + inline: true }) } @@ -6334,6 +6335,7 @@ impl<'a> Parser<'a> { self.submod_path(id, &outer_attrs, id_span)?; let (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 if warn { let attr = Attribute { id: attr::mk_attr_id(), @@ -6346,9 +6348,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 { @@ -6548,7 +6554,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: "); @@ -6568,9 +6574,10 @@ impl<'a> Parser<'a> { p0.cfg_mods = self.cfg_mods; let mod_inner_lo = p0.span; let mod_attrs = p0.parse_inner_attributes()?; - let m0 = p0.parse_mod_items(&token::Eof, mod_inner_lo)?; + let mut m0 = p0.parse_mod_items(&token::Eof, mod_inner_lo)?; + m0.inline = false; 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 |
