dtolnay / quote

Rust quasi-quoting

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Consider removing invalid span workaround form `join_spans`

mystor opened this issue · comments

In the internal join_spans function, there is some old code which filters out invalid tokens from the input stream by debug-printing the Span object, and inspecting the output.

quote/src/spanned.rs

Lines 21 to 32 in 7d5d360

let mut iter = tokens.into_iter().filter_map(|tt| {
// FIXME: This shouldn't be required, since optimally spans should
// never be invalid. This filter_map can probably be removed when
// https://github.com/rust-lang/rust/issues/43081 is resolved.
let span = tt.span();
let debug = format!("{:?}", span);
if debug.ends_with("bytes(0..0)") {
None
} else {
Some(span)
}
});

Given that rust-lang/rust#43081 appears to have been fixed for a bit over a year (rust-lang/rust#43081 (comment)), perhaps this code could be disabled on versions with the fix (appears to be rustc 1.53+)?