diff options
| author | bors <bors@rust-lang.org> | 2022-04-02 07:42:50 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-04-02 07:42:50 +0000 |
| commit | 07a461ad52b8485b184397b453b5436c70f9f460 (patch) | |
| tree | c8c190d608710eca64c12ab369c12f6f95f7639c | |
| parent | 95f68702ff927231ef6d37c03a8c3fcd2b6cf59b (diff) | |
| parent | a150fc2990bb89d804761f64d2ce3cf497b7fc81 (diff) | |
| download | rust-07a461ad52b8485b184397b453b5436c70f9f460.tar.gz rust-07a461ad52b8485b184397b453b5436c70f9f460.zip | |
Auto merge of #95571 - petrochenkov:nowrapident2, r=Aaron1011
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 https://github.com/rust-lang/rust/pull/92472. Fixes https://github.com/rust-lang/rust/issues/95569 r? `@Aaron1011`
| -rw-r--r-- | compiler/rustc_session/src/lib.rs | 1 | ||||
| -rw-r--r-- | compiler/rustc_session/src/utils.rs | 3 | ||||
| -rw-r--r-- | src/test/ui/proc-macro/nested-macro-rules.stdout | 24 |
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, |
