@@ -1145,9 +1145,34 @@ impl<'a> Parser<'a> {
1145
1145
if text. is_empty ( ) {
1146
1146
self . span_bug ( sp, "found empty literal suffix in Some" )
1147
1147
}
1148
- self . struct_span_err ( sp, & format ! ( "suffixes on {} are invalid" , kind) )
1149
- . span_label ( sp, format ! ( "invalid suffix `{}`" , text) )
1150
- . emit ( ) ;
1148
+ let mut err = if kind == "a tuple index" &&
1149
+ [ "i32" , "u32" , "isize" , "usize" ] . contains ( & text. to_string ( ) . as_str ( ) )
1150
+ {
1151
+ // #59553: warn instead of reject out of hand to allow the fix to percolate
1152
+ // through the ecosystem when people fix their macros
1153
+ let mut err = self . struct_span_warn (
1154
+ sp,
1155
+ & format ! ( "suffixes on {} are invalid" , kind) ,
1156
+ ) ;
1157
+ err. note ( & format ! (
1158
+ "`{}` is *temporarily* accepted on tuple index fields as it was \
1159
+ incorrectly accepted on stable for a few releases",
1160
+ text,
1161
+ ) ) ;
1162
+ err. help (
1163
+ "on proc macros, you'll want to use `syn::Index::from` or \
1164
+ `proc_macro::Literal::*_unsuffixed` for code that will desugar \
1165
+ to tuple field access",
1166
+ ) ;
1167
+ err. note (
1168
+ "for more context, see https://github.com/rust-lang/rust/issues/59553" ,
1169
+ ) ;
1170
+ err
1171
+ } else {
1172
+ self . struct_span_err ( sp, & format ! ( "suffixes on {} are invalid" , kind) )
1173
+ } ;
1174
+ err. span_label ( sp, format ! ( "invalid suffix `{}`" , text) ) ;
1175
+ err. emit ( ) ;
1151
1176
}
1152
1177
}
1153
1178
}
@@ -1455,6 +1480,9 @@ impl<'a> Parser<'a> {
1455
1480
fn struct_span_err < S : Into < MultiSpan > > ( & self , sp : S , m : & str ) -> DiagnosticBuilder < ' a > {
1456
1481
self . sess . span_diagnostic . struct_span_err ( sp, m)
1457
1482
}
1483
+ fn struct_span_warn < S : Into < MultiSpan > > ( & self , sp : S , m : & str ) -> DiagnosticBuilder < ' a > {
1484
+ self . sess . span_diagnostic . struct_span_warn ( sp, m)
1485
+ }
1458
1486
crate fn span_bug < S : Into < MultiSpan > > ( & self , sp : S , m : & str ) -> ! {
1459
1487
self . sess . span_diagnostic . span_bug ( sp, m)
1460
1488
}
0 commit comments