@@ -1119,9 +1119,34 @@ impl<'a> Parser<'a> {
11191119 if text. is_empty ( ) {
11201120 self . span_bug ( sp, "found empty literal suffix in Some" )
11211121 }
1122- self . struct_span_err ( sp, & format ! ( "suffixes on {} are invalid" , kind) )
1123- . span_label ( sp, format ! ( "invalid suffix `{}`" , text) )
1124- . emit ( ) ;
1122+ let mut err = if kind == "a tuple index" &&
1123+ [ "i32" , "u32" , "isize" , "usize" ] . contains ( & text. to_string ( ) . as_str ( ) )
1124+ {
1125+ // #59553: warn instead of reject out of hand to allow the fix to percolate
1126+ // through the ecosystem when people fix their macros
1127+ let mut err = self . struct_span_warn (
1128+ sp,
1129+ & format ! ( "suffixes on {} are invalid" , kind) ,
1130+ ) ;
1131+ err. note ( & format ! (
1132+ "`{}` is *temporarily* accepted on tuple index fields as it was \
1133+ incorrectly accepted on stable for a few releases",
1134+ text,
1135+ ) ) ;
1136+ err. help (
1137+ "on proc macros, you'll want to use `syn::Index::from` or \
1138+ `proc_macro::Literal::*_unsuffixed` for code that will desugar \
1139+ to tuple field access",
1140+ ) ;
1141+ err. note (
1142+ "for more context, see https://github.com/rust-lang/rust/issues/59553" ,
1143+ ) ;
1144+ err
1145+ } else {
1146+ self . struct_span_err ( sp, & format ! ( "suffixes on {} are invalid" , kind) )
1147+ } ;
1148+ err. span_label ( sp, format ! ( "invalid suffix `{}`" , text) ) ;
1149+ err. emit ( ) ;
11251150 }
11261151 }
11271152 }
@@ -1429,6 +1454,9 @@ impl<'a> Parser<'a> {
14291454 fn struct_span_err < S : Into < MultiSpan > > ( & self , sp : S , m : & str ) -> DiagnosticBuilder < ' a > {
14301455 self . sess . span_diagnostic . struct_span_err ( sp, m)
14311456 }
1457+ fn struct_span_warn < S : Into < MultiSpan > > ( & self , sp : S , m : & str ) -> DiagnosticBuilder < ' a > {
1458+ self . sess . span_diagnostic . struct_span_warn ( sp, m)
1459+ }
14321460 crate fn span_bug < S : Into < MultiSpan > > ( & self , sp : S , m : & str ) -> ! {
14331461 self . sess . span_diagnostic . span_bug ( sp, m)
14341462 }
0 commit comments