Skip to content

Commit 2c302b2

Browse files
authored
Rollup merge of rust-lang#82238 - petrochenkov:nocratemod, r=Aaron1011
ast: Keep expansion status for out-of-line module items I.e. whether a module `mod foo;` is already loaded from a file or not. This is a pre-requisite to correctly treating inner attributes on such modules (rust-lang#81661). With this change AST structures for `mod` items diverge even more for AST structure for the crate root, which previously used `ast::Mod`. Therefore this PR removes `ast::Mod` from `ast::Crate` in the first commit, these two things are sufficiently different from each other, at least at syntactic level. Customization points for visiting a "`mod` item or crate root" were also removed from AST visitors (`fn visit_mod`). `ast::Mod` itself was refactored away in the second commit in favor of `ItemKind::Mod(Unsafe, ModKind)`.
2 parents 6e12a2f + b185fa3 commit 2c302b2

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

clippy_lints/src/utils/ast_utils.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -241,9 +241,12 @@ pub fn eq_item_kind(l: &ItemKind, r: &ItemKind) -> bool {
241241
&& eq_generics(lg, rg)
242242
&& both(lb, rb, |l, r| eq_block(l, r))
243243
}
244-
(Mod(l), Mod(r)) => {
245-
l.inline == r.inline && over(&l.items, &r.items, |l, r| eq_item(l, r, eq_item_kind))
246-
}
244+
(Mod(lu, lmk), Mod(ru, rmk)) => lu == ru && match (lmk, rmk) {
245+
(ModKind::Loaded(litems, linline, _), ModKind::Loaded(ritems, rinline, _)) =>
246+
linline == rinline && over(litems, ritems, |l, r| eq_item(l, r, eq_item_kind)),
247+
(ModKind::Unloaded, ModKind::Unloaded) => true,
248+
_ => false,
249+
},
247250
(ForeignMod(l), ForeignMod(r)) => {
248251
both(&l.abi, &r.abi, |l, r| eq_str_lit(l, r))
249252
&& over(&l.items, &r.items, |l, r| eq_item(l, r, eq_foreign_item_kind))

0 commit comments

Comments
 (0)