Skip to content

Delete use of proc_macro::Span::before/after #391

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

Merged
merged 1 commit into from
Jun 8, 2023
Merged
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
5 changes: 1 addition & 4 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,7 @@ fn main() {
println!("cargo:rustc-cfg=wrap_proc_macro");
}

if version.nightly
&& feature_allowed("proc_macro_span")
&& feature_allowed("proc_macro_span_shrink")
{
if version.nightly && feature_allowed("proc_macro_span") {
println!("cargo:rustc-cfg=proc_macro_span");
}

Expand Down
20 changes: 0 additions & 20 deletions src/fallback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -541,26 +541,6 @@ impl Span {
})
}

#[cfg(procmacro2_semver_exempt)]
pub fn before(&self) -> Span {
Span {
#[cfg(span_locations)]
lo: self.lo,
#[cfg(span_locations)]
hi: self.lo,
}
}

#[cfg(procmacro2_semver_exempt)]
pub fn after(&self) -> Span {
Span {
#[cfg(span_locations)]
lo: self.hi,
#[cfg(span_locations)]
hi: self.hi,
}
}

#[cfg(not(span_locations))]
pub fn join(&self, _other: Span) -> Option<Span> {
Some(Span {})
Expand Down
23 changes: 1 addition & 22 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,7 @@

// Proc-macro2 types in rustdoc of other crates get linked to here.
#![doc(html_root_url = "https://docs.rs/proc-macro2/1.0.59")]
#![cfg_attr(
any(proc_macro_span, super_unstable),
feature(proc_macro_span, proc_macro_span_shrink)
)]
#![cfg_attr(any(proc_macro_span, super_unstable), feature(proc_macro_span))]
#![cfg_attr(super_unstable, feature(proc_macro_def_site))]
#![cfg_attr(doc_cfg, feature(doc_cfg))]
#![allow(
Expand Down Expand Up @@ -494,24 +491,6 @@ impl Span {
self.inner.end()
}

/// Creates an empty span pointing to directly before this span.
///
/// This method is semver exempt and not exposed by default.
#[cfg(all(procmacro2_semver_exempt, any(not(wrap_proc_macro), super_unstable)))]
#[cfg_attr(doc_cfg, doc(cfg(procmacro2_semver_exempt)))]
pub fn before(&self) -> Span {
Span::_new(self.inner.before())
}

/// Creates an empty span pointing to directly after this span.
///
/// This method is semver exempt and not exposed by default.
#[cfg(all(procmacro2_semver_exempt, any(not(wrap_proc_macro), super_unstable)))]
#[cfg_attr(doc_cfg, doc(cfg(procmacro2_semver_exempt)))]
pub fn after(&self) -> Span {
Span::_new(self.inner.after())
}

/// Create a new span encompassing `self` and `other`.
///
/// Returns `None` if `self` and `other` are from different files.
Expand Down
16 changes: 0 additions & 16 deletions src/wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -483,22 +483,6 @@ impl Span {
}
}

#[cfg(super_unstable)]
pub fn before(&self) -> Span {
match self {
Span::Compiler(s) => Span::Compiler(s.before()),
Span::Fallback(s) => Span::Fallback(s.before()),
}
}

#[cfg(super_unstable)]
pub fn after(&self) -> Span {
match self {
Span::Compiler(s) => Span::Compiler(s.after()),
Span::Fallback(s) => Span::Fallback(s.after()),
}
}

pub fn join(&self, other: Span) -> Option<Span> {
let ret = match (self, other) {
#[cfg(proc_macro_span)]
Expand Down