Skip to content

Commit

Permalink
correctly group meta list tokens using TokenTree::Group
Browse files Browse the repository at this point in the history
this should allow using newer versions of proc_macro2
  • Loading branch information
fw-immunant committed Jan 29, 2025
1 parent f106b9b commit 3b1ec86
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions c2rust-ast-builder/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -537,27 +537,19 @@ impl Builder {
let mut tokens = TokenStream::new();
let comma_token = Token![,](self.span);
let mut it = list.nested.into_iter();
tokens.extend(
Some(proc_macro2::TokenTree::Punct(proc_macro2::Punct::new(
'(',
proc_macro2::Spacing::Alone,
)))
.into_iter(),
);
if let Some(value) = it.next() {
value.to_tokens(&mut tokens);
}
for value in it {
comma_token.to_tokens(&mut tokens);
value.to_tokens(&mut tokens);
}
tokens.extend(
Some(proc_macro2::TokenTree::Punct(proc_macro2::Punct::new(
')',
proc_macro2::Spacing::Alone,
)))
.into_iter(),
);
let tokens = proc_macro2::TokenTree::Group(proc_macro2::Group::new(
proc_macro2::Delimiter::Parenthesis,
tokens,
))
.into();

PreparedMetaItem {
path: list.path,
tokens,
Expand Down

0 comments on commit 3b1ec86

Please sign in to comment.