Skip to content
Open
Show file tree
Hide file tree
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
14 changes: 7 additions & 7 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ fn main() {
println!("cargo:rustc-check-cfg=cfg(no_is_available)");
println!("cargo:rustc-check-cfg=cfg(no_literal_byte_character)");
println!("cargo:rustc-check-cfg=cfg(no_literal_c_string)");
println!("cargo:rustc-check-cfg=cfg(no_proc_macro_span_file)");
println!("cargo:rustc-check-cfg=cfg(no_source_text)");
println!("cargo:rustc-check-cfg=cfg(proc_macro_span)");
println!("cargo:rustc-check-cfg=cfg(proc_macro_span_file)");
println!("cargo:rustc-check-cfg=cfg(proc_macro_span_location)");
println!("cargo:rustc-check-cfg=cfg(procmacro2_backtrace)");
println!("cargo:rustc-check-cfg=cfg(procmacro2_build_probe)");
Expand Down Expand Up @@ -66,6 +66,12 @@ fn main() {
println!("cargo:rustc-cfg=no_literal_c_string");
}

if rustc < 88 {
// Do not call libproc_macro's Span::file and Span::local_file. Always
// return dummy values.
println!("cargo:rustc-cfg=no_proc_macro_span_file");
}

if !cfg!(feature = "proc-macro") {
println!("cargo:rerun-if-changed=build.rs");
return;
Expand Down Expand Up @@ -130,12 +136,6 @@ fn main() {
println!("cargo:rustc-cfg=proc_macro_span_location");
}

if proc_macro_span || (rustc >= 88 && compile_probe_stable("proc_macro_span_file")) {
// Enable non-dummy behavior of Span::file and Span::local_file methods
// on Rust 1.88+.
println!("cargo:rustc-cfg=proc_macro_span_file");
}

if semver_exempt && proc_macro_span {
// Implement the semver exempt API in terms of the nightly-only
// proc_macro API.
Expand Down
3 changes: 0 additions & 3 deletions src/probe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,5 @@
#[cfg(proc_macro_span)]
pub(crate) mod proc_macro_span;

#[cfg(proc_macro_span_file)]
pub(crate) mod proc_macro_span_file;

#[cfg(proc_macro_span_location)]
pub(crate) mod proc_macro_span_location;
10 changes: 0 additions & 10 deletions src/probe/proc_macro_span.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@ extern crate alloc;
extern crate proc_macro;
extern crate std;

use alloc::string::String;
use core::ops::{Range, RangeBounds};
use proc_macro::{Literal, Span};
use std::path::PathBuf;

pub fn byte_range(this: &Span) -> Range<usize> {
this.byte_range()
Expand All @@ -34,14 +32,6 @@ pub fn column(this: &Span) -> usize {
this.column()
}

pub fn file(this: &Span) -> String {
this.file()
}

pub fn local_file(this: &Span) -> Option<PathBuf> {
this.local_file()
}

pub fn join(this: &Span, other: Span) -> Option<Span> {
this.join(other)
}
Expand Down
19 changes: 0 additions & 19 deletions src/probe/proc_macro_span_file.rs

This file was deleted.

16 changes: 7 additions & 9 deletions src/wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@ use crate::fallback::{self, FromStr2 as _};
use crate::location::LineColumn;
#[cfg(proc_macro_span)]
use crate::probe::proc_macro_span;
#[cfg(all(span_locations, proc_macro_span_file))]
use crate::probe::proc_macro_span_file;
#[cfg(all(span_locations, proc_macro_span_location))]
use crate::probe::proc_macro_span_location;
use crate::{Delimiter, Punct, Spacing, TokenTree};
#[cfg(all(span_locations, not(proc_macro_span_file)))]
#[cfg(all(span_locations, no_proc_macro_span_file))]
use alloc::borrow::ToOwned as _;
use alloc::string::{String, ToString as _};
use alloc::vec::Vec;
Expand Down Expand Up @@ -472,9 +470,9 @@ impl Span {
#[cfg(span_locations)]
pub(crate) fn file(&self) -> String {
match self {
#[cfg(proc_macro_span_file)]
Span::Compiler(s) => proc_macro_span_file::file(s),
#[cfg(not(proc_macro_span_file))]
#[cfg(not(no_proc_macro_span_file))]
Span::Compiler(s) => s.file(),
#[cfg(no_proc_macro_span_file)]
Span::Compiler(_) => "<token stream>".to_owned(),
Span::Fallback(s) => s.file(),
}
Expand All @@ -483,9 +481,9 @@ impl Span {
#[cfg(span_locations)]
pub(crate) fn local_file(&self) -> Option<PathBuf> {
match self {
#[cfg(proc_macro_span_file)]
Span::Compiler(s) => proc_macro_span_file::local_file(s),
#[cfg(not(proc_macro_span_file))]
#[cfg(not(no_proc_macro_span_file))]
Span::Compiler(s) => s.local_file(),
#[cfg(no_proc_macro_span_file)]
Span::Compiler(_) => None,
Span::Fallback(s) => s.local_file(),
}
Expand Down
Loading