summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/extra.rs2
-rw-r--r--src/fallback.rs10
-rw-r--r--src/lib.rs36
-rw-r--r--src/location.rs2
4 files changed, 31 insertions, 19 deletions
diff --git a/src/extra.rs b/src/extra.rs
index 543ec1d..522a90e 100644
--- a/src/extra.rs
+++ b/src/extra.rs
@@ -69,7 +69,7 @@ use core::fmt::{self, Debug};
/// This function is not applicable to and will panic if called from a
/// procedural macro.
#[cfg(span_locations)]
-#[cfg_attr(doc_cfg, doc(cfg(feature = "span-locations")))]
+#[cfg_attr(docsrs, doc(cfg(feature = "span-locations")))]
pub fn invalidate_current_thread_spans() {
crate::imp::invalidate_current_thread_spans();
}
diff --git a/src/fallback.rs b/src/fallback.rs
index b42537b..2d1c991 100644
--- a/src/fallback.rs
+++ b/src/fallback.rs
@@ -781,7 +781,7 @@ impl Debug for Group {
#[derive(Clone)]
pub(crate) struct Ident {
- sym: String,
+ sym: Box<str>,
span: Span,
raw: bool,
}
@@ -795,7 +795,7 @@ impl Ident {
pub fn new_unchecked(string: &str, span: Span) -> Self {
Ident {
- sym: string.to_owned(),
+ sym: Box::from(string),
span,
raw: false,
}
@@ -809,7 +809,7 @@ impl Ident {
pub fn new_raw_unchecked(string: &str, span: Span) -> Self {
Ident {
- sym: string.to_owned(),
+ sym: Box::from(string),
span,
raw: true,
}
@@ -886,9 +886,9 @@ where
fn eq(&self, other: &T) -> bool {
let other = other.as_ref();
if self.raw {
- other.starts_with("r#") && self.sym == other[2..]
+ other.starts_with("r#") && *self.sym == other[2..]
} else {
- self.sym == other
+ *self.sym == *other
}
}
}
diff --git a/src/lib.rs b/src/lib.rs
index 93d7e5b..02e9857 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -86,10 +86,10 @@
//! a different thread.
// Proc-macro2 types in rustdoc of other crates get linked to here.
-#![doc(html_root_url = "https://docs.rs/proc-macro2/1.0.81")]
+#![doc(html_root_url = "https://docs.rs/proc-macro2/1.0.85")]
#![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))]
+#![cfg_attr(docsrs, feature(doc_cfg))]
#![deny(unsafe_op_in_unsafe_fn)]
#![allow(
clippy::cast_lossless,
@@ -175,7 +175,7 @@ use std::ffi::CStr;
use std::path::PathBuf;
#[cfg(span_locations)]
-#[cfg_attr(doc_cfg, doc(cfg(feature = "span-locations")))]
+#[cfg_attr(docsrs, doc(cfg(feature = "span-locations")))]
pub use crate::location::LineColumn;
/// An abstract stream of tokens, or more concretely a sequence of token trees.
@@ -252,7 +252,7 @@ impl FromStr for TokenStream {
}
#[cfg(feature = "proc-macro")]
-#[cfg_attr(doc_cfg, doc(cfg(feature = "proc-macro")))]
+#[cfg_attr(docsrs, doc(cfg(feature = "proc-macro")))]
impl From<proc_macro::TokenStream> for TokenStream {
fn from(inner: proc_macro::TokenStream) -> Self {
TokenStream::_new(inner.into())
@@ -260,7 +260,7 @@ impl From<proc_macro::TokenStream> for TokenStream {
}
#[cfg(feature = "proc-macro")]
-#[cfg_attr(doc_cfg, doc(cfg(feature = "proc-macro")))]
+#[cfg_attr(docsrs, doc(cfg(feature = "proc-macro")))]
impl From<TokenStream> for proc_macro::TokenStream {
fn from(inner: TokenStream) -> Self {
inner.inner.into()
@@ -339,7 +339,7 @@ impl Error for LexError {}
///
/// This type 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)))]
+#[cfg_attr(docsrs, doc(cfg(procmacro2_semver_exempt)))]
#[derive(Clone, PartialEq, Eq)]
pub struct SourceFile {
inner: imp::SourceFile,
@@ -428,7 +428,7 @@ impl Span {
///
/// This method is semver exempt and not exposed by default.
#[cfg(procmacro2_semver_exempt)]
- #[cfg_attr(doc_cfg, doc(cfg(procmacro2_semver_exempt)))]
+ #[cfg_attr(docsrs, doc(cfg(procmacro2_semver_exempt)))]
pub fn def_site() -> Self {
Span::_new(imp::Span::def_site())
}
@@ -471,7 +471,7 @@ impl 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)))]
+ #[cfg_attr(docsrs, doc(cfg(procmacro2_semver_exempt)))]
pub fn source_file(&self) -> SourceFile {
SourceFile::_new(self.inner.source_file())
}
@@ -486,7 +486,7 @@ impl Span {
/// procedural macro, such as main.rs or build.rs, the byte range is always
/// accurate regardless of toolchain.
#[cfg(span_locations)]
- #[cfg_attr(doc_cfg, doc(cfg(feature = "span-locations")))]
+ #[cfg_attr(docsrs, doc(cfg(feature = "span-locations")))]
pub fn byte_range(&self) -> Range<usize> {
self.inner.byte_range()
}
@@ -501,7 +501,7 @@ impl Span {
/// outside of a procedural macro, such as main.rs or build.rs, the
/// line/column are always meaningful regardless of toolchain.
#[cfg(span_locations)]
- #[cfg_attr(doc_cfg, doc(cfg(feature = "span-locations")))]
+ #[cfg_attr(docsrs, doc(cfg(feature = "span-locations")))]
pub fn start(&self) -> LineColumn {
self.inner.start()
}
@@ -516,7 +516,7 @@ impl Span {
/// outside of a procedural macro, such as main.rs or build.rs, the
/// line/column are always meaningful regardless of toolchain.
#[cfg(span_locations)]
- #[cfg_attr(doc_cfg, doc(cfg(feature = "span-locations")))]
+ #[cfg_attr(docsrs, doc(cfg(feature = "span-locations")))]
pub fn end(&self) -> LineColumn {
self.inner.end()
}
@@ -538,7 +538,7 @@ impl Span {
///
/// This method is semver exempt and not exposed by default.
#[cfg(procmacro2_semver_exempt)]
- #[cfg_attr(doc_cfg, doc(cfg(procmacro2_semver_exempt)))]
+ #[cfg_attr(docsrs, doc(cfg(procmacro2_semver_exempt)))]
pub fn eq(&self, other: &Span) -> bool {
self.inner.eq(&other.inner)
}
@@ -685,6 +685,18 @@ pub enum Delimiter {
/// operator priorities in cases like `$var * 3` where `$var` is `1 + 2`.
/// Invisible delimiters may not survive roundtrip of a token stream through
/// a string.
+ ///
+ /// <div class="warning">
+ ///
+ /// Note: rustc currently can ignore the grouping of tokens delimited by `None` in the output
+ /// of a proc_macro. Only `None`-delimited groups created by a macro_rules macro in the input
+ /// of a proc_macro macro are preserved, and only in very specific circumstances.
+ /// Any `None`-delimited groups (re)created by a proc_macro will therefore not preserve
+ /// operator priorities as indicated above. The other `Delimiter` variants should be used
+ /// instead in this context. This is a rustc bug. For details, see
+ /// [rust-lang/rust#67062](https://github.com/rust-lang/rust/issues/67062).
+ ///
+ /// </div>
None,
}
diff --git a/src/location.rs b/src/location.rs
index 463026c..7190e2d 100644
--- a/src/location.rs
+++ b/src/location.rs
@@ -3,7 +3,7 @@ use core::cmp::Ordering;
/// A line-column pair representing the start or end of a `Span`.
///
/// This type is semver exempt and not exposed by default.
-#[cfg_attr(doc_cfg, doc(cfg(feature = "span-locations")))]
+#[cfg_attr(docsrs, doc(cfg(feature = "span-locations")))]
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
pub struct LineColumn {
/// The 1-indexed line in the source file on which the span starts or ends