@@ -304,23 +304,25 @@ impl<'a> Parser<'a> {
304
304
if self . may_recover ( )
305
305
&& ( self . eat_keyword_noexpect ( kw:: Impl ) || self . eat_keyword_noexpect ( kw:: Dyn ) )
306
306
{
307
- let kw = self . prev_token . ident ( ) . unwrap ( ) . 0 . name ;
307
+ let kw = self . prev_token . ident ( ) . unwrap ( ) . 0 ;
308
+ let removal_span = kw. span . with_hi ( self . token . span . lo ( ) ) ;
309
+ let path = self . parse_path ( PathStyle :: Type ) ?;
310
+ let parse_plus = allow_plus == AllowPlus :: Yes && self . check_plus ( ) ;
311
+ let kind =
312
+ self . parse_remaining_bounds_path ( lifetime_defs, path, lo, parse_plus) ?;
308
313
let mut err = self . sess . create_err ( errors:: TransposeDynOrImpl {
309
- span : self . prev_token . span ,
310
- kw : kw. as_str ( ) ,
314
+ span : kw . span ,
315
+ kw : kw. name . as_str ( ) ,
311
316
sugg : errors:: TransposeDynOrImplSugg {
312
- removal_span : self . prev_token . span . with_hi ( self . token . span . lo ( ) ) ,
317
+ removal_span,
313
318
insertion_span : for_span. shrink_to_lo ( ) ,
314
- kw : kw. as_str ( ) ,
319
+ kw : kw. name . as_str ( ) ,
315
320
} ,
316
321
} ) ;
317
- let path = self . parse_path ( PathStyle :: Type ) ?;
318
- let parse_plus = allow_plus == AllowPlus :: Yes && self . check_plus ( ) ;
319
- let kind =
320
- self . parse_remaining_bounds_path ( lifetime_defs, path, lo, parse_plus) ?;
322
+
321
323
// Take the parsed bare trait object and turn it either
322
324
// into a `dyn` object or an `impl Trait`.
323
- let kind = match ( kind, kw) {
325
+ let kind = match ( kind, kw. name ) {
324
326
( TyKind :: TraitObject ( bounds, _) , kw:: Dyn ) => {
325
327
TyKind :: TraitObject ( bounds, TraitObjectSyntax :: Dyn )
326
328
}
0 commit comments