]> git.lizzy.rs Git - rust.git/commitdiff
expand: simplify flat_map_item wrt. inline module detection
authorMazdak Farrokhzad <twingoow@gmail.com>
Tue, 31 Dec 2019 09:06:52 +0000 (10:06 +0100)
committerMazdak Farrokhzad <twingoow@gmail.com>
Thu, 13 Feb 2020 10:25:34 +0000 (11:25 +0100)
src/librustc_expand/expand.rs

index ee0b7fa00de261c2063ca44f56a8ce99dabdec20..316dd02bd9581154c1f89ebb0c86acfcfeacb148 100644 (file)
@@ -1383,17 +1383,14 @@ fn visit_block(&mut self, block: &mut P<Block>) {
                     _ => 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 };