diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-12-31 10:06:52 +0100 |
|---|---|---|
| committer | Mazdak Farrokhzad <twingoow@gmail.com> | 2020-02-13 11:25:34 +0100 |
| commit | ec434500157c47143a9b5600a7e34522c49f4e8e (patch) | |
| tree | f3565dcc7c2b4c9bbce4688e45db24aaec2d3c2f /src | |
| parent | dc6bd6a12347f27c937c19adfda542f694fb61c5 (diff) | |
| download | rust-ec434500157c47143a9b5600a7e34522c49f4e8e.tar.gz rust-ec434500157c47143a9b5600a7e34522c49f4e8e.zip | |
expand: simplify flat_map_item wrt. inline module detection
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc_expand/expand.rs | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/src/librustc_expand/expand.rs b/src/librustc_expand/expand.rs index ee0b7fa00de..316dd02bd95 100644 --- a/src/librustc_expand/expand.rs +++ b/src/librustc_expand/expand.rs @@ -1383,17 +1383,14 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> { _ => unreachable!(), }) } - ast::ItemKind::Mod(ast::Mod { inner, .. }) if item.ident != Ident::invalid() => { + ast::ItemKind::Mod(ast::Mod { inner, inline, .. }) + if item.ident != Ident::invalid() => + { let orig_directory_ownership = self.cx.current_expansion.directory_ownership; let mut module = (*self.cx.current_expansion.module).clone(); module.mod_path.push(item.ident); - // Detect if this is an inline module (`mod m { ... }` as opposed to `mod m;`). - // In the non-inline case, `inner` is never the dummy span (cf. `parse_item_mod`). - // Thus, if `inner` is the dummy span, we know the module is inline. - let inline_module = item.span.contains(inner) || inner.is_dummy(); - - if inline_module { + if inline { if let Some(path) = attr::first_attr_value_str_by_name(&item.attrs, sym::path) { self.cx.current_expansion.directory_ownership = DirectoryOwnership::Owned { relative: None }; |
