Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure all quote! tokens have the default Span #51

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,24 @@ pub mod __rt {

pub fn parse(tokens: &mut ::Tokens, s: &str) {
let s: TokenStream = s.parse().expect("invalid token stream");
tokens.append_all(s.into_iter());

// Reset all tokens in this iterator back to the default span to ensure
// they don't get "bogus" spans through `parse`. It was found that
// otherwise this doesn't actually work:
//
// quote! {
// mod foo {
// use super::*;
// }
// }
//
// That spits out a weird error about "there are too may initial
// `super`s". No idea why that's spit out, but ensuring that the default
// span comes out seems to fix it!
tokens.append_all(s.into_iter().map(|mut t| {
t.span = Default::default();
t
}));
}

pub fn append_kind(tokens: &mut ::Tokens, kind: TokenNode) {
Expand Down