This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +11
-16
lines changed
compiler/rustc_parse/src/parser Expand file tree Collapse file tree 2 files changed +11
-16
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ use super::{
6
6
} ;
7
7
use crate :: errors:: { self , MacroExpandsToAdtField } ;
8
8
use crate :: fluent_generated as fluent;
9
+ use crate :: maybe_whole;
9
10
use ast:: token:: IdentIsRaw ;
10
11
use rustc_ast:: ast:: * ;
11
12
use rustc_ast:: ptr:: P ;
@@ -115,17 +116,10 @@ impl<'a> Parser<'a> {
115
116
fn_parse_mode : FnParseMode ,
116
117
force_collect : ForceCollect ,
117
118
) -> PResult < ' a , Option < Item > > {
118
- // Don't use `maybe_whole` so that we have precise control
119
- // over when we bump the parser
120
- if let token:: Interpolated ( nt) = & self . token . kind
121
- && let token:: NtItem ( item) = & nt. 0
122
- {
123
- let mut item = item. clone ( ) ;
124
- self . bump ( ) ;
125
-
119
+ maybe_whole ! ( self , NtItem , |item| {
126
120
attrs. prepend_to_nt_inner( & mut item. attrs) ;
127
- return Ok ( Some ( item. into_inner ( ) ) ) ;
128
- } ;
121
+ Some ( item. into_inner( ) )
122
+ } ) ;
129
123
130
124
let item =
131
125
self . collect_tokens_trailing_token ( attrs, force_collect, |this : & mut Self , attrs| {
Original file line number Diff line number Diff line change @@ -93,12 +93,13 @@ pub enum TrailingToken {
93
93
#[ macro_export]
94
94
macro_rules! maybe_whole {
95
95
( $p: expr, $constructor: ident, |$x: ident| $e: expr) => {
96
- if let token:: Interpolated ( nt) = & $p. token. kind {
97
- if let token:: $constructor( x) = & nt. 0 {
98
- let $x = x. clone( ) ;
99
- $p. bump( ) ;
100
- return Ok ( $e) ;
101
- }
96
+ if let token:: Interpolated ( nt) = & $p. token. kind
97
+ && let token:: $constructor( x) = & nt. 0
98
+ {
99
+ #[ allow( unused_mut) ]
100
+ let mut $x = x. clone( ) ;
101
+ $p. bump( ) ;
102
+ return Ok ( $e) ;
102
103
}
103
104
} ;
104
105
}
You can’t perform that action at this time.
0 commit comments