@@ -474,6 +474,26 @@ define_Conf! {
474474 /// Whether to check MSRV compatibility in `#[test]` and `#[cfg(test)]` code.
475475 #[ lints( incompatible_msrv) ]
476476 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 ,
477497 /// Whether to also run the listed lints on private items.
478498 #[ lints( missing_errors_doc, missing_panics_doc, missing_safety_doc, unnecessary_safety_doc) ]
479499 check_private_items: bool = false ,
@@ -554,24 +574,10 @@ define_Conf! {
554574 #[ lints( collapsible_if) ]
555575 lint_commented_code: bool = false ,
556576 /// Whether to suggest reordering constructor fields when initializers are present.
577+ /// DEPRECATED CONFIGURATION: lint-inconsistent-struct-field-initializers
557578 ///
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) ]
575581 lint_inconsistent_struct_field_initializers: bool = false ,
576582 /// The lower bound for linting decimal literals
577583 #[ lints( decimal_literal_representation) ]
@@ -986,7 +992,23 @@ impl serde::de::Error for FieldError {
986992 // set and allows it.
987993 use fmt:: Write ;
988994
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 < _ > > ( ) ;
9901012 expected. sort_unstable ( ) ;
9911013
9921014 let ( rows, column_widths) = calculate_dimensions ( & expected) ;
@@ -1069,7 +1091,13 @@ mod tests {
10691091 fn configs_are_tested ( ) {
10701092 let mut names: HashSet < String > = crate :: get_configuration_metadata ( )
10711093 . 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+ } )
10731101 . collect ( ) ;
10741102
10751103 let toml_files = WalkDir :: new ( "../tests" )
0 commit comments