Skip to content

Commit aa83de2

Browse files
Merge branch 'master' into unnecessary-min
2 parents e0f3cfb + 4f3180a commit aa83de2

File tree

204 files changed

+2540
-1647
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

204 files changed

+2540
-1647
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5567,6 +5567,7 @@ Released 2018-09-13
55675567
[`needless_borrow`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
55685568
[`needless_borrowed_reference`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrowed_reference
55695569
[`needless_borrows_for_generic_args`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrows_for_generic_args
5570+
[`needless_character_iteration`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_character_iteration
55705571
[`needless_collect`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_collect
55715572
[`needless_continue`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_continue
55725573
[`needless_doctest_main`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_doctest_main
@@ -5912,6 +5913,7 @@ Released 2018-09-13
59125913
[`verbose_file_reads`]: https://rust-lang.github.io/rust-clippy/master/index.html#verbose_file_reads
59135914
[`vtable_address_comparisons`]: https://rust-lang.github.io/rust-clippy/master/index.html#vtable_address_comparisons
59145915
[`waker_clone_wake`]: https://rust-lang.github.io/rust-clippy/master/index.html#waker_clone_wake
5916+
[`while_float`]: https://rust-lang.github.io/rust-clippy/master/index.html#while_float
59155917
[`while_immutable_condition`]: https://rust-lang.github.io/rust-clippy/master/index.html#while_immutable_condition
59165918
[`while_let_loop`]: https://rust-lang.github.io/rust-clippy/master/index.html#while_let_loop
59175919
[`while_let_on_iterator`]: https://rust-lang.github.io/rust-clippy/master/index.html#while_let_on_iterator

book/src/configuration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ Very rarely, you may wish to prevent Clippy from evaluating certain sections of
133133
`clippy` cfg is not set. You may need to provide a stub so that the code compiles:
134134

135135
```rust
136-
#[cfg(not(clippy)]
136+
#[cfg(not(clippy))]
137137
include!(concat!(env!("OUT_DIR"), "/my_big_function-generated.rs"));
138138

139139
#[cfg(clippy)]

book/src/development/adding_lints.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,11 @@ declare_clippy_lint! {
587587
}
588588
```
589589

590+
If the lint is in the `restriction` group because it lints things that are not
591+
necessarily “bad” but are more of a style choice, then replace the
592+
“Why is this bad?” section heading with “Why restrict this?”, to avoid writing
593+
“Why is this bad? It isn't, but ...”.
594+
590595
Once your lint is merged, this documentation will show up in the [lint
591596
list][lint_list].
592597

clippy_dev/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![feature(lazy_cell)]
21
#![feature(let_chains)]
32
#![feature(rustc_private)]
43
#![cfg_attr(feature = "deny-warnings", deny(warnings))]

clippy_dev/src/new_lint.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,12 +331,17 @@ fn get_lint_file_contents(lint: &LintData<'_>, enable_msrv: bool) -> String {
331331
}
332332

333333
fn get_lint_declaration(name_upper: &str, category: &str) -> String {
334+
let justification_heading = if category == "restriction" {
335+
"Why restrict this?"
336+
} else {
337+
"Why is this bad?"
338+
};
334339
formatdoc!(
335340
r#"
336341
declare_clippy_lint! {{
337342
/// ### What it does
338343
///
339-
/// ### Why is this bad?
344+
/// ### {justification_heading}
340345
///
341346
/// ### Example
342347
/// ```no_run

clippy_lints/src/absolute_paths.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ declare_clippy_lint! {
1212
/// ### What it does
1313
/// Checks for usage of items through absolute paths, like `std::env::current_dir`.
1414
///
15-
/// ### Why is this bad?
15+
/// ### Why restrict this?
1616
/// Many codebases have their own style when it comes to importing, but one that is seldom used
1717
/// is using absolute paths *everywhere*. This is generally considered unidiomatic, and you
1818
/// should add a `use` statement.

clippy_lints/src/allow_attributes.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@ declare_clippy_lint! {
1919
/// This lint only warns outer attributes (`#[allow]`), as inner attributes
2020
/// (`#![allow]`) are usually used to enable or disable lints on a global scale.
2121
///
22-
/// ### Why is this bad?
23-
/// `#[expect]` attributes suppress the lint emission, but emit a warning, if
22+
/// ### Why restrict this?
23+
/// `#[allow]` attributes can linger after their reason for existence is gone.
24+
/// `#[expect]` attributes suppress the lint emission, but emit a warning if
2425
/// the expectation is unfulfilled. This can be useful to be notified when the
25-
/// lint is no longer triggered.
26+
/// lint is no longer triggered, which may indicate the attribute can be removed.
2627
///
2728
/// ### Example
2829
/// ```rust,ignore

clippy_lints/src/as_conversions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ declare_clippy_lint! {
1717
/// There is a good explanation the reason why this lint should work in this way and how it is useful
1818
/// [in this issue](https://github.com/rust-lang/rust-clippy/issues/5122).
1919
///
20-
/// ### Why is this bad?
20+
/// ### Why restrict this?
2121
/// `as` conversions will perform many kinds of
2222
/// conversions, including silently lossy conversions and dangerous coercions.
2323
/// There are cases when it makes sense to use `as`, so the lint is

clippy_lints/src/asm_syntax.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,8 @@ declare_clippy_lint! {
6565
/// ### What it does
6666
/// Checks for usage of Intel x86 assembly syntax.
6767
///
68-
/// ### Why is this bad?
69-
/// The lint has been enabled to indicate a preference
70-
/// for AT&T x86 assembly syntax.
68+
/// ### Why restrict this?
69+
/// To enforce consistent use of AT&T x86 assembly syntax.
7170
///
7271
/// ### Example
7372
///
@@ -114,9 +113,8 @@ declare_clippy_lint! {
114113
/// ### What it does
115114
/// Checks for usage of AT&T x86 assembly syntax.
116115
///
117-
/// ### Why is this bad?
118-
/// The lint has been enabled to indicate a preference
119-
/// for Intel x86 assembly syntax.
116+
/// ### Why restrict this?
117+
/// To enforce consistent use of Intel x86 assembly syntax.
120118
///
121119
/// ### Example
122120
///

clippy_lints/src/assertions_on_result_states.rs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,33 @@ declare_clippy_lint! {
1616
/// ### What it does
1717
/// Checks for `assert!(r.is_ok())` or `assert!(r.is_err())` calls.
1818
///
19-
/// ### Why is this bad?
20-
/// An assertion failure cannot output an useful message of the error.
19+
/// ### Why restrict this?
20+
/// This form of assertion does not show any of the information present in the `Result`
21+
/// other than which variant it isn’t.
2122
///
2223
/// ### Known problems
2324
/// The suggested replacement decreases the readability of code and log output.
2425
///
2526
/// ### Example
26-
/// ```rust,ignore
27+
/// ```rust,no_run
2728
/// # let r = Ok::<_, ()>(());
2829
/// assert!(r.is_ok());
29-
/// # let r = Err::<_, ()>(());
30+
/// # let r = Err::<(), _>(());
3031
/// assert!(r.is_err());
3132
/// ```
33+
///
34+
/// Use instead:
35+
///
36+
/// ```rust,no_run
37+
/// # let r = Ok::<_, ()>(());
38+
/// r.unwrap();
39+
/// # let r = Err::<(), _>(());
40+
/// r.unwrap_err();
41+
/// ```
3242
#[clippy::version = "1.64.0"]
3343
pub ASSERTIONS_ON_RESULT_STATES,
3444
restriction,
35-
"`assert!(r.is_ok())`/`assert!(r.is_err())` gives worse error message than directly calling `r.unwrap()`/`r.unwrap_err()`"
45+
"`assert!(r.is_ok())` or `assert!(r.is_err())` gives worse panic messages than directly calling `r.unwrap()` or `r.unwrap_err()`"
3646
}
3747

3848
declare_lint_pass!(AssertionsOnResultStates => [ASSERTIONS_ON_RESULT_STATES]);

clippy_lints/src/attrs/maybe_misused_cfg.rs

Lines changed: 0 additions & 51 deletions
This file was deleted.

clippy_lints/src/attrs/mismatched_target_os.rs

Lines changed: 0 additions & 90 deletions
This file was deleted.

0 commit comments

Comments
 (0)