@@ -160,7 +160,7 @@ impl<'a> Parser<'a> {
160
160
style : PathStyle ,
161
161
ty_generics : Option < & Generics > ,
162
162
) -> PResult < ' a , Path > {
163
- let reject_generics_if_mod_style = |parser : & Parser < ' _ > , path : & Path | {
163
+ let reject_generics_if_mod_style = |parser : & Parser < ' _ > , path : Path | {
164
164
// Ensure generic arguments don't end up in attribute paths, such as:
165
165
//
166
166
// macro_rules! m {
@@ -178,21 +178,26 @@ impl<'a> Parser<'a> {
178
178
. map ( |arg| arg. span ( ) )
179
179
. collect :: < Vec < _ > > ( ) ;
180
180
parser. dcx ( ) . emit_err ( errors:: GenericsInPath { span } ) ;
181
+ // Ignore these arguments to prevent unexpected behaviors.
182
+ let segments = path
183
+ . segments
184
+ . iter ( )
185
+ . map ( |segment| PathSegment { ident : segment. ident , id : segment. id , args : None } )
186
+ . collect ( ) ;
187
+ Path { span : path. span , segments, tokens : path. tokens . clone ( ) }
188
+ } else {
189
+ path
181
190
}
182
191
} ;
183
192
184
- maybe_whole ! ( self , NtPath , |path| {
185
- reject_generics_if_mod_style( self , & path) ;
186
- path. into_inner( )
187
- } ) ;
193
+ maybe_whole ! ( self , NtPath , |path| reject_generics_if_mod_style( self , path. into_inner( ) ) ) ;
188
194
189
195
if let token:: Interpolated ( nt) = & self . token . kind {
190
196
if let token:: NtTy ( ty) = & nt. 0 {
191
197
if let ast:: TyKind :: Path ( None , path) = & ty. kind {
192
198
let path = path. clone ( ) ;
193
199
self . bump ( ) ;
194
- reject_generics_if_mod_style ( self , & path) ;
195
- return Ok ( path) ;
200
+ return Ok ( reject_generics_if_mod_style ( self , path) ) ;
196
201
}
197
202
}
198
203
}
0 commit comments