Skip to content

Commit ec43450

Browse files
committed
expand: simplify flat_map_item wrt. inline module detection
1 parent dc6bd6a commit ec43450

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/librustc_expand/expand.rs

+4-7
Original file line numberDiff line numberDiff line change
@@ -1383,17 +1383,14 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
13831383
_ => unreachable!(),
13841384
})
13851385
}
1386-
ast::ItemKind::Mod(ast::Mod { inner, .. }) if item.ident != Ident::invalid() => {
1386+
ast::ItemKind::Mod(ast::Mod { inner, inline, .. })
1387+
if item.ident != Ident::invalid() =>
1388+
{
13871389
let orig_directory_ownership = self.cx.current_expansion.directory_ownership;
13881390
let mut module = (*self.cx.current_expansion.module).clone();
13891391
module.mod_path.push(item.ident);
13901392

1391-
// Detect if this is an inline module (`mod m { ... }` as opposed to `mod m;`).
1392-
// In the non-inline case, `inner` is never the dummy span (cf. `parse_item_mod`).
1393-
// Thus, if `inner` is the dummy span, we know the module is inline.
1394-
let inline_module = item.span.contains(inner) || inner.is_dummy();
1395-
1396-
if inline_module {
1393+
if inline {
13971394
if let Some(path) = attr::first_attr_value_str_by_name(&item.attrs, sym::path) {
13981395
self.cx.current_expansion.directory_ownership =
13991396
DirectoryOwnership::Owned { relative: None };

0 commit comments

Comments
 (0)