1 // SPDX-License-Identifier: GPL-2.0
3 use proc_macro::{token_stream, Ident, TokenStream, TokenTree};
5 use crate::helpers::expect_punct;
7 fn expect_ident(it: &mut token_stream::IntoIter) -> Ident {
8 if let Some(TokenTree::Ident(ident)) = it.next() {
11 panic!("Expected Ident")
15 pub(crate) fn concat_idents(ts: TokenStream) -> TokenStream {
16 let mut it = ts.into_iter();
17 let a = expect_ident(&mut it);
18 assert_eq!(expect_punct(&mut it), ',');
19 let b = expect_ident(&mut it);
20 assert!(it.next().is_none(), "only two idents can be concatenated");
21 let res = Ident::new(&format!("{a}{b}"), b.span());
22 TokenStream::from_iter([TokenTree::Ident(res)])