rust/tests/ui/rust-2024/auxiliary/reserved-guarded-strings-macro-2024.rs
2024-10-08 18:21:16 -06:00

22 lines
612 B
Rust

//@ force-host
//@ compile-flags: -Zunstable-options
//@ edition:2024
//@ 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_in_a_guarded_string_literal(_: TokenStream) -> TokenStream {
TokenStream::from_str("#\"abc\"#").unwrap().into_iter().count().to_string().parse().unwrap()
}
#[proc_macro]
pub fn number_of_tokens_in_a_guarded_unterminated_string_literal(_: TokenStream) -> TokenStream {
TokenStream::from_str("#\"abc\"").unwrap().into_iter().count().to_string().parse().unwrap()
}