Skip to content

Commit 88b590b

Browse files
committed
lint-inconsistent-... -> check-inconsistent-...
1 parent b27a2bb commit 88b590b

File tree

7 files changed

+59
-50
lines changed

7 files changed

+59
-50
lines changed

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6347,6 +6347,7 @@ Released 2018-09-13
63476347
[`await-holding-invalid-types`]: https://doc.rust-lang.org/clippy/lint_configuration.html#await-holding-invalid-types
63486348
[`cargo-ignore-publish`]: https://doc.rust-lang.org/clippy/lint_configuration.html#cargo-ignore-publish
63496349
[`check-incompatible-msrv-in-tests`]: https://doc.rust-lang.org/clippy/lint_configuration.html#check-incompatible-msrv-in-tests
6350+
[`check-inconsistent-struct-field-initializers`]: https://doc.rust-lang.org/clippy/lint_configuration.html#check-inconsistent-struct-field-initializers
63506351
[`check-private-items`]: https://doc.rust-lang.org/clippy/lint_configuration.html#check-private-items
63516352
[`cognitive-complexity-threshold`]: https://doc.rust-lang.org/clippy/lint_configuration.html#cognitive-complexity-threshold
63526353
[`disallowed-macros`]: https://doc.rust-lang.org/clippy/lint_configuration.html#disallowed-macros
@@ -6364,7 +6365,6 @@ Released 2018-09-13
63646365
[`ignore-interior-mutability`]: https://doc.rust-lang.org/clippy/lint_configuration.html#ignore-interior-mutability
63656366
[`large-error-threshold`]: https://doc.rust-lang.org/clippy/lint_configuration.html#large-error-threshold
63666367
[`lint-commented-code`]: https://doc.rust-lang.org/clippy/lint_configuration.html#lint-commented-code
6367-
[`lint-inconsistent-struct-field-initializers`]: https://doc.rust-lang.org/clippy/lint_configuration.html#lint-inconsistent-struct-field-initializers
63686368
[`literal-representation-threshold`]: https://doc.rust-lang.org/clippy/lint_configuration.html#literal-representation-threshold
63696369
[`matches-for-let-else`]: https://doc.rust-lang.org/clippy/lint_configuration.html#matches-for-let-else
63706370
[`max-fn-params-bools`]: https://doc.rust-lang.org/clippy/lint_configuration.html#max-fn-params-bools

book/src/lint_configuration.md

