@@ -306,11 +306,11 @@ pub enum ChangeType<'tcx> {
306
306
/// A possibly public field has been added to a variant or struct.
307
307
///
308
308
/// This also records whether all fields are public were public before the change.
309
- VariantFieldAdded { public : bool , total_public : bool } ,
309
+ VariantFieldAdded { public : bool , total_public : bool , is_enum : bool } ,
310
310
/// A possibly public field has been removed from a variant or struct.
311
311
///
312
- /// This also records whether all fields are public were public before the change.
313
- VariantFieldRemoved { public : bool , total_public : bool } ,
312
+ /// This also records whether all fields were public before the change.
313
+ VariantFieldRemoved { public : bool , total_public : bool , is_enum : bool } ,
314
314
/// A variant or struct has changed it's style.
315
315
///
316
316
/// The style could have been changed from a tuple variant/struct to a regular
@@ -319,6 +319,7 @@ pub enum ChangeType<'tcx> {
319
319
VariantStyleChanged {
320
320
now_struct : bool ,
321
321
total_private : bool ,
322
+ is_enum : bool ,
322
323
} ,
323
324
/// A function has changed it's constness.
324
325
FnConstChanged { now_const : bool } ,
@@ -373,8 +374,10 @@ impl<'tcx> ChangeType<'tcx> {
373
374
TypeParameterRemoved { .. } |
374
375
VariantAdded |
375
376
VariantRemoved |
376
- VariantFieldAdded { .. } | // TODO: this (and the two below) appear wrong
377
- VariantFieldRemoved { .. } |
377
+ VariantFieldAdded { public : true , .. } |
378
+ VariantFieldAdded { public : false , total_public : true , .. } |
379
+ VariantFieldRemoved { public : true , .. } |
380
+ VariantFieldRemoved { public : false , is_enum : true , .. } |
378
381
VariantStyleChanged { .. } |
379
382
TypeChanged { .. } |
380
383
FnConstChanged { now_const : false } |
@@ -396,6 +399,8 @@ impl<'tcx> ChangeType<'tcx> {
396
399
StaticMutabilityChanged { now_mut : true } |
397
400
VarianceLoosened |
398
401
TypeParameterAdded { defaulted : true } |
402
+ VariantFieldAdded { public : false , .. } |
403
+ VariantFieldRemoved { public : false , .. } |
399
404
FnConstChanged { now_const : true } => NonBreaking ,
400
405
}
401
406
}
@@ -477,13 +482,13 @@ on said enum can become non-exhaustive."
477
482
to the removed variant is rendered invalid."
478
483
}
479
484
VariantFieldAdded { .. } => {
480
- "Adding a field to an enum variant is breaking, as matches on the variant are
481
- invalidated. In case of structs, this only holds for public fields, or the
482
- first private field being added."
485
+ "Adding a field to an enum variant or struct is breaking, as matches on the
486
+ variant or struct are invalidated. In case of structs, this only holds for
487
+ public fields, or the first private field being added."
483
488
}
484
489
VariantFieldRemoved { .. } => {
485
- "Removing a field from an enum variant is breaking, as matches on the variant
486
- are invalidated. In case of structs, this only holds for public fields."
490
+ "Removing a field from an enum variant or struct is breaking, as matches on the
491
+ variant are invalidated. In case of structs, this only holds for public fields."
487
492
}
488
493
VariantStyleChanged { .. } => {
489
494
"Changing the style of a variant is a breaking change, since most old
@@ -616,51 +621,123 @@ impl<'a> fmt::Display for ChangeType<'a> {
616
621
VariantFieldAdded {
617
622
public : true ,
618
623
total_public : true ,
619
- } => "public variant field added to variant with no private fields" ,
624
+ is_enum : true ,
625
+ } => "public field added to variant with no private fields" ,
626
+ VariantFieldAdded {
627
+ public : true ,
628
+ total_public : true ,
629
+ is_enum : false ,
630
+ } => "public field added to struct with no private fields" ,
631
+ VariantFieldAdded {
632
+ public : true ,
633
+ total_public : false ,
634
+ is_enum : true ,
635
+ } => "public field added to variant with private fields" ,
620
636
VariantFieldAdded {
621
637
public : true ,
622
638
total_public : false ,
623
- } => "public variant field added to variant with private fields" ,
639
+ is_enum : false ,
640
+ } => "public field added to struct with private fields" ,
641
+ VariantFieldAdded {
642
+ public : false ,
643
+ total_public : true ,
644
+ is_enum : true ,
645
+ } => "private field added to variant with no private fields" ,
624
646
VariantFieldAdded {
625
647
public : false ,
626
648
total_public : true ,
627
- } => "variant field added to variant with no private fields" ,
649
+ is_enum : false ,
650
+ } => "private field added to struct with no private fields" ,
628
651
VariantFieldAdded {
629
652
public : false ,
630
653
total_public : false ,
631
- } => "variant field added to variant with private fields" ,
654
+ is_enum : true ,
655
+ } => "private field added to variant with private fields" ,
656
+ VariantFieldAdded {
657
+ public : false ,
658
+ total_public : false ,
659
+ is_enum : false ,
660
+ } => "private field added to struct with private fields" ,
632
661
VariantFieldRemoved {
633
662
public : true ,
634
663
total_public : true ,
635
- } => "public variant field removed from variant with no private fields" ,
664
+ is_enum : true ,
665
+ } => "public field removed from variant with no private fields" ,
666
+ VariantFieldRemoved {
667
+ public : true ,
668
+ total_public : true ,
669
+ is_enum : false ,
670
+ } => "public field removed from struct with no private fields" ,
671
+ VariantFieldRemoved {
672
+ public : true ,
673
+ total_public : false ,
674
+ is_enum : true
675
+ } => "public field removed from variant with private fields" ,
636
676
VariantFieldRemoved {
637
677
public : true ,
638
678
total_public : false ,
639
- } => "public variant field removed from variant with private fields" ,
679
+ is_enum : false ,
680
+ } => "public field removed from struct with private fields" ,
640
681
VariantFieldRemoved {
641
682
public : false ,
642
683
total_public : true ,
643
- } => "variant field removed from variant with no private fields" ,
684
+ is_enum : true ,
685
+ } => "private field removed from variant with no private fields" ,
686
+ VariantFieldRemoved {
687
+ public : false ,
688
+ total_public : true ,
689
+ is_enum : false ,
690
+ } => "private field removed from struct with no private fields" ,
644
691
VariantFieldRemoved {
645
692
public : false ,
646
693
total_public : false ,
647
- } => "variant field removed from variant with private fields" ,
694
+ is_enum : true ,
695
+ } => "private field removed from variant with private fields" ,
696
+ VariantFieldRemoved {
697
+ public : false ,
698
+ total_public : false ,
699
+ is_enum : false ,
700
+ } => "private field removed from struct with private fields" ,
648
701
VariantStyleChanged {
649
702
now_struct : true ,
650
703
total_private : true ,
704
+ is_enum : true ,
651
705
} => "variant with no public fields changed to a struct variant" ,
706
+ VariantStyleChanged {
707
+ now_struct : true ,
708
+ total_private : true ,
709
+ is_enum : false ,
710
+ } => "tuple struct with no public fields changed to a regular struct" ,
652
711
VariantStyleChanged {
653
712
now_struct : true ,
654
713
total_private : false ,
655
- } => "variant changed to a struct variant" ,
714
+ is_enum : true ,
715
+ } => "variant with public fields changed to a struct variant" ,
716
+ VariantStyleChanged {
717
+ now_struct : true ,
718
+ total_private : false ,
719
+ is_enum : false ,
720
+ } => "tuple struct with public fields changed to a regular struct" ,
656
721
VariantStyleChanged {
657
722
now_struct : false ,
658
723
total_private : true ,
724
+ is_enum : true ,
659
725
} => "variant with no public fields changed to a tuple variant" ,
726
+ VariantStyleChanged {
727
+ now_struct : false ,
728
+ total_private : true ,
729
+ is_enum : false ,
730
+ } => "struct with no public fields changed to a tuple struct" ,
731
+ VariantStyleChanged {
732
+ now_struct : false ,
733
+ total_private : false ,
734
+ is_enum : true ,
735
+ } => "variant with public fields changed to a tuple variant" ,
660
736
VariantStyleChanged {
661
737
now_struct : false ,
662
738
total_private : false ,
663
- } => "variant changed to a tuple variant" ,
739
+ is_enum : false ,
740
+ } => "struct with public fields changed to a tuple struct" ,
664
741
FnConstChanged { now_const : true } => "fn item made const" ,
665
742
FnConstChanged { now_const : false } => "fn item made non-const" ,
666
743
MethodSelfChanged { now_self : true } => "added self-argument to method" ,
@@ -1210,14 +1287,17 @@ pub mod tests {
1210
1287
VariantFieldAdded {
1211
1288
public : bool ,
1212
1289
total_public : bool ,
1290
+ is_enum : bool ,
1213
1291
} ,
1214
1292
VariantFieldRemoved {
1215
1293
public : bool ,
1216
1294
total_public : bool ,
1295
+ is_enum : bool ,
1217
1296
} ,
1218
1297
VariantStyleChanged {
1219
1298
now_struct : bool ,
1220
1299
total_private : bool ,
1300
+ is_enum : bool ,
1221
1301
} ,
1222
1302
FnConstChanged {
1223
1303
now_const : bool ,
@@ -1255,23 +1335,29 @@ pub mod tests {
1255
1335
ChangeType_ :: VariantFieldAdded {
1256
1336
public,
1257
1337
total_public,
1338
+ is_enum,
1258
1339
} => VariantFieldAdded {
1259
1340
public,
1260
1341
total_public,
1342
+ is_enum,
1261
1343
} ,
1262
1344
ChangeType_ :: VariantFieldRemoved {
1263
1345
public,
1264
1346
total_public,
1347
+ is_enum,
1265
1348
} => VariantFieldRemoved {
1266
1349
public,
1267
1350
total_public,
1351
+ is_enum,
1268
1352
} ,
1269
1353
ChangeType_ :: VariantStyleChanged {
1270
1354
now_struct,
1271
1355
total_private,
1356
+ is_enum,
1272
1357
} => VariantStyleChanged {
1273
1358
now_struct,
1274
1359
total_private,
1360
+ is_enum,
1275
1361
} ,
1276
1362
ChangeType_ :: FnConstChanged { now_const } => FnConstChanged { now_const } ,
1277
1363
ChangeType_ :: MethodSelfChanged { now_self } => MethodSelfChanged { now_self } ,
@@ -1312,14 +1398,17 @@ pub mod tests {
1312
1398
VariantFieldAdded {
1313
1399
public : b1,
1314
1400
total_public : b2,
1401
+ is_enum : b2,
1315
1402
} ,
1316
1403
VariantFieldRemoved {
1317
1404
public : b1,
1318
1405
total_public : b2,
1406
+ is_enum : b2,
1319
1407
} ,
1320
1408
VariantStyleChanged {
1321
1409
now_struct : b1,
1322
1410
total_private : b2,
1411
+ is_enum : b2,
1323
1412
} ,
1324
1413
FnConstChanged { now_const : b1 } ,
1325
1414
MethodSelfChanged { now_self : b1 } ,
0 commit comments