rustc_lint: Stop creating a fake ast::Crate for running early lints

Add a trait generalizing over the crate root and freshly loaded modules instead
This also makes node IDs used for pre-expansion linting more precise
This commit is contained in:
Vadim Petrochenkov 2021-12-07 18:28:12 +08:00
parent 9c70b6d11b
commit 05cd75504b
5 changed files with 85 additions and 26 deletions

View file

@ -1108,7 +1108,12 @@ impl InvocationCollectorNode for P<ast::Item> {
);
if let Some(extern_mod_loaded) = ecx.extern_mod_loaded {
(attrs, items) = extern_mod_loaded(ident, attrs, items, inner_span);
(attrs, items) = extern_mod_loaded(
ecx.current_expansion.lint_node_id,
attrs,
items,
ident.name,
);
}
*mod_kind = ModKind::Loaded(items, Inline::No, inner_span);