+27-27
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,33 @@ Whether to check MSRV compatibility in `#[test]` and `#[cfg(test)]` code.
425425
* [`incompatible_msrv`](https://rust-lang.github.io/rust-clippy/master/index.html#incompatible_msrv)
426426

427427

428+
## `check-inconsistent-struct-field-initializers`
429+
Whether to suggest reordering constructor fields when initializers are present.
430+
431+
Warnings produced by this configuration aren't necessarily fixed by just reordering the fields. Even if the
432+
suggested code would compile, it can change semantics if the initializer expressions have side effects. The
433+
following example [from rust-clippy#11846] shows how the suggestion can run into borrow check errors:
434+
435+
```rust
436+
struct MyStruct {
437+
vector: Vec<u32>,
438+
length: usize
439+
}
440+
fn main() {
441+
let vector = vec![1,2,3];
442+
MyStruct { length: vector.len(), vector};
443+
}
444+
```
445+
446+
[from rust-clippy#11846]: https://github.com/rust-lang/rust-clippy/issues/11846#issuecomment-1820747924
447+
448+
**Default Value:** `false`
449+
450+
---
451+
**Affected lints:**
452+
* [`inconsistent_struct_constructor`](https://rust-lang.github.io/rust-clippy/master/index.html#inconsistent_struct_constructor)
453+
454+
428455
## `check-private-items`
429456
Whether to also run the listed lints on private items.
430457

@@ -624,33 +651,6 @@ that would be collapsed.
624651
* [`collapsible_if`](https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if)
625652

626653

627-
## `lint-inconsistent-struct-field-initializers`
628-
Whether to suggest reordering constructor fields when initializers are present.
629-
630-
Warnings produced by this configuration aren't necessarily fixed by just reordering the fields. Even if the
631-
suggested code would compile, it can change semantics if the initializer expressions have side effects. The
632-
following example [from rust-clippy#11846] shows how the suggestion can run into borrow check errors:
633-
634-
```rust
635-
struct MyStruct {
636-
vector: Vec<u32>,
637-
length: usize
638-
}
639-
fn main() {
640-
let vector = vec![1,2,3];
641-
MyStruct { length: vector.len(), vector};
642-
}
643-
```
644-
645-
[from rust-clippy#11846]: https://github.com/rust-lang/rust-clippy/issues/11846#issuecomment-1820747924
646-
647-
**Default Value:** `false`
648-
649-
---
650-
**Affected lints:**
651-
* [`inconsistent_struct_constructor`](https://rust-lang.github.io/rust-clippy/master/index.html#inconsistent_struct_constructor)
652-
653-
654654
## `literal-representation-threshold`
655655
The lower bound for linting decimal literals
656656

clippy.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
avoid-breaking-exported-api = false
22

3-
lint-inconsistent-struct-field-initializers = true
3+
check-inconsistent-struct-field-initializers = true
44

55
[[disallowed-methods]]
66
path = "rustc_lint::context::LintContext::lint"

clippy_config/src/conf.rs

+23-17
Original file line numberDiff line numberDiff line change
@@ -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)]

clippy_lints/src/inconsistent_struct_constructor.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,13 @@ declare_clippy_lint! {
6565
}
6666

6767
pub struct InconsistentStructConstructor {
68-
lint_inconsistent_struct_field_initializers: bool,
68+
check_inconsistent_struct_field_initializers: bool,
6969
}
7070

7171
impl InconsistentStructConstructor {
7272
pub fn new(conf: &'static Conf) -> Self {
7373
Self {
74-
lint_inconsistent_struct_field_initializers: conf.lint_inconsistent_struct_field_initializers,
74+
check_inconsistent_struct_field_initializers: conf.check_inconsistent_struct_field_initializers,
7575
}
7676
}
7777
}
@@ -86,7 +86,7 @@ impl<'tcx> LateLintPass<'tcx> for InconsistentStructConstructor {
8686
let all_fields_are_shorthand = fields.iter().all(|f| f.is_shorthand);
8787
let applicability = if all_fields_are_shorthand {
8888
Applicability::MachineApplicable
89-
} else if self.lint_inconsistent_struct_field_initializers {
89+
} else if self.check_inconsistent_struct_field_initializers {
9090
Applicability::MaybeIncorrect
9191
} else {
9292
return;
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
lint-inconsistent-struct-field-initializers = true
1+
check-inconsistent-struct-field-initializers = true

tests/ui-toml/toml_unknown_key/conf_unknown_key.stderr

+3
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ error: error reading Clippy's configuration file: unknown field `foobar`, expect
3232
blacklisted-names
3333
cargo-ignore-publish
3434
check-incompatible-msrv-in-tests
35+
check-inconsistent-struct-field-initializers
3536
check-private-items
3637
cognitive-complexity-threshold
3738
cyclomatic-complexity-threshold
@@ -126,6 +127,7 @@ error: error reading Clippy's configuration file: unknown field `barfoo`, expect
126127
blacklisted-names
127128
cargo-ignore-publish
128129
check-incompatible-msrv-in-tests
130+
check-inconsistent-struct-field-initializers
129131
check-private-items
130132
cognitive-complexity-threshold
131133
cyclomatic-complexity-threshold
@@ -220,6 +222,7 @@ error: error reading Clippy's configuration file: unknown field `allow_mixed_uni
220222
blacklisted-names
221223
cargo-ignore-publish
222224
check-incompatible-msrv-in-tests
225+
check-inconsistent-struct-field-initializers
223226
check-private-items
224227
cognitive-complexity-threshold
225228
cyclomatic-complexity-threshold

0 commit comments

Comments
 (0)