@@ -1145,9 +1145,34 @@ impl<'a> Parser<'a> {
11451145 if text. is_empty ( ) {
11461146 self . span_bug ( sp, "found empty literal suffix in Some" )
11471147 }
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 ( ) ;
11511176 }
11521177 }
11531178 }
@@ -1455,6 +1480,9 @@ impl<'a> Parser<'a> {
14551480 fn struct_span_err < S : Into < MultiSpan > > ( & self , sp : S , m : & str ) -> DiagnosticBuilder < ' a > {
14561481 self . sess . span_diagnostic . struct_span_err ( sp, m)
14571482 }
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+ }
14581486 crate fn span_bug < S : Into < MultiSpan > > ( & self , sp : S , m : & str ) -> ! {
14591487 self . sess . span_diagnostic . span_bug ( sp, m)
14601488 }
0 commit comments