1
Fork 0

Fix 59191

This adds an explicit error for when macros replace the crate root with
a non-module item.
This commit is contained in:
David Ross 2020-02-01 18:04:07 -08:00
parent 6c0b779b7b
commit 276734d6a4

View file

@ -363,7 +363,15 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
krate.attrs = vec![];
krate.module = ast::Mod { inner: orig_mod_span, items: vec![], inline: true };
}
_ => unreachable!(),
Some(ast::Item { span, kind, .. }) => {
self.cx.span_fatal(
span,
&format!(
"expected crate top-level item to be a module after macro expansion, found a {}",
kind.descriptive_variant()
),
);
}
};
self.cx.trace_macros_diag();
krate