Skip to content

Commit 410114b

Browse files
committed
Add tests for issue 59191
1 parent 276734d commit 410114b

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// edition:2018
2+
// force-host
3+
// no-prefer-dynamic
4+
5+
#![crate_type = "proc-macro"]
6+
7+
extern crate proc_macro;
8+
use proc_macro::TokenStream;
9+
10+
#[proc_macro_attribute]
11+
pub fn no_main(_attrs: TokenStream, _input: TokenStream) -> TokenStream {
12+
let new_krate = r#"
13+
fn main() {}
14+
"#;
15+
new_krate.parse().unwrap()
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// edition:2018
2+
// aux-crate:issue_59191=issue-59191.rs
3+
// Test that using a macro to replace the entire crate tree with a non-'mod' item errors out nicely.
4+
// `issue_59191::no_main` replaces whatever's passed in with `fn main() {}`.
5+
#![feature(custom_inner_attributes)]
6+
#![issue_59191::no_main]
7+
//~^ ERROR expected crate top-level item to be a module after macro expansion, found a function
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
error: expected crate top-level item to be a module after macro expansion, found a function
2+
--> $DIR/issue-59191-replace-root-with-fn.rs:6:1
3+
|
4+
LL | #![issue_59191::no_main]
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^
6+
7+
error: aborting due to previous error
8+

0 commit comments

Comments
 (0)