rustc_interface: Hide some hacky details of early linting from expand

This commit is contained in:
Vadim Petrochenkov
2021-02-22 19:49:09 +03:00
parent 46b67aa74d
commit da3419e18c
4 changed files with 15 additions and 11 deletions

View File

@@ -1298,7 +1298,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
ModKind::Unloaded => {
// We have an outline `mod foo;` so we need to parse the file.
let ParsedExternalMod {
items,
mut items,
inner_span,
file_path,
dir_path,
@@ -1312,14 +1312,12 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
&mut attrs,
);
let krate =
ast::Crate { attrs, items, span: inner_span, proc_macros: vec![] };
if let Some(extern_mod_loaded) = self.cx.extern_mod_loaded {
extern_mod_loaded(&krate, ident);
(attrs, items) = extern_mod_loaded(ident, attrs, items, inner_span);
}
*mod_kind = ModKind::Loaded(krate.items, Inline::No, inner_span);
item.attrs = krate.attrs;
*mod_kind = ModKind::Loaded(items, Inline::No, inner_span);
item.attrs = attrs;
// File can have inline attributes, e.g., `#![cfg(...)]` & co. => Reconfigure.
item = configure!(self, item);
(Some(file_path), dir_path, dir_ownership)