1use proc_macro2::{Group, Span, TokenStream, TokenTree};
2
3pub(crate) fn respan(stream: TokenStream, span: Span) -> TokenStream {
4 streamimpl Iterator
5 .into_iter()
6 .map(|token: TokenTree| respan_token(token, span))
7 .collect()
8}
9
10fn respan_token(mut token: TokenTree, span: Span) -> TokenTree {
11 if let TokenTree::Group(g: &mut Group) = &mut token {
12 *g = Group::new(g.delimiter(), stream:respan(g.stream(), span));
13 }
14 token.set_span(span);
15 token
16}
17