Skip to content

Commit 0d5ace3

Browse files
committed
Auto merge of rust-lang#8908 - Serial-ATA:doc-comment-issues, r=xFrednet
Make docs more consistent changelog: none This just fixes some docs to make them more consistent. I mostly just changed `// Good`, `// Bad`, etc to `Use instead:`.
2 parents 7572b6b + b20f95c commit 0d5ace3

36 files changed

+197
-177
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: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,14 @@ 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()?);
35-
/// ```
36-
/// or
37-
/// ```rust,ignore
35+
///
36+
/// // or
37+
///
3838
/// f(a.try_into().expect("Unexpected u16 overflow in f"));
3939
/// ```
40-
///
4140
#[clippy::version = "1.41.0"]
4241
pub AS_CONVERSIONS,
4342
restriction,

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: 19 additions & 17 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,20 +234,20 @@ 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
244+
/// # mod hidden {
242245
/// #[cfg(target_os = "linux")]
243246
/// fn conditional() { }
244-
/// ```
247+
/// # }
248+
///
249+
/// // or
245250
///
246-
/// Or:
247-
/// ```rust
248251
/// #[cfg(unix)]
249252
/// fn conditional() { }
250253
/// ```
@@ -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: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,17 @@ declare_clippy_lint! {
2222
///
2323
/// ### Examples
2424
/// ```rust
25-
/// // Bad
25+
/// # fn somefunc() -> bool { true };
2626
/// if { true } { /* ... */ }
2727
///
28-
/// // Good
29-
/// if true { /* ... */ }
28+
/// if { let x = somefunc(); x } { /* ... */ }
3029
/// ```
3130
///
32-
/// // or
33-
///
31+
/// Use instead:
3432
/// ```rust
3533
/// # fn somefunc() -> bool { true };
36-
/// // Bad
37-
/// if { let x = somefunc(); x } { /* ... */ }
34+
/// if true { /* ... */ }
3835
///
39-
/// // Good
4036
/// let res = { let x = somefunc(); x };
4137
/// if res { /* ... */ }
4238
/// ```

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;

clippy_lints/src/copies.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ declare_clippy_lint! {
141141
/// };
142142
/// ```
143143
///
144-
/// Could be written as:
144+
/// Use instead:
145145
/// ```ignore
146146
/// println!("Hello World");
147147
/// let foo = if … {

clippy_lints/src/derivable_impls.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ declare_clippy_lint! {
2121
/// bar: bool
2222
/// }
2323
///
24-
/// impl std::default::Default for Foo {
24+
/// impl Default for Foo {
2525
/// fn default() -> Self {
2626
/// Self {
2727
/// bar: false

clippy_lints/src/double_comparison.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ declare_clippy_lint! {
2424
/// if x == y || x < y {}
2525
/// ```
2626
///
27-
/// Could be written as:
27+
/// Use instead:
2828
///
2929
/// ```rust
3030
/// # let x = 1;

clippy_lints/src/double_parens.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,21 @@ declare_clippy_lint! {
1313
///
1414
/// ### Example
1515
/// ```rust
16-
/// // Bad
1716
/// fn simple_double_parens() -> i32 {
1817
/// ((0))
1918
/// }
2019
///
21-
/// // Good
20+
/// # fn foo(bar: usize) {}
21+
/// foo((0));
22+
/// ```
23+
///
24+
/// Use instead:
25+
/// ```rust
2226
/// fn simple_no_parens() -> i32 {
2327
/// 0
2428
/// }
2529
///
26-
/// // or
27-
///
2830
/// # fn foo(bar: usize) {}
29-
/// // Bad
30-
/// foo((0));
31-
///
32-
/// // Good
3331
/// foo(0);
3432
/// ```
3533
#[clippy::version = "pre 1.29.0"]

clippy_lints/src/duration_subsec.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,17 @@ declare_clippy_lint! {
2222
/// ### Example
2323
/// ```rust
2424
/// # use std::time::Duration;
25-
/// let dur = Duration::new(5, 0);
26-
///
27-
/// // Bad
28-
/// let _micros = dur.subsec_nanos() / 1_000;
29-
/// let _millis = dur.subsec_nanos() / 1_000_000;
25+
/// # let duration = Duration::new(5, 0);
26+
/// let micros = duration.subsec_nanos() / 1_000;
27+
/// let millis = duration.subsec_nanos() / 1_000_000;
28+
/// ```
3029
///
31-
/// // Good
32-
/// let _micros = dur.subsec_micros();
33-
/// let _millis = dur.subsec_millis();
30+
/// Use instead:
31+
/// ```rust
32+
/// # use std::time::Duration;
33+
/// # let duration = Duration::new(5, 0);
34+
/// let micros = duration.subsec_micros();
35+
/// let millis = duration.subsec_millis();
3436
/// ```
3537
#[clippy::version = "pre 1.29.0"]
3638
pub DURATION_SUBSEC,

clippy_lints/src/else_if_without_else.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ declare_clippy_lint! {
2626
/// }
2727
/// ```
2828
///
29-
/// Could be written:
29+
/// Use instead:
3030
///
3131
/// ```rust
3232
/// # fn a() {}

clippy_lints/src/empty_enum.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,11 @@ declare_clippy_lint! {
2323
///
2424
///
2525
/// ### Example
26-
/// Bad:
2726
/// ```rust
2827
/// enum Test {}
2928
/// ```
3029
///
31-
/// Good:
30+
/// Use instead:
3231
/// ```rust
3332
/// #![feature(never_type)]
3433
///

clippy_lints/src/entry.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ declare_clippy_lint! {
4646
/// map.insert(k, v);
4747
/// }
4848
/// ```
49-
/// can both be rewritten as:
49+
/// Use instead:
5050
/// ```rust
5151
/// # use std::collections::HashMap;
5252
/// # let mut map = HashMap::new();

clippy_lints/src/enum_variants.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ declare_clippy_lint! {
3232
/// BattenbergCake,
3333
/// }
3434
/// ```
35-
/// Could be written as:
35+
/// Use instead:
3636
/// ```rust
3737
/// enum Cake {
3838
/// BlackForest,

clippy_lints/src/eq_op.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ declare_clippy_lint! {
3030
/// ```rust
3131
/// # let x = 1;
3232
/// if x + 1 == x + 1 {}
33-
/// ```
34-
/// or
35-
/// ```rust
33+
///
34+
/// // or
35+
///
3636
/// # let a = 3;
3737
/// # let b = 4;
3838
/// assert_eq!(a, a);

0 commit comments

Comments
 (0)