@@ -1119,9 +1119,34 @@ impl<'a> Parser<'a> {
1119
1119
if text. is_empty ( ) {
1120
1120
self . span_bug ( sp, "found empty literal suffix in Some" )
1121
1121
}
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 ( ) ;
1125
1150
}
1126
1151
}
1127
1152
}
@@ -1429,6 +1454,9 @@ impl<'a> Parser<'a> {
1429
1454
fn struct_span_err < S : Into < MultiSpan > > ( & self , sp : S , m : & str ) -> DiagnosticBuilder < ' a > {
1430
1455
self . sess . span_diagnostic . struct_span_err ( sp, m)
1431
1456
}
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
+ }
1432
1460
crate fn span_bug < S : Into < MultiSpan > > ( & self , sp : S , m : & str ) -> ! {
1433
1461
self . sess . span_diagnostic . span_bug ( sp, m)
1434
1462
}
0 commit comments