Skip to content

Commit b80ee52

Browse files
committed
lint-inconsistent-... -> check-inconsistent...
1 parent a9c61ec commit b80ee52

File tree

6 files changed

+56
-51
lines changed

6 files changed

+56
-51
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6345,6 +6345,7 @@ Released 2018-09-13
63456345
[`await-holding-invalid-types`]: https://doc.rust-lang.org/clippy/lint_configuration.html#await-holding-invalid-types
63466346
[`cargo-ignore-publish`]: https://doc.rust-lang.org/clippy/lint_configuration.html#cargo-ignore-publish
63476347
[`check-incompatible-msrv-in-tests`]: https://doc.rust-lang.org/clippy/lint_configuration.html#check-incompatible-msrv-in-tests
6348+
[`check-inconsistent-struct-field-initializers`]: https://doc.rust-lang.org/clippy/lint_configuration.html#check-inconsistent-struct-field-initializers
63486349
[`check-private-items`]: https://doc.rust-lang.org/clippy/lint_configuration.html#check-private-items
63496350
[`cognitive-complexity-threshold`]: https://doc.rust-lang.org/clippy/lint_configuration.html#cognitive-complexity-threshold
63506351
[`disallowed-macros`]: https://doc.rust-lang.org/clippy/lint_configuration.html#disallowed-macros
@@ -6361,7 +6362,6 @@ Released 2018-09-13
63616362
[`future-size-threshold`]: https://doc.rust-lang.org/clippy/lint_configuration.html#future-size-threshold
63626363
[`ignore-interior-mutability`]: https://doc.rust-lang.org/clippy/lint_configuration.html#ignore-interior-mutability
63636364
[`large-error-threshold`]: https://doc.rust-lang.org/clippy/lint_configuration.html#large-error-threshold
6364-
[`lint-inconsistent-struct-field-initializers`]: https://doc.rust-lang.org/clippy/lint_configuration.html#lint-inconsistent-struct-field-initializers
63656365
[`literal-representation-threshold`]: https://doc.rust-lang.org/clippy/lint_configuration.html#literal-representation-threshold
63666366
[`matches-for-let-else`]: https://doc.rust-lang.org/clippy/lint_configuration.html#matches-for-let-else
63676367
[`max-fn-params-bools`]: https://doc.rust-lang.org/clippy/lint_configuration.html#max-fn-params-bools

book/src/lint_configuration.md

Lines changed: 27 additions & 27 deletions
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

@@ -613,33 +640,6 @@ The maximum size of the `Err`-variant in a `Result` returned from a function
613640
* [`result_large_err`](https://rust-lang.github.io/rust-clippy/master/index.html#result_large_err)
614641

615642

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

clippy.toml

Lines changed: 1 addition & 1 deletion
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

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,26 @@ define_Conf! {
467467
/// Whether to check MSRV compatibility in `#[test]` and `#[cfg(test)]` code.
468468
#[lints(incompatible_msrv)]
469469
check_incompatible_msrv_in_tests: bool = false,
470+
/// Whether to suggest reordering constructor fields when initializers are present.
471+
///
472+
/// Warnings produced by this configuration aren't necessarily fixed by just reordering the fields. Even if the
473+
/// suggested code would compile, it can change semantics if the initializer expressions have side effects. The
474+
/// following example [from rust-clippy#11846] shows how the suggestion can run into borrow check errors:
475+
///
476+
/// ```rust
477+
/// struct MyStruct {
478+
/// vector: Vec<u32>,
479+
/// length: usize
480+
/// }
481+
/// fn main() {
482+
/// let vector = vec![1,2,3];
483+
/// MyStruct { length: vector.len(), vector};
484+
/// }
485+
/// ```
486+
///
487+
/// [from rust-clippy#11846]: https://github.com/rust-lang/rust-clippy/issues/11846#issuecomment-1820747924
488+
#[lints(inconsistent_struct_constructor)]
489+
check_inconsistent_struct_field_initializers: bool = false,
470490
/// Whether to also run the listed lints on private items.
471491
#[lints(missing_errors_doc, missing_panics_doc, missing_safety_doc, unnecessary_safety_doc)]
472492
check_private_items: bool = false,
@@ -542,25 +562,10 @@ define_Conf! {
542562
/// The maximum size of the `Err`-variant in a `Result` returned from a function
543563
#[lints(result_large_err)]
544564
large_error_threshold: u64 = 128,
545-
/// Whether to suggest reordering constructor fields when initializers are present.
546-
///
547-
/// Warnings produced by this configuration aren't necessarily fixed by just reordering the fields. Even if the
548-
/// suggested code would compile, it can change semantics if the initializer expressions have side effects. The
549-
/// following example [from rust-clippy#11846] shows how the suggestion can run into borrow check errors:
550-
///
551-
/// ```rust
552-
/// struct MyStruct {
553-
/// vector: Vec<u32>,
554-
/// length: usize
555-
/// }
556-
/// fn main() {
557-
/// let vector = vec![1,2,3];
558-
/// MyStruct { length: vector.len(), vector};
559-
/// }
560-
/// ```
565+
/// DEPRECATED CONFIGURATION: lint-inconsistent-struct-field-initializers
561566
///
562-
/// [from rust-clippy#11846]: https://github.com/rust-lang/rust-clippy/issues/11846#issuecomment-1820747924
563-
#[lints(inconsistent_struct_constructor)]
567+
/// Use the `check-inconsistent-struct-field-initializers` configuration instead.
568+
#[conf_deprecated("Please use `check-inconsistent-struct-field-initializers` instead", check_inconsistent_struct_field_initializers)]
564569
lint_inconsistent_struct_field_initializers: bool = false,
565570
/// The lower bound for linting decimal literals
566571
#[lints(decimal_literal_representation)]

clippy_lints/src/inconsistent_struct_constructor.rs

Lines changed: 3 additions & 3 deletions
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;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
lint-inconsistent-struct-field-initializers = true
1+
check-inconsistent-struct-field-initializers = true

0 commit comments

Comments
 (0)