From eabac1560e2f672172623bf79e1cb8b5a9d1fe98 Mon Sep 17 00:00:00 2001 From: CensoredUsername Date: Thu, 25 Apr 2024 16:22:50 +0200 Subject: [PATCH] Add a warning to Delimiter::None that rustc currently does not respect it. It does not provide the behaviour it is indicated to provide when used in a proc_macro context. This is a port of rust-lang/rust/124389. --- src/lib.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 93d7e5b..c3cf646 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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. + /// + ///
+ /// + /// 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). + /// + ///
None, }