@@ -495,11 +495,16 @@ impl<'a> Parser<'a> {
495
495
None => {
496
496
let after_eq = eq. shrink_to_hi ( ) ;
497
497
let before_next = self . token . span . shrink_to_lo ( ) ;
498
+ let the_type_placeholder = if matches ! ( self . token. kind, token:: Comma | token:: Gt ) {
499
+ " TheType"
500
+ } else {
501
+ " TheType "
502
+ } ;
498
503
self . struct_span_err ( after_eq. to ( before_next) , "missing type to the right of `=`" )
499
504
. span_suggestion (
500
505
self . sess . source_map ( ) . next_point ( eq) . to ( before_next) ,
501
506
"to constrain the associated type, add a type after `=`" ,
502
- " TheType" . to_string ( ) ,
507
+ the_type_placeholder . to_string ( ) ,
503
508
Applicability :: HasPlaceholders ,
504
509
)
505
510
. span_suggestion (
@@ -572,6 +577,19 @@ impl<'a> Parser<'a> {
572
577
return self . recover_const_arg ( start, err) . map ( Some ) ;
573
578
}
574
579
}
580
+ } else if self . eat_keyword_noexpect ( kw:: Const ) {
581
+ // Detect and recover from the old, pre-RFC2000 syntax for const generics.
582
+ let mut err = self . struct_span_err (
583
+ start,
584
+ "expected lifetime, type, or constant, found keyword `const`" ,
585
+ ) ;
586
+ if self . check_const_arg ( ) {
587
+ err. emit ( ) ;
588
+ GenericArg :: Const ( self . parse_const_arg ( ) ?)
589
+ } else {
590
+ let after_kw_const = self . token . span ;
591
+ return self . recover_const_arg ( after_kw_const, err) . map ( Some ) ;
592
+ }
575
593
} else {
576
594
return Ok ( None ) ;
577
595
} ;
0 commit comments