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

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

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

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

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

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

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

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

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

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

Lines changed: 3 additions & 2 deletions
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"]

0 commit comments

Comments
 (0)