Fix 59191
This adds an explicit error for when macros replace the crate root with a non-module item.
This commit is contained in:
parent
6c0b779b7b
commit
276734d6a4
1 changed files with 9 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue