summaryrefslogtreecommitdiffstats
path: root/library/proc_macro
diff options
context:
space:
mode:
Diffstat (limited to 'library/proc_macro')
-rw-r--r--library/proc_macro/src/lib.rs48
1 files changed, 32 insertions, 16 deletions
diff --git a/library/proc_macro/src/lib.rs b/library/proc_macro/src/lib.rs
index 7fb0d989c..83d637b68 100644
--- a/library/proc_macro/src/lib.rs
+++ b/library/proc_macro/src/lib.rs
@@ -24,7 +24,6 @@
#![feature(staged_api)]
#![feature(allow_internal_unstable)]
#![feature(decl_macro)]
-#![feature(local_key_cell_methods)]
#![feature(maybe_uninit_write_slice)]
#![feature(negative_impls)]
#![feature(new_uninit)]
@@ -33,6 +32,7 @@
#![feature(min_specialization)]
#![feature(strict_provenance)]
#![recursion_limit = "256"]
+#![cfg_attr(not(bootstrap), allow(internal_features))]
#[unstable(feature = "proc_macro_internals", issue = "27812")]
#[doc(hidden)]
@@ -177,6 +177,7 @@ impl FromStr for TokenStream {
// N.B., the bridge only provides `to_string`, implement `fmt::Display`
// based on it (the reverse of the usual relationship between the two).
+#[doc(hidden)]
#[stable(feature = "proc_macro_lib", since = "1.15.0")]
impl ToString for TokenStream {
fn to_string(&self) -> String {
@@ -738,6 +739,7 @@ impl From<Literal> for TokenTree {
// N.B., the bridge only provides `to_string`, implement `fmt::Display`
// based on it (the reverse of the usual relationship between the two).
+#[doc(hidden)]
#[stable(feature = "proc_macro_lib", since = "1.15.0")]
impl ToString for TokenTree {
fn to_string(&self) -> String {
@@ -872,6 +874,7 @@ impl Group {
// N.B., the bridge only provides `to_string`, implement `fmt::Display`
// based on it (the reverse of the usual relationship between the two).
+#[doc(hidden)]
#[stable(feature = "proc_macro_lib", since = "1.15.0")]
impl ToString for Group {
fn to_string(&self) -> String {
@@ -913,21 +916,34 @@ impl !Send for Punct {}
#[stable(feature = "proc_macro_lib2", since = "1.29.0")]
impl !Sync for Punct {}
-/// Describes whether a `Punct` is followed immediately by another `Punct` ([`Spacing::Joint`]) or
-/// by a different token or whitespace ([`Spacing::Alone`]).
+/// Indicates whether a `Punct` token can join with the following token
+/// to form a multi-character operator.
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
#[stable(feature = "proc_macro_lib2", since = "1.29.0")]
pub enum Spacing {
- /// A `Punct` is not immediately followed by another `Punct`.
- /// E.g. `+` is `Alone` in `+ =`, `+ident` and `+()`.
- #[stable(feature = "proc_macro_lib2", since = "1.29.0")]
- Alone,
- /// A `Punct` is immediately followed by another `Punct`.
- /// E.g. `+` is `Joint` in `+=` and `++`.
+ /// A `Punct` token can join with the following token to form a multi-character operator.
+ ///
+ /// In token streams constructed using proc macro interfaces `Joint` punctuation tokens can be
+ /// followed by any other tokens. \
+ /// However, in token streams parsed from source code compiler will only set spacing to `Joint`
+ /// in the following cases:
+ /// - A `Punct` is immediately followed by another `Punct` without a whitespace. \
+ /// E.g. `+` is `Joint` in `+=` and `++`.
+ /// - A single quote `'` is immediately followed by an identifier without a whitespace. \
+ /// E.g. `'` is `Joint` in `'lifetime`.
///
- /// Additionally, single quote `'` can join with identifiers to form lifetimes: `'ident`.
+ /// This list may be extended in the future to enable more token combinations.
#[stable(feature = "proc_macro_lib2", since = "1.29.0")]
Joint,
+ /// A `Punct` token cannot join with the following token to form a multi-character operator.
+ ///
+ /// `Alone` punctuation tokens can be followed by any other tokens. \
+ /// In token streams parsed from source code compiler will set spacing to `Alone` in all cases
+ /// not covered by the conditions for `Joint` above. \
+ /// E.g. `+` is `Alone` in `+ =`, `+ident` and `+()`.
+ /// In particular, token not followed by anything will also be marked as `Alone`.
+ #[stable(feature = "proc_macro_lib2", since = "1.29.0")]
+ Alone,
}
impl Punct {
@@ -959,10 +975,9 @@ impl Punct {
self.0.ch as char
}
- /// Returns the spacing of this punctuation character, indicating whether it's immediately
- /// followed by another `Punct` in the token stream, so they can potentially be combined into
- /// a multi-character operator (`Joint`), or it's followed by some other token or whitespace
- /// (`Alone`) so the operator has certainly ended.
+ /// Returns the spacing of this punctuation character, indicating whether it can be potentially
+ /// combined into a multi-character operator with the following token (`Joint`), or the operator
+ /// has certainly ended (`Alone`).
#[stable(feature = "proc_macro_lib2", since = "1.29.0")]
pub fn spacing(&self) -> Spacing {
if self.0.joint { Spacing::Joint } else { Spacing::Alone }
@@ -981,6 +996,7 @@ impl Punct {
}
}
+#[doc(hidden)]
#[stable(feature = "proc_macro_lib2", since = "1.29.0")]
impl ToString for Punct {
fn to_string(&self) -> String {
@@ -1083,8 +1099,7 @@ impl Ident {
}
}
-/// Converts the identifier to a string that should be losslessly convertible
-/// back into the same identifier.
+#[doc(hidden)]
#[stable(feature = "proc_macro_lib2", since = "1.29.0")]
impl ToString for Ident {
fn to_string(&self) -> String {
@@ -1423,6 +1438,7 @@ impl FromStr for Literal {
}
}
+#[doc(hidden)]
#[stable(feature = "proc_macro_lib2", since = "1.29.0")]
impl ToString for Literal {
fn to_string(&self) -> String {