Skip to content

Commit

Permalink
Add tests for issue 59191
Browse files Browse the repository at this point in the history
  • Loading branch information
daboross committed Feb 2, 2020
1 parent 276734d commit 410114b
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/test/ui/proc-macro/auxiliary/issue-59191.rs
@@ -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()
}
7 changes: 7 additions & 0 deletions src/test/ui/proc-macro/issue-59191-replace-root-with-fn.rs
@@ -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
@@ -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

0 comments on commit 410114b

Please sign in to comment.