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::{
66} ;
77use crate :: errors:: { self , MacroExpandsToAdtField } ;
88use crate :: fluent_generated as fluent;
9+ use crate :: maybe_whole;
910use ast:: token:: IdentIsRaw ;
1011use rustc_ast:: ast:: * ;
1112use rustc_ast:: ptr:: P ;
@@ -115,17 +116,10 @@ impl<'a> Parser<'a> {
115116 fn_parse_mode : FnParseMode ,
116117 force_collect : ForceCollect ,
117118 ) -> 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| {
126120 attrs. prepend_to_nt_inner( & mut item. attrs) ;
127- return Ok ( Some ( item. into_inner ( ) ) ) ;
128- } ;
121+ Some ( item. into_inner( ) )
122+ } ) ;
129123
130124 let item =
131125 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 {
9393#[ macro_export]
9494macro_rules! maybe_whole {
9595 ( $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) ;
102103 }
103104 } ;
104105}
You can’t perform that action at this time.
0 commit comments