Add tests for issue 59191

This commit is contained in:
David Ross 2020-02-01 18:07:26 -08:00
parent 276734d6a4
commit 410114b9d2
3 changed files with 31 additions and 0 deletions

View file

@ -0,0 +1,16 @@
// edition:2018
// force-host
// no-prefer-dynamic
#![crate_type = "proc-macro"]
extern crate proc_macro;
use proc_macro::TokenStream;
#[proc_macro_attribute]
pub fn no_main(_attrs: TokenStream, _input: TokenStream) -> TokenStream {
let new_krate = r#"
fn main() {}
"#;
new_krate.parse().unwrap()
}

View file

@ -0,0 +1,7 @@
// edition:2018
// aux-crate:issue_59191=issue-59191.rs
// Test that using a macro to replace the entire crate tree with a non-'mod' item errors out nicely.
// `issue_59191::no_main` replaces whatever's passed in with `fn main() {}`.
#![feature(custom_inner_attributes)]
#![issue_59191::no_main]
//~^ ERROR expected crate top-level item to be a module after macro expansion, found a function

View file

@ -0,0 +1,8 @@
error: expected crate top-level item to be a module after macro expansion, found a function
--> $DIR/issue-59191-replace-root-with-fn.rs:6:1
|
LL | #![issue_59191::no_main]
| ^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error