Skip to content

Commit 0d9c871

Browse files
committed
add proc macro test
1 parent df9bd80 commit 0d9c871

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// force-host
2+
// edition: 2018
3+
// no-prefer-dynamic
4+
#![crate_type = "proc-macro"]
5+
6+
extern crate proc_macro;
7+
8+
use proc_macro::TokenStream;
9+
use std::str::FromStr;
10+
11+
#[proc_macro]
12+
pub fn number_of_tokens(_: TokenStream) -> TokenStream {
13+
TokenStream::from_str("c\"\"").unwrap().into_iter().count().to_string().parse().unwrap()
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// even if this crate is edition 2021, proc macros compiled using older
2+
// editions should still be able to observe the pre-2021 token behavior
3+
//
4+
// adapted from tests/ui/rust-2021/reserved-prefixes-via-macro.rs
5+
6+
// edition: 2021
7+
// check-pass
8+
9+
// aux-build: count.rs
10+
extern crate count;
11+
12+
const _: () = {
13+
assert!(count::number_of_tokens!() == 2);
14+
};
15+
16+
fn main() {}

0 commit comments

Comments
 (0)