Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit cfd0f55

Browse files
committed
Make docs more consistent
1 parent 5920fa3 commit cfd0f55

29 files changed

+109
-68
lines changed

clippy_lints/src/approx_const.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ declare_clippy_lint! {
2828
/// let x = 3.14;
2929
/// let y = 1_f64 / x;
3030
/// ```
31-
/// Use predefined constants instead:
31+
/// Use instead:
3232
/// ```rust
3333
/// let x = std::f32::consts::PI;
3434
/// let y = std::f64::consts::FRAC_1_PI;

clippy_lints/src/as_conversions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ declare_clippy_lint! {
2929
/// f(a as u16);
3030
/// ```
3131
///
32-
/// Usually better represents the semantics you expect:
32+
/// Use instead:
3333
/// ```rust,ignore
3434
/// f(a.try_into()?);
3535
/// ```

clippy_lints/src/assign_ops.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,16 @@ declare_clippy_lint! {
2727
/// let mut a = 5;
2828
/// let b = 0;
2929
/// // ...
30-
/// // Bad
30+
///
3131
/// a = a + b;
32+
/// ```
33+
///
34+
/// Use instead:
35+
/// ```rust
36+
/// let mut a = 5;
37+
/// let b = 0;
38+
/// // ...
3239
///
33-
/// // Good
3440
/// a += b;
3541
/// ```
3642
#[clippy::version = "pre 1.29.0"]

clippy_lints/src/attrs.rs

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,14 @@ declare_clippy_lint! {
8989
///
9090
/// ### Example
9191
/// ```ignore
92-
/// // Bad
9392
/// #[deny(dead_code)]
9493
/// extern crate foo;
9594
/// #[forbid(dead_code)]
9695
/// use foo::bar;
96+
/// ```
9797
///
98-
/// // Ok
98+
/// Use instead:
99+
/// ```rust,ignore
99100
/// #[allow(unused_imports)]
100101
/// use foo::baz;
101102
/// #[allow(unused_imports)]
@@ -146,15 +147,19 @@ declare_clippy_lint! {
146147
///
147148
/// ### Example
148149
/// ```rust
150+
/// #[allow(dead_code)]
151+
///
152+
/// fn not_quite_good_code() { }
153+
/// ```
154+
///
155+
/// Use instead:
156+
/// ```rust
149157
/// // Good (as inner attribute)
150158
/// #![allow(dead_code)]
151159
///
152160
/// fn this_is_fine() { }
153161
///
154-
/// // Bad
155-
/// #[allow(dead_code)]
156-
///
157-
/// fn not_quite_good_code() { }
162+
/// // or
158163
///
159164
/// // Good (as outer attribute)
160165
/// #[allow(dead_code)]
@@ -175,12 +180,11 @@ declare_clippy_lint! {
175180
/// These lints should only be enabled on a lint-by-lint basis and with careful consideration.
176181
///
177182
/// ### Example
178-
/// Bad:
179183
/// ```rust
180184
/// #![deny(clippy::restriction)]
181185
/// ```
182186
///
183-
/// Good:
187+
/// Use instead:
184188
/// ```rust
185189
/// #![deny(clippy::as_conversions)]
186190
/// ```
@@ -205,13 +209,12 @@ declare_clippy_lint! {
205209
/// [#3123](https://github.com/rust-lang/rust-clippy/pull/3123#issuecomment-422321765)
206210
///
207211
/// ### Example
208-
/// Bad:
209212
/// ```rust
210213
/// #[cfg_attr(rustfmt, rustfmt_skip)]
211214
/// fn main() { }
212215
/// ```
213216
///
214-
/// Good:
217+
/// Use instead:
215218
/// ```rust
216219
/// #[rustfmt::skip]
217220
/// fn main() { }
@@ -231,19 +234,19 @@ declare_clippy_lint! {
231234
/// by the conditional compilation engine.
232235
///
233236
/// ### Example
234-
/// Bad:
235237
/// ```rust
236238
/// #[cfg(linux)]
237239
/// fn conditional() { }
238240
/// ```
239241
///
240-
/// Good:
242+
/// Use instead:
241243
/// ```rust
242244
/// #[cfg(target_os = "linux")]
243245
/// fn conditional() { }
244246
/// ```
245247
///
246-
/// Or:
248+
/// or
249+
///
247250
/// ```rust
248251
/// #[cfg(unix)]
249252
/// fn conditional() { }
@@ -266,14 +269,13 @@ declare_clippy_lint! {
266269
/// ensure that others understand the reasoning
267270
///
268271
/// ### Example
269-
/// Bad:
270272
/// ```rust
271273
/// #![feature(lint_reasons)]
272274
///
273275
/// #![allow(clippy::some_lint)]
274276
/// ```
275277
///
276-
/// Good:
278+
/// Use instead:
277279
/// ```rust
278280
/// #![feature(lint_reasons)]
279281
///

clippy_lints/src/blocks_in_if_conditions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ declare_clippy_lint! {
2929
/// if true { /* ... */ }
3030
/// ```
3131
///
32-
/// // or
32+
/// or
3333
///
3434
/// ```rust
3535
/// # fn somefunc() -> bool { true };

clippy_lints/src/booleans.rs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,14 @@ declare_clippy_lint! {
2727
///
2828
/// ### Example
2929
/// ```ignore
30-
/// if a && true // should be: if a
31-
/// if !(a == b) // should be: if a != b
30+
/// if a && true {}
31+
/// if !(a == b) {}
32+
/// ```
33+
///
34+
/// Use instead:
35+
/// ```rust,ignore
36+
/// if a {}
37+
/// if a != b {}
3238
/// ```
3339
#[clippy::version = "pre 1.29.0"]
3440
pub NONMINIMAL_BOOL,
@@ -48,10 +54,15 @@ declare_clippy_lint! {
4854
/// Ignores short circuiting behavior.
4955
///
5056
/// ### Example
51-
/// ```ignore
57+
/// ```rust,ignore
58+
/// // The `b` is unnecessary, the expression is equivalent to `if a`.
5259
/// if a && b || a { ... }
5360
/// ```
54-
/// The `b` is unnecessary, the expression is equivalent to `if a`.
61+
///
62+
/// Use instead:
63+
/// ```rust,ignore
64+
/// if a {}
65+
/// ```
5566
#[clippy::version = "pre 1.29.0"]
5667
pub LOGIC_BUG,
5768
correctness,

clippy_lints/src/bytecount.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,13 @@ declare_clippy_lint! {
2828
/// ### Example
2929
/// ```rust
3030
/// # let vec = vec![1_u8];
31-
/// &vec.iter().filter(|x| **x == 0u8).count(); // use bytecount::count instead
31+
/// let count = vec.iter().filter(|x| **x == 0u8).count();
32+
/// ```
33+
///
34+
/// Use instead:
35+
/// ```rust,ignore
36+
/// # let vec = vec![1_u8];
37+
/// let count = bytecount::count(&vec, 0u8);
3238
/// ```
3339
#[clippy::version = "pre 1.29.0"]
3440
pub NAIVE_BYTECOUNT,

clippy_lints/src/cognitive_complexity.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ declare_clippy_lint! {
2525
/// complexity.
2626
///
2727
/// ### Example
28-
/// No. You'll see it when you get the warning.
28+
/// You'll see it when you get the warning.
2929
#[clippy::version = "1.35.0"]
3030
pub COGNITIVE_COMPLEXITY,
3131
nursery,

clippy_lints/src/collapsible_if.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ declare_clippy_lint! {
4141
///
4242
/// ```
4343
///
44-
/// Should be written:
44+
/// Use instead:
4545
///
4646
/// ```rust,ignore
4747
/// if x && y {

clippy_lints/src/comparison_chain.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ declare_clippy_lint! {
3434
/// }
3535
/// ```
3636
///
37-
/// Could be written:
37+
/// Use instead:
3838
///
3939
/// ```rust,ignore
4040
/// use std::cmp::Ordering;

0 commit comments

Comments
 (0)