summaryrefslogtreecommitdiffstats
path: root/tests/ui/rust-2021/auxiliary/reserved-prefixes-macro-2018.rs
blob: eb301e5e1be32f26cabf18f39bf7d1712cc3cb43 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// 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_in_a_prefixed_integer_literal(_: TokenStream) -> TokenStream {
    TokenStream::from_str("hey#123").unwrap().into_iter().count().to_string().parse().unwrap()
}

#[proc_macro]
pub fn number_of_tokens_in_a_prefixed_char_literal(_: TokenStream) -> TokenStream {
    TokenStream::from_str("hey#'a'").unwrap().into_iter().count().to_string().parse().unwrap()
}

#[proc_macro]
pub fn number_of_tokens_in_a_prefixed_string_literal(_: TokenStream) -> TokenStream {
    TokenStream::from_str("hey#\"abc\"").unwrap().into_iter().count().to_string().parse().unwrap()
}