@@ -474,6 +474,26 @@ define_Conf! {
474
474
/// Whether to check MSRV compatibility in `#[test]` and `#[cfg(test)]` code.
475
475
#[ lints( incompatible_msrv) ]
476
476
check_incompatible_msrv_in_tests: bool = false ,
477
+ /// Whether to suggest reordering constructor fields when initializers are present.
478
+ ///
479
+ /// Warnings produced by this configuration aren't necessarily fixed by just reordering the fields. Even if the
480
+ /// suggested code would compile, it can change semantics if the initializer expressions have side effects. The
481
+ /// following example [from rust-clippy#11846] shows how the suggestion can run into borrow check errors:
482
+ ///
483
+ /// ```rust
484
+ /// struct MyStruct {
485
+ /// vector: Vec<u32>,
486
+ /// length: usize
487
+ /// }
488
+ /// fn main() {
489
+ /// let vector = vec![1,2,3];
490
+ /// MyStruct { length: vector.len(), vector};
491
+ /// }
492
+ /// ```
493
+ ///
494
+ /// [from rust-clippy#11846]: https://github.com/rust-lang/rust-clippy/issues/11846#issuecomment-1820747924
495
+ #[ lints( inconsistent_struct_constructor) ]
496
+ check_inconsistent_struct_field_initializers: bool = false ,
477
497
/// Whether to also run the listed lints on private items.
478
498
#[ lints( missing_errors_doc, missing_panics_doc, missing_safety_doc, unnecessary_safety_doc) ]
479
499
check_private_items: bool = false ,
@@ -554,24 +574,10 @@ define_Conf! {
554
574
#[ lints( collapsible_if) ]
555
575
lint_commented_code: bool = false ,
556
576
/// Whether to suggest reordering constructor fields when initializers are present.
577
+ /// DEPRECATED CONFIGURATION: lint-inconsistent-struct-field-initializers
557
578
///
558
- /// Warnings produced by this configuration aren't necessarily fixed by just reordering the fields. Even if the
559
- /// suggested code would compile, it can change semantics if the initializer expressions have side effects. The
560
- /// following example [from rust-clippy#11846] shows how the suggestion can run into borrow check errors:
561
- ///
562
- /// ```rust
563
- /// struct MyStruct {
564
- /// vector: Vec<u32>,
565
- /// length: usize
566
- /// }
567
- /// fn main() {
568
- /// let vector = vec![1,2,3];
569
- /// MyStruct { length: vector.len(), vector};
570
- /// }
571
- /// ```
572
- ///
573
- /// [from rust-clippy#11846]: https://github.com/rust-lang/rust-clippy/issues/11846#issuecomment-1820747924
574
- #[ lints( inconsistent_struct_constructor) ]
579
+ /// Use the `check-inconsistent-struct-field-initializers` configuration instead.
580
+ #[ conf_deprecated( "Please use `check-inconsistent-struct-field-initializers` instead" , check_inconsistent_struct_field_initializers) ]
575
581
lint_inconsistent_struct_field_initializers: bool = false ,
576
582
/// The lower bound for linting decimal literals
577
583
#[ lints( decimal_literal_representation) ]
@@ -986,7 +992,23 @@ impl serde::de::Error for FieldError {
986
992
// set and allows it.
987
993
use fmt:: Write ;
988
994
989
- let mut expected = expected. to_vec ( ) ;
995
+ let metadata = get_configuration_metadata ( ) ;
996
+ let deprecated = metadata
997
+ . iter ( )
998
+ . filter_map ( |conf| {
999
+ if conf. deprecation_reason . is_some ( ) {
1000
+ Some ( conf. name . as_str ( ) )
1001
+ } else {
1002
+ None
1003
+ }
1004
+ } )
1005
+ . collect :: < Vec < _ > > ( ) ;
1006
+
1007
+ let mut expected = expected
1008
+ . iter ( )
1009
+ . copied ( )
1010
+ . filter ( |name| !deprecated. contains ( name) )
1011
+ . collect :: < Vec < _ > > ( ) ;
990
1012
expected. sort_unstable ( ) ;
991
1013
992
1014
let ( rows, column_widths) = calculate_dimensions ( & expected) ;
@@ -1069,7 +1091,13 @@ mod tests {
1069
1091
fn configs_are_tested ( ) {
1070
1092
let mut names: HashSet < String > = crate :: get_configuration_metadata ( )
1071
1093
. into_iter ( )
1072
- . map ( |meta| meta. name . replace ( '_' , "-" ) )
1094
+ . filter_map ( |meta| {
1095
+ if meta. deprecation_reason . is_none ( ) {
1096
+ Some ( meta. name . replace ( '_' , "-" ) )
1097
+ } else {
1098
+ None
1099
+ }
1100
+ } )
1073
1101
. collect ( ) ;
1074
1102
1075
1103
let toml_files = WalkDir :: new ( "../tests" )
0 commit comments