Skip to content

Commit

Permalink
Delete needs_invalid_span_woraround config for rustc older than 1.53
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Jul 16, 2023
1 parent 67b54a8 commit 8a3481b
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 18 deletions.
7 changes: 1 addition & 6 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,10 @@ use std::str;
fn main() {
println!("cargo:rerun-if-changed=build.rs");

let version = match rustc_version() {
let _version = match rustc_version() {
Some(version) => version,
None => return,
};

if version.minor < 53 {
// https://github.com/rust-lang/rust/issues/43081
println!("cargo:rustc-cfg=needs_invalid_span_workaround");
}
}

struct RustcVersion {
Expand Down
12 changes: 0 additions & 12 deletions src/spanned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,8 @@ impl<T: ?Sized + ToTokens> Spanned for T {
}

fn join_spans(tokens: TokenStream) -> Span {
#[cfg(not(needs_invalid_span_workaround))]
let mut iter = tokens.into_iter().map(|tt| tt.span());

#[cfg(needs_invalid_span_workaround)]
let mut iter = tokens.into_iter().filter_map(|tt| {
let span = tt.span();
let debug = format!("{:?}", span);
if debug.ends_with("bytes(0..0)") {
None
} else {
Some(span)
}
});

let first = match iter.next() {
Some(span) => span,
None => return Span::call_site(),
Expand Down

0 comments on commit 8a3481b

Please sign in to comment.