From facc69f654b002c54509d206b71720be654934e3 Mon Sep 17 00:00:00 2001 From: Kevin Mehall Date: Sun, 17 May 2020 23:34:21 -0700 Subject: [PATCH] Stabilize Span::resolved_at + Span::located_at with `hygiene` feature These were stabilized in Rust in https://github.com/rust-lang/rust/pull/69041 --- Cargo.toml | 1 + src/fallback.rs | 4 ++-- src/lib.rs | 8 ++++---- src/wrapper.rs | 4 ++-- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 779dc496..e0926cd8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,6 +36,7 @@ default = ["proc-macro"] # of a token. span-locations = [] +# Span::mixed_site, Span::resolved_at, and Span::located_at. Requires rustc 1.45+ hygiene = [] # This feature no longer means anything. diff --git a/src/fallback.rs b/src/fallback.rs index 554c87ea..c49460f0 100644 --- a/src/fallback.rs +++ b/src/fallback.rs @@ -384,7 +384,7 @@ impl Span { Span::call_site() } - #[cfg(procmacro2_semver_exempt)] + #[cfg(hygiene)] pub fn resolved_at(&self, _other: Span) -> Span { // Stable spans consist only of line/column information, so // `resolved_at` and `located_at` only select which span the @@ -392,7 +392,7 @@ impl Span { *self } - #[cfg(procmacro2_semver_exempt)] + #[cfg(hygiene)] pub fn located_at(&self, other: Span) -> Span { other } diff --git a/src/lib.rs b/src/lib.rs index 4deb30bb..57d34f0e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -371,8 +371,8 @@ impl Span { /// Creates a new span with the same line/column information as `self` but /// that resolves symbols as though it were at `other`. /// - /// This method is semver exempt and not exposed by default. - #[cfg(procmacro2_semver_exempt)] + /// This method requires the `"hygiene"` feature to be enabled. + #[cfg(hygiene)] pub fn resolved_at(&self, other: Span) -> Span { Span::_new(self.inner.resolved_at(other.inner)) } @@ -380,8 +380,8 @@ impl Span { /// Creates a new span with the same name resolution behavior as `self` but /// with the line/column information of `other`. /// - /// This method is semver exempt and not exposed by default. - #[cfg(procmacro2_semver_exempt)] + /// This method requires the `"hygiene"` feature to be enabled. + #[cfg(hygiene)] pub fn located_at(&self, other: Span) -> Span { Span::_new(self.inner.located_at(other.inner)) } diff --git a/src/wrapper.rs b/src/wrapper.rs index f9429b7b..8ea98efa 100644 --- a/src/wrapper.rs +++ b/src/wrapper.rs @@ -394,7 +394,7 @@ impl Span { } } - #[cfg(super_unstable)] + #[cfg(hygiene)] pub fn resolved_at(&self, other: Span) -> Span { match (self, other) { (Span::Compiler(a), Span::Compiler(b)) => Span::Compiler(a.resolved_at(b)), @@ -403,7 +403,7 @@ impl Span { } } - #[cfg(super_unstable)] + #[cfg(hygiene)] pub fn located_at(&self, other: Span) -> Span { match (self, other) { (Span::Compiler(a), Span::Compiler(b)) => Span::Compiler(a.located_at(b)),