Skip to content

Commit

Permalink
Auto merge of rust-lang#95571 - petrochenkov:nowrapident2, r=Aaron1011
Browse files Browse the repository at this point in the history
ast_lowering: Stop wrapping `ident` matchers into groups

The lowered forms goes to metadata, for example during encoding of macro definitions.
This is a missing part of rust-lang#92472.

Fixes rust-lang#95569
r? `@Aaron1011`
  • Loading branch information
bors committed Apr 2, 2022
2 parents 95f6870 + a150fc2 commit 07a461a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 18 deletions.
1 change: 1 addition & 0 deletions compiler/rustc_session/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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)]
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_session/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
24 changes: 6 additions & 18 deletions src/test/ui/proc-macro/nested-macro-rules.stdout
Original file line number Diff line number Diff line change
@@ -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 {}
Expand All @@ -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,
Expand Down

0 comments on commit 07a461a

Please sign in to comment.