Skip to content

Commit 464c85c

Browse files
authored
Rollup merge of #7420 - xFrednet:7172-update-lint-documentation, r=flip1995
Update lint documentation to use markdown headlines This PR updates all lint documentation to use markdown headlines. It additionally removed the *Known problems* section for lints without any problems. I've double-checked all automatic replacements, but a second pair of eyes is definitely appreciated! I wasn't sure when you wanted to switch to the new metadata collection tomorrow, I therefore prepared this PR today. And that's it this is a standalone PR to keep the other related PRs reviewable. changelog: none r? `@flip1995` cc: #7172 Note: This should be merged with the other metadata collection related PRs.
2 parents bcdf147 + 9bc5803 commit 464c85c

File tree

230 files changed

+2718
-2475
lines changed

Some content is hidden

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

230 files changed

+2718
-2475
lines changed

clippy_dev/src/new_lint.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -169,14 +169,11 @@ use rustc_session::{{declare_lint_pass, declare_tool_lint}};
169169
{pass_import}
170170
171171
declare_clippy_lint! {{
172-
/// **What it does:**
172+
/// ### What it does
173173
///
174-
/// **Why is this bad?**
175-
///
176-
/// **Known problems:** None.
177-
///
178-
/// **Example:**
174+
/// ### Why is this bad?
179175
///
176+
/// ### Example
180177
/// ```rust
181178
/// // example code where clippy issues a warning
182179
/// ```

clippy_lints/src/absurd_extreme_comparisons.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,26 @@ use clippy_utils::ty::is_isize_or_usize;
1111
use clippy_utils::{clip, int_bits, unsext};
1212

1313
declare_clippy_lint! {
14-
/// **What it does:** Checks for comparisons where one side of the relation is
14+
/// ### What it does
15+
/// Checks for comparisons where one side of the relation is
1516
/// either the minimum or maximum value for its type and warns if it involves a
1617
/// case that is always true or always false. Only integer and boolean types are
1718
/// checked.
1819
///
19-
/// **Why is this bad?** An expression like `min <= x` may misleadingly imply
20+
/// ### Why is this bad?
21+
/// An expression like `min <= x` may misleadingly imply
2022
/// that it is possible for `x` to be less than the minimum. Expressions like
2123
/// `max < x` are probably mistakes.
2224
///
23-
/// **Known problems:** For `usize` the size of the current compile target will
25+
/// ### Known problems
26+
/// For `usize` the size of the current compile target will
2427
/// be assumed (e.g., 64 bits on 64 bit systems). This means code that uses such
2528
/// a comparison to detect target pointer width will trigger this lint. One can
2629
/// use `mem::sizeof` and compare its value or conditional compilation
2730
/// attributes
2831
/// like `#[cfg(target_pointer_width = "64")] ..` instead.
2932
///
30-
/// **Example:**
31-
///
33+
/// ### Example
3234
/// ```rust
3335
/// let vec: Vec<isize> = Vec::new();
3436
/// if vec.len() <= 0 {}

clippy_lints/src/approx_const.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,21 @@ use rustc_span::symbol;
77
use std::f64::consts as f64;
88

99
declare_clippy_lint! {
10-
/// **What it does:** Checks for floating point literals that approximate
10+
/// ### What it does
11+
/// Checks for floating point literals that approximate
1112
/// constants which are defined in
1213
/// [`std::f32::consts`](https://doc.rust-lang.org/stable/std/f32/consts/#constants)
1314
/// or
1415
/// [`std::f64::consts`](https://doc.rust-lang.org/stable/std/f64/consts/#constants),
1516
/// respectively, suggesting to use the predefined constant.
1617
///
17-
/// **Why is this bad?** Usually, the definition in the standard library is more
18+
/// ### Why is this bad?
19+
/// Usually, the definition in the standard library is more
1820
/// precise than what people come up with. If you find that your definition is
1921
/// actually more precise, please [file a Rust
2022
/// issue](https://github.com/rust-lang/rust/issues).
2123
///
22-
/// **Known problems:** None.
23-
///
24-
/// **Example:**
24+
/// ### Example
2525
/// ```rust
2626
/// let x = 3.14;
2727
/// let y = 1_f64 / x;

clippy_lints/src/arithmetic.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,21 @@ use rustc_session::{declare_tool_lint, impl_lint_pass};
66
use rustc_span::source_map::Span;
77

88
declare_clippy_lint! {
9-
/// **What it does:** Checks for integer arithmetic operations which could overflow or panic.
9+
/// ### What it does
10+
/// Checks for integer arithmetic operations which could overflow or panic.
1011
///
1112
/// Specifically, checks for any operators (`+`, `-`, `*`, `<<`, etc) which are capable
1213
/// of overflowing according to the [Rust
1314
/// Reference](https://doc.rust-lang.org/reference/expressions/operator-expr.html#overflow),
1415
/// or which can panic (`/`, `%`). No bounds analysis or sophisticated reasoning is
1516
/// attempted.
1617
///
17-
/// **Why is this bad?** Integer overflow will trigger a panic in debug builds or will wrap in
18+
/// ### Why is this bad?
19+
/// Integer overflow will trigger a panic in debug builds or will wrap in
1820
/// release mode. Division by zero will cause a panic in either mode. In some applications one
1921
/// wants explicitly checked, wrapping or saturating arithmetic.
2022
///
21-
/// **Known problems:** None.
22-
///
23-
/// **Example:**
23+
/// ### Example
2424
/// ```rust
2525
/// # let a = 0;
2626
/// a + 1;
@@ -31,14 +31,14 @@ declare_clippy_lint! {
3131
}
3232

3333
declare_clippy_lint! {
34-
/// **What it does:** Checks for float arithmetic.
34+
/// ### What it does
35+
/// Checks for float arithmetic.
3536
///
36-
/// **Why is this bad?** For some embedded systems or kernel development, it
37+
/// ### Why is this bad?
38+
/// For some embedded systems or kernel development, it
3739
/// can be useful to rule out floating-point numbers.
3840
///
39-
/// **Known problems:** None.
40-
///
41-
/// **Example:**
41+
/// ### Example
4242
/// ```rust
4343
/// # let a = 0.0;
4444
/// a + 1.0;

clippy_lints/src/as_conversions.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ use rustc_middle::lint::in_external_macro;
55
use rustc_session::{declare_lint_pass, declare_tool_lint};
66

77
declare_clippy_lint! {
8-
/// **What it does:** Checks for usage of `as` conversions.
8+
/// ### What it does
9+
/// Checks for usage of `as` conversions.
910
///
1011
/// Note that this lint is specialized in linting *every single* use of `as`
1112
/// regardless of whether good alternatives exist or not.
@@ -15,14 +16,13 @@ declare_clippy_lint! {
1516
/// There is a good explanation the reason why this lint should work in this way and how it is useful
1617
/// [in this issue](https://github.com/rust-lang/rust-clippy/issues/5122).
1718
///
18-
/// **Why is this bad?** `as` conversions will perform many kinds of
19+
/// ### Why is this bad?
20+
/// `as` conversions will perform many kinds of
1921
/// conversions, including silently lossy conversions and dangerous coercions.
2022
/// There are cases when it makes sense to use `as`, so the lint is
2123
/// Allow by default.
2224
///
23-
/// **Known problems:** None.
24-
///
25-
/// **Example:**
25+
/// ### Example
2626
/// ```rust,ignore
2727
/// let a: u32;
2828
/// ...

clippy_lints/src/asm_syntax.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,14 @@ fn check_expr_asm_syntax(lint: &'static Lint, cx: &EarlyContext<'_>, expr: &Expr
5353
}
5454

5555
declare_clippy_lint! {
56-
/// **What it does:** Checks for usage of Intel x86 assembly syntax.
56+
/// ### What it does
57+
/// Checks for usage of Intel x86 assembly syntax.
5758
///
58-
/// **Why is this bad?** The lint has been enabled to indicate a preference
59+
/// ### Why is this bad?
60+
/// The lint has been enabled to indicate a preference
5961
/// for AT&T x86 assembly syntax.
6062
///
61-
/// **Known problems:** None.
62-
///
63-
/// **Example:**
63+
/// ### Example
6464
///
6565
/// ```rust,no_run
6666
/// # #![feature(asm)]
@@ -89,14 +89,14 @@ impl EarlyLintPass for InlineAsmX86IntelSyntax {
8989
}
9090

9191
declare_clippy_lint! {
92-
/// **What it does:** Checks for usage of AT&T x86 assembly syntax.
92+
/// ### What it does
93+
/// Checks for usage of AT&T x86 assembly syntax.
9394
///
94-
/// **Why is this bad?** The lint has been enabled to indicate a preference
95+
/// ### Why is this bad?
96+
/// The lint has been enabled to indicate a preference
9597
/// for Intel x86 assembly syntax.
9698
///
97-
/// **Known problems:** None.
98-
///
99-
/// **Example:**
99+
/// ### Example
100100
///
101101
/// ```rust,no_run
102102
/// # #![feature(asm)]

clippy_lints/src/assertions_on_constants.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,17 @@ use rustc_lint::{LateContext, LateLintPass};
88
use rustc_session::{declare_lint_pass, declare_tool_lint};
99

1010
declare_clippy_lint! {
11-
/// **What it does:** Checks for `assert!(true)` and `assert!(false)` calls.
11+
/// ### What it does
12+
/// Checks for `assert!(true)` and `assert!(false)` calls.
1213
///
13-
/// **Why is this bad?** Will be optimized out by the compiler or should probably be replaced by a
14+
/// ### Why is this bad?
15+
/// Will be optimized out by the compiler or should probably be replaced by a
1416
/// `panic!()` or `unreachable!()`
1517
///
16-
/// **Known problems:** None
18+
/// ### Known problems
19+
/// None
1720
///
18-
/// **Example:**
21+
/// ### Example
1922
/// ```rust,ignore
2023
/// assert!(false)
2124
/// assert!(true)

clippy_lints/src/assign_ops.rs

+14-8
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,18 @@ use rustc_middle::hir::map::Map;
1212
use rustc_session::{declare_lint_pass, declare_tool_lint};
1313

1414
declare_clippy_lint! {
15-
/// **What it does:** Checks for `a = a op b` or `a = b commutative_op a`
15+
/// ### What it does
16+
/// Checks for `a = a op b` or `a = b commutative_op a`
1617
/// patterns.
1718
///
18-
/// **Why is this bad?** These can be written as the shorter `a op= b`.
19+
/// ### Why is this bad?
20+
/// These can be written as the shorter `a op= b`.
1921
///
20-
/// **Known problems:** While forbidden by the spec, `OpAssign` traits may have
22+
/// ### Known problems
23+
/// While forbidden by the spec, `OpAssign` traits may have
2124
/// implementations that differ from the regular `Op` impl.
2225
///
23-
/// **Example:**
26+
/// ### Example
2427
/// ```rust
2528
/// let mut a = 5;
2629
/// let b = 0;
@@ -37,17 +40,20 @@ declare_clippy_lint! {
3740
}
3841

3942
declare_clippy_lint! {
40-
/// **What it does:** Checks for `a op= a op b` or `a op= b op a` patterns.
43+
/// ### What it does
44+
/// Checks for `a op= a op b` or `a op= b op a` patterns.
4145
///
42-
/// **Why is this bad?** Most likely these are bugs where one meant to write `a
46+
/// ### Why is this bad?
47+
/// Most likely these are bugs where one meant to write `a
4348
/// op= b`.
4449
///
45-
/// **Known problems:** Clippy cannot know for sure if `a op= a op b` should have
50+
/// ### Known problems
51+
/// Clippy cannot know for sure if `a op= a op b` should have
4652
/// been `a = a op a op b` or `a = a op b`/`a op= b`. Therefore, it suggests both.
4753
/// If `a op= a op b` is really the correct behaviour it should be
4854
/// written as `a = a op a op b` as it's less confusing.
4955
///
50-
/// **Example:**
56+
/// ### Example
5157
/// ```rust
5258
/// let mut a = 5;
5359
/// let b = 2;

clippy_lints/src/async_yields_async.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,14 @@ use rustc_lint::{LateContext, LateLintPass};
77
use rustc_session::{declare_lint_pass, declare_tool_lint};
88

99
declare_clippy_lint! {
10-
/// **What it does:** Checks for async blocks that yield values of types
10+
/// ### What it does
11+
/// Checks for async blocks that yield values of types
1112
/// that can themselves be awaited.
1213
///
13-
/// **Why is this bad?** An await is likely missing.
14-
///
15-
/// **Known problems:** None.
16-
///
17-
/// **Example:**
14+
/// ### Why is this bad?
15+
/// An await is likely missing.
1816
///
17+
/// ### Example
1918
/// ```rust
2019
/// async fn foo() {}
2120
///

clippy_lints/src/atomic_ordering.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@ use rustc_middle::ty;
88
use rustc_session::{declare_lint_pass, declare_tool_lint};
99

1010
declare_clippy_lint! {
11-
/// **What it does:** Checks for usage of invalid atomic
11+
/// ### What it does
12+
/// Checks for usage of invalid atomic
1213
/// ordering in atomic loads/stores/exchanges/updates and
1314
/// memory fences.
1415
///
15-
/// **Why is this bad?** Using an invalid atomic ordering
16+
/// ### Why is this bad?
17+
/// Using an invalid atomic ordering
1618
/// will cause a panic at run-time.
1719
///
18-
/// **Known problems:** None.
19-
///
20-
/// **Example:**
20+
/// ### Example
2121
/// ```rust,no_run
2222
/// # use std::sync::atomic::{self, AtomicU8, Ordering};
2323
///

0 commit comments

Comments
 (0)