diff options
| author | David Ross <daboross@daboross.net> | 2020-02-01 18:04:07 -0800 |
|---|---|---|
| committer | David Ross <daboross@daboross.net> | 2020-02-01 18:58:40 -0800 |
| commit | 276734d6a4997088b6d2e7416f5d4c07b4c8acf5 (patch) | |
| tree | 8e10593d36e6d9f81feaf5feb39fb75314d66c0b | |
| parent | 6c0b779b7bb23ad1bead914e8023642cc2368406 (diff) | |
| download | rust-276734d6a4997088b6d2e7416f5d4c07b4c8acf5.tar.gz rust-276734d6a4997088b6d2e7416f5d4c07b4c8acf5.zip | |
Fix 59191
This adds an explicit error for when macros replace the crate root with a non-module item.
| -rw-r--r-- | src/librustc_expand/expand.rs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/librustc_expand/expand.rs b/src/librustc_expand/expand.rs index ea459064b09..1aa4f11a130 100644 --- a/src/librustc_expand/expand.rs +++ b/src/librustc_expand/expand.rs @@ -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 |
