add proc macro test
This commit is contained in:
parent
df9bd80d74
commit
0d9c871736
14
tests/ui/rfcs/rfc-3348-c-string-literals/auxiliary/count.rs
Normal file
14
tests/ui/rfcs/rfc-3348-c-string-literals/auxiliary/count.rs
Normal file
@ -0,0 +1,14 @@
|
||||
// force-host
|
||||
// edition: 2018
|
||||
// no-prefer-dynamic
|
||||
#![crate_type = "proc-macro"]
|
||||
|
||||
extern crate proc_macro;
|
||||
|
||||
use proc_macro::TokenStream;
|
||||
use std::str::FromStr;
|
||||
|
||||
#[proc_macro]
|
||||
pub fn number_of_tokens(_: TokenStream) -> TokenStream {
|
||||
TokenStream::from_str("c\"\"").unwrap().into_iter().count().to_string().parse().unwrap()
|
||||
}
|
16
tests/ui/rfcs/rfc-3348-c-string-literals/edition-spans.rs
Normal file
16
tests/ui/rfcs/rfc-3348-c-string-literals/edition-spans.rs
Normal file
@ -0,0 +1,16 @@
|
||||
// even if this crate is edition 2021, proc macros compiled using older
|
||||
// editions should still be able to observe the pre-2021 token behavior
|
||||
//
|
||||
// adapted from tests/ui/rust-2021/reserved-prefixes-via-macro.rs
|
||||
|
||||
// edition: 2021
|
||||
// check-pass
|
||||
|
||||
// aux-build: count.rs
|
||||
extern crate count;
|
||||
|
||||
const _: () = {
|
||||
assert!(count::number_of_tokens!() == 2);
|
||||
};
|
||||
|
||||
fn main() {}
|
Loading…
Reference in New Issue
Block a user