@@ -1289,25 +1289,41 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
1289
1289
PathSource :: Expr ( _) | PathSource :: TupleStruct ( ..) | PathSource :: Pat => {
1290
1290
let span = find_span ( & source, err) ;
1291
1291
err. span_label ( self . r . def_span ( def_id) , & format ! ( "`{path_str}` defined here" ) ) ;
1292
- let ( tail, descr, applicability) = match source {
1293
- PathSource :: Pat | PathSource :: TupleStruct ( ..) => {
1294
- ( "" , "pattern" , Applicability :: MachineApplicable )
1295
- }
1296
- _ => ( ": val" , "literal" , Applicability :: HasPlaceholders ) ,
1297
- } ;
1298
1292
1293
+ let ( tail, descr, applicability, old_fields) = match source {
1294
+ PathSource :: Pat => ( "" , "pattern" , Applicability :: MachineApplicable , None ) ,
1295
+ PathSource :: TupleStruct ( _, args) => (
1296
+ "" ,
1297
+ "pattern" ,
1298
+ Applicability :: MachineApplicable ,
1299
+ Some (
1300
+ args. iter ( )
1301
+ . map ( |a| self . r . tcx . sess . source_map ( ) . span_to_snippet ( * a) . ok ( ) )
1302
+ . collect :: < Vec < Option < String > > > ( ) ,
1303
+ ) ,
1304
+ ) ,
1305
+ _ => ( ": val" , "literal" , Applicability :: HasPlaceholders , None ) ,
1306
+ } ;
1299
1307
let field_ids = self . r . field_def_ids ( def_id) ;
1300
1308
let ( fields, applicability) = match field_ids {
1301
- Some ( field_ids) => (
1302
- field_ids
1303
- . iter ( )
1304
- . map ( |& field_id| {
1305
- format ! ( "{}{tail}" , self . r. tcx. item_name( field_id) )
1306
- } )
1307
- . collect :: < Vec < String > > ( )
1308
- . join ( ", " ) ,
1309
- applicability,
1310
- ) ,
1309
+ Some ( field_ids) => {
1310
+ let fields = field_ids. iter ( ) . map ( |& id| self . r . tcx . item_name ( id) ) ;
1311
+
1312
+ let fields = if let Some ( old_fields) = old_fields {
1313
+ fields
1314
+ . enumerate ( )
1315
+ . map ( |( idx, new) | ( new, old_fields. get ( idx) ) )
1316
+ . map ( |( new, old) | {
1317
+ let new = new. to_ident_string ( ) ;
1318
+ if let Some ( Some ( old) ) = old && new != * old { format ! ( "{}: {}" , new, old) } else { new }
1319
+ } )
1320
+ . collect :: < Vec < String > > ( )
1321
+ } else {
1322
+ fields. map ( |f| format ! ( "{f}{tail}" ) ) . collect :: < Vec < String > > ( )
1323
+ } ;
1324
+
1325
+ ( fields. join ( ", " ) , applicability)
1326
+ }
1311
1327
None => ( "/* fields */" . to_string ( ) , Applicability :: HasPlaceholders ) ,
1312
1328
} ;
1313
1329
let pad = match field_ids {
0 commit comments