Skip to content

Commit a150fc2

Browse files
committed
ast_lowering: Stop wrapping ident matchers into groups
The lowered forms goes to metadata, for example during encoding of macro definitions
1 parent 297a801 commit a150fc2

File tree

3 files changed

+10
-18
lines changed

3 files changed

+10
-18
lines changed

compiler/rustc_session/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#![feature(crate_visibility_modifier)]
22
#![feature(derive_default_enum)]
3+
#![feature(if_let_guard)]
34
#![feature(let_chains)]
45
#![feature(let_else)]
56
#![feature(min_specialization)]

compiler/rustc_session/src/utils.rs

+3
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ impl<'a> FlattenNonterminals<'a> {
132132

133133
pub fn process_token(&mut self, token: Token) -> TokenStream {
134134
match token.kind {
135+
token::Interpolated(nt) if let token::NtIdent(ident, is_raw) = *nt => {
136+
TokenTree::Token(Token::new(token::Ident(ident.name, is_raw), ident.span)).into()
137+
}
135138
token::Interpolated(nt) => {
136139
let tts = (self.nt_to_tokenstream)(&nt, self.parse_sess, self.synthesize_tokens);
137140
TokenTree::Delimited(

src/test/ui/proc-macro/nested-macro-rules.stdout

+6-18
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
PRINT-BANG INPUT (DISPLAY): FirstStruct
22
PRINT-BANG INPUT (DEBUG): TokenStream [
3-
Group {
4-
delimiter: None,
5-
stream: TokenStream [
6-
Ident {
7-
ident: "FirstStruct",
8-
span: $DIR/auxiliary/nested-macro-rules.rs:16:14: 16:25 (#7),
9-
},
10-
],
11-
span: $DIR/auxiliary/nested-macro-rules.rs:9:30: 9:35 (#6),
3+
Ident {
4+
ident: "FirstStruct",
5+
span: $DIR/auxiliary/nested-macro-rules.rs:16:14: 16:25 (#7),
126
},
137
]
148
PRINT-ATTR INPUT (DISPLAY): struct FirstAttrStruct {}
@@ -17,15 +11,9 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [
1711
ident: "struct",
1812
span: $DIR/auxiliary/nested-macro-rules.rs:10:32: 10:38 (#6),
1913
},
20-
Group {
21-
delimiter: None,
22-
stream: TokenStream [
23-
Ident {
24-
ident: "FirstAttrStruct",
25-
span: $DIR/auxiliary/nested-macro-rules.rs:16:27: 16:42 (#7),
26-
},
27-
],
28-
span: $DIR/auxiliary/nested-macro-rules.rs:10:39: 10:56 (#6),
14+
Ident {
15+
ident: "FirstAttrStruct",
16+
span: $DIR/auxiliary/nested-macro-rules.rs:16:27: 16:42 (#7),
2917
},
3018
Group {
3119
delimiter: Brace,

0 commit comments

Comments
 (0)