@@ -160,7 +160,7 @@ impl<'a> Parser<'a> {
160160 style : PathStyle ,
161161 ty_generics : Option < & Generics > ,
162162 ) -> 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 | {
164164 // Ensure generic arguments don't end up in attribute paths, such as:
165165 //
166166 // macro_rules! m {
@@ -178,21 +178,26 @@ impl<'a> Parser<'a> {
178178 . map ( |arg| arg. span ( ) )
179179 . collect :: < Vec < _ > > ( ) ;
180180 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 { segments, ..path }
188+ } else {
189+ path
181190 }
182191 } ;
183192
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( ) ) ) ;
188194
189195 if let token:: Interpolated ( nt) = & self . token . kind {
190196 if let token:: NtTy ( ty) = & nt. 0 {
191197 if let ast:: TyKind :: Path ( None , path) = & ty. kind {
192198 let path = path. clone ( ) ;
193199 self . bump ( ) ;
194- reject_generics_if_mod_style ( self , & path) ;
195- return Ok ( path) ;
200+ return Ok ( reject_generics_if_mod_style ( self , path) ) ;
196201 }
197202 }
198203 }
0 commit comments