Skip to content

Commit

Permalink
Enable span_open() and span_close() on Rust 1.55+
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Dec 5, 2021
1 parent 366c402 commit bf7f116
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 4 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ fn main() {
println!("cargo:rustc-cfg=no_literal_from_str");
}

if version.minor < 55 {
println!("cargo:rustc-cfg=no_group_open_close");
}

if version.minor < 57 {
println!("cargo:rustc-cfg=no_is_available");
}
Expand Down
8 changes: 4 additions & 4 deletions src/wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -620,19 +620,19 @@ impl Group {

pub fn span_open(&self) -> Span {
match self {
#[cfg(proc_macro_span)]
#[cfg(not(no_group_open_close))]
Group::Compiler(g) => Span::Compiler(g.span_open()),
#[cfg(not(proc_macro_span))]
#[cfg(no_group_open_close)]
Group::Compiler(g) => Span::Compiler(g.span()),
Group::Fallback(g) => Span::Fallback(g.span_open()),
}
}

pub fn span_close(&self) -> Span {
match self {
#[cfg(proc_macro_span)]
#[cfg(not(no_group_open_close))]
Group::Compiler(g) => Span::Compiler(g.span_close()),
#[cfg(not(proc_macro_span))]
#[cfg(no_group_open_close)]
Group::Compiler(g) => Span::Compiler(g.span()),
Group::Fallback(g) => Span::Fallback(g.span_close()),
}
Expand Down

0 comments on commit bf7f116

Please sign in to comment.