about summary refs log tree commit diff
diff options
context:
space:
mode:
authorVadim Petrochenkov <vadim.petrochenkov@gmail.com>2022-04-01 23:54:05 +0300
committerVadim Petrochenkov <vadim.petrochenkov@gmail.com>2022-04-02 00:09:34 +0300
commita150fc2990bb89d804761f64d2ce3cf497b7fc81 (patch)
tree8ab913e9b0889a99e4a47233567b21a116f93c6d
parent297a8018b525c28ef10ee6a91d61954839b508b9 (diff)
downloadrust-a150fc2990bb89d804761f64d2ce3cf497b7fc81.tar.gz
rust-a150fc2990bb89d804761f64d2ce3cf497b7fc81.zip
ast_lowering: Stop wrapping `ident` matchers into groups
The lowered forms goes to metadata, for example during encoding of macro definitions
-rw-r--r--compiler/rustc_session/src/lib.rs1
-rw-r--r--compiler/rustc_session/src/utils.rs3
-rw-r--r--src/test/ui/proc-macro/nested-macro-rules.stdout24
3 files changed, 10 insertions, 18 deletions
diff --git a/compiler/rustc_session/src/lib.rs b/compiler/rustc_session/src/lib.rs
index 14273b07ebd..3151b025fff 100644
--- a/compiler/rustc_session/src/lib.rs
+++ b/compiler/rustc_session/src/lib.rs
@@ -1,5 +1,6 @@
 #![feature(crate_visibility_modifier)]
 #![feature(derive_default_enum)]
+#![feature(if_let_guard)]
 #![feature(let_chains)]
 #![feature(let_else)]
 #![feature(min_specialization)]
diff --git a/compiler/rustc_session/src/utils.rs b/compiler/rustc_session/src/utils.rs
index 6a8775bd10b..9a286d94ab8 100644
--- a/compiler/rustc_session/src/utils.rs
+++ b/compiler/rustc_session/src/utils.rs
@@ -132,6 +132,9 @@ impl<'a> FlattenNonterminals<'a> {
 
     pub fn process_token(&mut self, token: Token) -> TokenStream {
         match token.kind {
+            token::Interpolated(nt) if let token::NtIdent(ident, is_raw) = *nt => {
+                TokenTree::Token(Token::new(token::Ident(ident.name, is_raw), ident.span)).into()
+            }
             token::Interpolated(nt) => {
                 let tts = (self.nt_to_tokenstream)(&nt, self.parse_sess, self.synthesize_tokens);
                 TokenTree::Delimited(
diff --git a/src/test/ui/proc-macro/nested-macro-rules.stdout b/src/test/ui/proc-macro/nested-macro-rules.stdout
index fa35e81148b..31113904041 100644
--- a/src/test/ui/proc-macro/nested-macro-rules.stdout
+++ b/src/test/ui/proc-macro/nested-macro-rules.stdout
@@ -1,14 +1,8 @@
 PRINT-BANG INPUT (DISPLAY): FirstStruct
 PRINT-BANG INPUT (DEBUG): TokenStream [
-    Group {
-        delimiter: None,
-        stream: TokenStream [
-            Ident {
-                ident: "FirstStruct",
-                span: $DIR/auxiliary/nested-macro-rules.rs:16:14: 16:25 (#7),
-            },
-        ],
-        span: $DIR/auxiliary/nested-macro-rules.rs:9:30: 9:35 (#6),
+    Ident {
+        ident: "FirstStruct",
+        span: $DIR/auxiliary/nested-macro-rules.rs:16:14: 16:25 (#7),
     },
 ]
 PRINT-ATTR INPUT (DISPLAY): struct FirstAttrStruct {}
@@ -17,15 +11,9 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [
         ident: "struct",
         span: $DIR/auxiliary/nested-macro-rules.rs:10:32: 10:38 (#6),
     },
-    Group {
-        delimiter: None,
-        stream: TokenStream [
-            Ident {
-                ident: "FirstAttrStruct",
-                span: $DIR/auxiliary/nested-macro-rules.rs:16:27: 16:42 (#7),
-            },
-        ],
-        span: $DIR/auxiliary/nested-macro-rules.rs:10:39: 10:56 (#6),
+    Ident {
+        ident: "FirstAttrStruct",
+        span: $DIR/auxiliary/nested-macro-rules.rs:16:27: 16:42 (#7),
     },
     Group {
         delimiter: Brace,