diff options
| author | bors <bors@rust-lang.org> | 2020-02-13 22:20:58 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-02-13 22:20:58 +0000 |
| commit | 10104085e4f9f52f405fa1cc5e5e18c4c4cc72d1 (patch) | |
| tree | e454e1e75dff88439e15462a257cb669b1d4c10d /src/librustc_parse/parser/module.rs | |
| parent | 5d04ce67fd14538d03fa47a2598f80d49fd564c6 (diff) | |
| parent | 7704e590ece52ef265e0ca16bce1180930b69330 (diff) | |
Auto merge of #69144 - Dylan-DPC:rollup-apt6zjj, r=Dylan-DPC
Rollup of 9 pull requests Successful merges: - #68728 (parse: merge `fn` syntax + cleanup item parsing) - #68938 (fix lifetime shadowing check in GATs) - #69057 (expand: misc cleanups and simplifications) - #69108 (Use HirId in TraitCandidate.) - #69125 (Add comment to SGX entry code) - #69126 (miri: fix exact_div) - #69127 (Enable use after scope detection in the new LLVM pass manager) - #69135 (Spelling error "represening" to "representing") - #69141 (Don't error on network failures) Failed merges: r? @ghost
Diffstat (limited to 'src/librustc_parse/parser/module.rs')
| -rw-r--r-- | src/librustc_parse/parser/module.rs | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/src/librustc_parse/parser/module.rs b/src/librustc_parse/parser/module.rs index 0c8fad03d86..754923ae55e 100644 --- a/src/librustc_parse/parser/module.rs +++ b/src/librustc_parse/parser/module.rs @@ -40,36 +40,34 @@ impl<'a> Parser<'a> { } /// Parses a `mod <foo> { ... }` or `mod <foo>;` item. - pub(super) fn parse_item_mod(&mut self, outer_attrs: &[Attribute]) -> PResult<'a, ItemInfo> { - let (in_cfg, outer_attrs) = - crate::config::process_configure_mod(self.sess, self.cfg_mods, outer_attrs); + pub(super) fn parse_item_mod(&mut self, attrs: &mut Vec<Attribute>) -> PResult<'a, ItemInfo> { + let in_cfg = crate::config::process_configure_mod(self.sess, self.cfg_mods, attrs); let id_span = self.token.span; let id = self.parse_ident()?; - if self.eat(&token::Semi) { + let (module, mut inner_attrs) = if self.eat(&token::Semi) { if in_cfg && self.recurse_into_file_modules { // This mod is in an external file. Let's go get it! let ModulePathSuccess { path, directory_ownership } = - self.submod_path(id, &outer_attrs, id_span)?; - let (module, attrs) = - self.eval_src_mod(path, directory_ownership, id.to_string(), id_span)?; - Ok((id, ItemKind::Mod(module), Some(attrs))) + self.submod_path(id, &attrs, id_span)?; + self.eval_src_mod(path, directory_ownership, id.to_string(), id_span)? } else { - let placeholder = ast::Mod { inner: DUMMY_SP, items: Vec::new(), inline: false }; - Ok((id, ItemKind::Mod(placeholder), None)) + (ast::Mod { inner: DUMMY_SP, items: Vec::new(), inline: false }, Vec::new()) } } else { let old_directory = self.directory.clone(); - self.push_directory(id, &outer_attrs); + self.push_directory(id, &attrs); self.expect(&token::OpenDelim(token::Brace))?; let mod_inner_lo = self.token.span; - let attrs = self.parse_inner_attributes()?; + let inner_attrs = self.parse_inner_attributes()?; let module = self.parse_mod_items(&token::CloseDelim(token::Brace), mod_inner_lo)?; self.directory = old_directory; - Ok((id, ItemKind::Mod(module), Some(attrs))) - } + (module, inner_attrs) + }; + attrs.append(&mut inner_attrs); + Ok((id, ItemKind::Mod(module))) } /// Given a termination token, parses all of the items in a module. |
