Skip to content

Commit 4970527

Browse files
committed
Auto merge of #8954 - Serial-ATA:doc-comment-issues, r=xFrednet
Improve lint doc consistency changelog: none This is a continuation of #8908. Notable changes: - Removed empty `Known Problems` sections - Removed "Good"/"Bad" language (replaced with "Use instead") - Removed (and added some 😄) duplication - Ignored the [`create_dir`] example so it doesn't create `clippy_lints/foo` 😄
2 parents 919cf50 + 649ac36 commit 4970527

Some content is hidden

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

66 files changed

+602
-434
lines changed

clippy_lints/src/assertions_on_constants.rs

-3
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ declare_clippy_lint! {
1414
/// Will be optimized out by the compiler or should probably be replaced by a
1515
/// `panic!()` or `unreachable!()`
1616
///
17-
/// ### Known problems
18-
/// None
19-
///
2017
/// ### Example
2118
/// ```rust,ignore
2219
/// assert!(false)

clippy_lints/src/async_yields_async.rs

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ declare_clippy_lint! {
2424
/// };
2525
/// }
2626
/// ```
27+
///
2728
/// Use instead:
2829
/// ```rust
2930
/// async fn foo() {}

clippy_lints/src/await_holding_invalid.rs

-2
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,6 @@ declare_clippy_lint! {
140140
/// from a memory access perspective but will cause bugs at runtime if they
141141
/// are held in such a way.
142142
///
143-
/// ### Known problems
144-
///
145143
/// ### Example
146144
///
147145
/// ```toml

clippy_lints/src/bool_assert_comparison.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,12 @@ declare_clippy_lint! {
1717
///
1818
/// ### Example
1919
/// ```rust
20-
/// // Bad
2120
/// assert_eq!("a".is_empty(), false);
2221
/// assert_ne!("a".is_empty(), true);
22+
/// ```
2323
///
24-
/// // Good
24+
/// Use instead:
25+
/// ```rust
2526
/// assert!(!"a".is_empty());
2627
/// ```
2728
#[clippy::version = "1.53.0"]

clippy_lints/src/borrow_deref_ref.rs

+8-5
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ declare_clippy_lint! {
1818
/// Dereferencing and then borrowing a reference value has no effect in most cases.
1919
///
2020
/// ### Known problems
21-
/// false negative on such code:
21+
/// False negative on such code:
2222
/// ```
2323
/// let x = &12;
2424
/// let addr_x = &x as *const _ as usize;
@@ -29,17 +29,20 @@ declare_clippy_lint! {
2929
///
3030
/// ### Example
3131
/// ```rust
32+
/// fn foo(_x: &str) {}
33+
///
3234
/// let s = &String::new();
3335
///
34-
/// // Bad
3536
/// let a: &String = &* s;
3637
/// foo(&*s);
38+
/// ```
3739
///
38-
/// // Good
40+
/// Use instead:
41+
/// ```rust
42+
/// # fn foo(_x: &str) {}
43+
/// # let s = &String::new();
3944
/// let a: &String = s;
4045
/// foo(&**s);
41-
///
42-
/// fn foo(_: &str){ }
4346
/// ```
4447
#[clippy::version = "1.59.0"]
4548
pub BORROW_DEREF_REF,

clippy_lints/src/casts/mod.rs

+20-12
Original file line numberDiff line numberDiff line change
@@ -219,13 +219,14 @@ declare_clippy_lint! {
219219
///
220220
/// ### Example
221221
/// ```rust
222-
/// // Bad
223222
/// fn fun() -> i32 { 1 }
224-
/// let a = fun as i64;
223+
/// let _ = fun as i64;
224+
/// ```
225225
///
226-
/// // Good
227-
/// fn fun2() -> i32 { 1 }
228-
/// let a = fun2 as usize;
226+
/// Use instead:
227+
/// ```rust
228+
/// # fn fun() -> i32 { 1 }
229+
/// let _ = fun as usize;
229230
/// ```
230231
#[clippy::version = "pre 1.29.0"]
231232
pub FN_TO_NUMERIC_CAST,
@@ -245,17 +246,19 @@ declare_clippy_lint! {
245246
///
246247
/// ### Example
247248
/// ```rust
248-
/// // Bad
249249
/// fn fn1() -> i16 {
250250
/// 1
251251
/// };
252252
/// let _ = fn1 as i32;
253+
/// ```
253254
///
254-
/// // Better: Cast to usize first, then comment with the reason for the truncation
255-
/// fn fn2() -> i16 {
255+
/// Use instead:
256+
/// ```rust
257+
/// // Cast to usize first, then comment with the reason for the truncation
258+
/// fn fn1() -> i16 {
256259
/// 1
257260
/// };
258-
/// let fn_ptr = fn2 as usize;
261+
/// let fn_ptr = fn1 as usize;
259262
/// let fn_ptr_truncated = fn_ptr as i32;
260263
/// ```
261264
#[clippy::version = "pre 1.29.0"]
@@ -277,19 +280,24 @@ declare_clippy_lint! {
277280
///
278281
/// ### Example
279282
/// ```rust
280-
/// // Bad: fn1 is cast as `usize`
283+
/// // fn1 is cast as `usize`
281284
/// fn fn1() -> u16 {
282285
/// 1
283286
/// };
284287
/// let _ = fn1 as usize;
288+
/// ```
285289
///
286-
/// // Good: maybe you intended to call the function?
290+
/// Use instead:
291+
/// ```rust
292+
/// // maybe you intended to call the function?
287293
/// fn fn2() -> u16 {
288294
/// 1
289295
/// };
290296
/// let _ = fn2() as usize;
291297
///
292-
/// // Good: maybe you intended to cast it to a function type?
298+
/// // or
299+
///
300+
/// // maybe you intended to cast it to a function type?
293301
/// fn fn3() -> u16 {
294302
/// 1
295303
/// }

clippy_lints/src/checked_conversions.rs

+4-8
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,14 @@ declare_clippy_lint! {
2222
/// ### Example
2323
/// ```rust
2424
/// # let foo: u32 = 5;
25-
/// # let _ =
26-
/// foo <= i32::MAX as u32
27-
/// # ;
25+
/// foo <= i32::MAX as u32;
2826
/// ```
2927
///
30-
/// Could be written:
31-
///
28+
/// Use instead:
3229
/// ```rust
3330
/// # let foo = 1;
34-
/// # let _ =
35-
/// i32::try_from(foo).is_ok()
36-
/// # ;
31+
/// # #[allow(unused)]
32+
/// i32::try_from(foo).is_ok();
3733
/// ```
3834
#[clippy::version = "1.37.0"]
3935
pub CHECKED_CONVERSIONS,

clippy_lints/src/comparison_chain.rs

-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ declare_clippy_lint! {
3535
/// ```
3636
///
3737
/// Use instead:
38-
///
3938
/// ```rust,ignore
4039
/// use std::cmp::Ordering;
4140
/// # fn a() {}

clippy_lints/src/create_dir.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ declare_clippy_lint! {
1515
/// Sometimes `std::fs::create_dir` is mistakenly chosen over `std::fs::create_dir_all`.
1616
///
1717
/// ### Example
18-
///
19-
/// ```rust
18+
/// ```rust,ignore
2019
/// std::fs::create_dir("foo");
2120
/// ```
21+
///
2222
/// Use instead:
23-
/// ```rust
23+
/// ```rust,ignore
2424
/// std::fs::create_dir_all("foo");
2525
/// ```
2626
#[clippy::version = "1.48.0"]

clippy_lints/src/dbg_macro.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,11 @@ declare_clippy_lint! {
1818
///
1919
/// ### Example
2020
/// ```rust,ignore
21-
/// // Bad
2221
/// dbg!(true)
22+
/// ```
2323
///
24-
/// // Good
24+
/// Use instead:
25+
/// ```rust,ignore
2526
/// true
2627
/// ```
2728
#[clippy::version = "1.34.0"]

clippy_lints/src/default.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,16 @@ declare_clippy_lint! {
1818
/// Checks for literal calls to `Default::default()`.
1919
///
2020
/// ### Why is this bad?
21-
/// It's more clear to the reader to use the name of the type whose default is
22-
/// being gotten than the generic `Default`.
21+
/// It's easier for the reader if the name of the type is used, rather than the
22+
/// generic `Default`.
2323
///
2424
/// ### Example
2525
/// ```rust
26-
/// // Bad
2726
/// let s: String = Default::default();
27+
/// ```
2828
///
29-
/// // Good
29+
/// Use instead:
30+
/// ```rust
3031
/// let s = String::default();
3132
/// ```
3233
#[clippy::version = "pre 1.29.0"]
@@ -47,13 +48,13 @@ declare_clippy_lint! {
4748
/// Assignments to patterns that are of tuple type are not linted.
4849
///
4950
/// ### Example
50-
/// Bad:
5151
/// ```
5252
/// # #[derive(Default)]
5353
/// # struct A { i: i32 }
5454
/// let mut a: A = Default::default();
5555
/// a.i = 42;
5656
/// ```
57+
///
5758
/// Use instead:
5859
/// ```
5960
/// # #[derive(Default)]

clippy_lints/src/dereference.rs

+10-6
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,14 @@ declare_clippy_lint! {
3030
/// let a: &mut String = &mut String::from("foo");
3131
/// let b: &str = a.deref();
3232
/// ```
33-
/// Could be written as:
33+
///
34+
/// Use instead:
3435
/// ```rust
3536
/// let a: &mut String = &mut String::from("foo");
3637
/// let b = &*a;
3738
/// ```
3839
///
39-
/// This lint excludes
40+
/// This lint excludes:
4041
/// ```rust,ignore
4142
/// let _ = d.unwrap().deref();
4243
/// ```
@@ -59,11 +60,13 @@ declare_clippy_lint! {
5960
/// ```rust
6061
/// fn fun(_a: &i32) {}
6162
///
62-
/// // Bad
6363
/// let x: &i32 = &&&&&&5;
6464
/// fun(&x);
65+
/// ```
6566
///
66-
/// // Good
67+
/// Use instead:
68+
/// ```rust
69+
/// # fn fun(_a: &i32) {}
6770
/// let x: &i32 = &5;
6871
/// fun(x);
6972
/// ```
@@ -82,13 +85,14 @@ declare_clippy_lint! {
8285
///
8386
/// ### Example
8487
/// ```rust
85-
/// // Bad
8688
/// let x = Some("");
8789
/// if let Some(ref x) = x {
8890
/// // use `x` here
8991
/// }
92+
/// ```
9093
///
91-
/// // Good
94+
/// Use instead:
95+
/// ```rust
9296
/// let x = Some("");
9397
/// if let Some(x) = x {
9498
/// // use `&x` here

clippy_lints/src/derivable_impls.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ declare_clippy_lint! {
3030
/// }
3131
/// ```
3232
///
33-
/// Could be written as:
34-
///
33+
/// Use instead:
3534
/// ```rust
3635
/// #[derive(Default)]
3736
/// struct Foo {
@@ -45,7 +44,6 @@ declare_clippy_lint! {
4544
/// specialized than what derive will produce. This lint can't detect the manual `impl`
4645
/// has exactly equal bounds, and therefore this lint is disabled for types with
4746
/// generic parameters.
48-
///
4947
#[clippy::version = "1.57.0"]
5048
pub DERIVABLE_IMPLS,
5149
complexity,

clippy_lints/src/enum_variants.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ declare_clippy_lint! {
6060
/// struct BlackForestCake;
6161
/// }
6262
/// ```
63-
/// Could be written as:
63+
///
64+
/// Use instead:
6465
/// ```rust
6566
/// mod cake {
6667
/// struct BlackForest;

clippy_lints/src/eq_op.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,13 @@ declare_clippy_lint! {
5252
/// ### Why is this bad?
5353
/// It is more idiomatic to dereference the other argument.
5454
///
55-
/// ### Known problems
56-
/// None
57-
///
5855
/// ### Example
59-
/// ```ignore
60-
/// // Bad
56+
/// ```rust,ignore
6157
/// &x == y
58+
/// ```
6259
///
63-
/// // Good
60+
/// Use instead:
61+
/// ```rust,ignore
6462
/// x == *y
6563
/// ```
6664
#[clippy::version = "pre 1.29.0"]

clippy_lints/src/eta_reduction.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@ declare_clippy_lint! {
3434
///
3535
/// ### Example
3636
/// ```rust,ignore
37-
/// // Bad
3837
/// xs.map(|x| foo(x))
38+
/// ```
3939
///
40-
/// // Good
40+
/// Use instead:
41+
/// ```rust,ignore
42+
/// // where `foo(_)` is a plain function that takes the exact argument type of `x`.
4143
/// xs.map(foo)
4244
/// ```
43-
/// where `foo(_)` is a plain function that takes the exact argument type of
44-
/// `x`.
4545
#[clippy::version = "pre 1.29.0"]
4646
pub REDUNDANT_CLOSURE,
4747
style,

clippy_lints/src/excessive_bools.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,11 @@ declare_clippy_lint! {
5454
/// API easier to use.
5555
///
5656
/// ### Example
57-
/// Bad:
5857
/// ```rust,ignore
5958
/// fn f(is_round: bool, is_hot: bool) { ... }
6059
/// ```
6160
///
62-
/// Good:
61+
/// Use instead:
6362
/// ```rust,ignore
6463
/// enum Shape {
6564
/// Round,

clippy_lints/src/float_literal.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,11 @@ declare_clippy_lint! {
4545
///
4646
/// ### Example
4747
/// ```rust
48-
/// // Bad
4948
/// let _: f32 = 16_777_217.0; // 16_777_216.0
49+
/// ```
5050
///
51-
/// // Good
51+
/// Use instead:
52+
/// ```rust
5253
/// let _: f32 = 16_777_216.0;
5354
/// let _: f64 = 16_777_217.0;
5455
/// ```

0 commit comments

Comments
 (0)