Skip to content

Commit dd522e6

Browse files
committed
fix or ignore failing doc tests
1 parent d854e03 commit dd522e6

Some content is hidden

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

44 files changed

+137
-127
lines changed

clippy_lints/src/assertions_on_constants.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ declare_clippy_lint! {
1515
/// **Known problems:** None
1616
///
1717
/// **Example:**
18-
/// ```rust
19-
/// assert!(false)
18+
/// ```no_run
19+
/// assert!(false);
2020
/// // or
21-
/// assert!(true)
21+
/// assert!(true);
2222
/// // or
2323
/// const B: bool = false;
24-
/// assert!(B)
24+
/// assert!(B);
2525
/// ```
2626
pub ASSERTIONS_ON_CONSTANTS,
2727
style,

clippy_lints/src/assign_ops.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ declare_clippy_lint! {
1717
/// implementations that differ from the regular `Op` impl.
1818
///
1919
/// **Example:**
20-
/// ```rust
20+
/// ```ignore
2121
/// let mut a = 5;
2222
/// ...
2323
/// a = a + b;
@@ -39,7 +39,7 @@ declare_clippy_lint! {
3939
/// written as `a = a op a op b` as it's less confusing.
4040
///
4141
/// **Example:**
42-
/// ```rust
42+
/// ```ignore
4343
/// let mut a = 5;
4444
/// ...
4545
/// a += a + b;

clippy_lints/src/attrs.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ declare_clippy_lint! {
3434
/// done the measurement.
3535
///
3636
/// **Example:**
37-
/// ```rust
37+
/// ```ignore
3838
/// #[inline(always)]
3939
/// fn not_quite_hot_code(..) { ... }
4040
/// ```
@@ -57,7 +57,7 @@ declare_clippy_lint! {
5757
/// **Known problems:** None.
5858
///
5959
/// **Example:**
60-
/// ```rust
60+
/// ```ignore
6161
/// // Bad
6262
/// #[deny(dead_code)]
6363
/// extern crate foo;
@@ -88,7 +88,7 @@ declare_clippy_lint! {
8888
/// **Example:**
8989
/// ```rust
9090
/// #[deprecated(since = "forever")]
91-
/// fn something_else(..) { ... }
91+
/// fn something_else() { /* ... */ }
9292
/// ```
9393
pub DEPRECATED_SEMVER,
9494
correctness,

clippy_lints/src/bit_mask.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ declare_clippy_lint! {
3737
/// **Known problems:** None.
3838
///
3939
/// **Example:**
40-
/// ```rust
40+
/// ```ignore
4141
/// if (x & 1 == 2) { … }
4242
/// ```
4343
pub BAD_BIT_MASK,
@@ -65,7 +65,7 @@ declare_clippy_lint! {
6565
/// uncommon).
6666
///
6767
/// **Example:**
68-
/// ```rust
68+
/// ```ignore
6969
/// if (x | 1 > 3) { … }
7070
/// ```
7171
pub INEFFECTIVE_BIT_MASK,
@@ -83,7 +83,7 @@ declare_clippy_lint! {
8383
/// **Known problems:** llvm generates better code for `x & 15 == 0` on x86
8484
///
8585
/// **Example:**
86-
/// ```rust
86+
/// ```ignore
8787
/// x & 0x1111 == 0
8888
/// ```
8989
pub VERBOSE_BIT_MASK,

clippy_lints/src/block_in_if_condition.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ declare_clippy_lint! {
1616
///
1717
/// **Example:**
1818
/// ```rust
19-
/// if { true } ..
19+
/// if { true } { /* ... */ }
2020
/// ```
2121
pub BLOCK_IN_IF_CONDITION_EXPR,
2222
style,
@@ -32,10 +32,10 @@ declare_clippy_lint! {
3232
/// **Known problems:** None.
3333
///
3434
/// **Example:**
35-
/// ```rust
36-
/// if { let x = somefunc(); x } ..
35+
/// ```ignore
36+
/// if { let x = somefunc(); x } {}
3737
/// // or
38-
/// if somefunc(|x| { x == 47 }) ..
38+
/// if somefunc(|x| { x == 47 }) {}
3939
/// ```
4040
pub BLOCK_IN_IF_CONDITION_STMT,
4141
style,

clippy_lints/src/booleans.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ declare_clippy_lint! {
2121
/// `&&`. Ignores `|`, `&` and `^`.
2222
///
2323
/// **Example:**
24-
/// ```rust
24+
/// ```ignore
2525
/// if a && true // should be: if a
2626
/// if !(a == b) // should be: if a != b
2727
/// ```
@@ -39,7 +39,7 @@ declare_clippy_lint! {
3939
/// **Known problems:** Ignores short circuiting behavior.
4040
///
4141
/// **Example:**
42-
/// ```rust
42+
/// ```ignore
4343
/// if a && b || a { ... }
4444
/// ```
4545
/// The `b` is unnecessary, the expression is equivalent to `if a`.

clippy_lints/src/const_static_lifetime.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ declare_clippy_lint! {
1313
/// **Known problems:** None.
1414
///
1515
/// **Example:**
16-
/// ```rust
16+
/// ```ignore
1717
/// const FOO: &'static [(&'static str, &'static str, fn(&Bar) -> bool)] =
1818
/// &[...]
1919
/// ```
2020
/// This code can be rewritten as
21-
/// ```rust
21+
/// ```ignore
2222
/// const FOO: &[(&str, &str, fn(&Bar) -> bool)] = &[...]
2323
/// ```
2424
pub CONST_STATIC_LIFETIME,

clippy_lints/src/copies.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ declare_clippy_lint! {
1818
/// **Known problems:** Hopefully none.
1919
///
2020
/// **Example:**
21-
/// ```rust
21+
/// ```ignore
2222
/// if a == b {
2323
/// …
2424
/// } else if a == b {
@@ -29,7 +29,7 @@ declare_clippy_lint! {
2929
/// Note that this lint ignores all conditions with a function call as it could
3030
/// have side effects:
3131
///
32-
/// ```rust
32+
/// ```ignore
3333
/// if foo() {
3434
/// …
3535
/// } else if foo() { // not linted
@@ -50,7 +50,7 @@ declare_clippy_lint! {
5050
/// **Known problems:** Hopefully none.
5151
///
5252
/// **Example:**
53-
/// ```rust
53+
/// ```ignore
5454
/// let foo = if … {
5555
/// 42
5656
/// } else {

clippy_lints/src/derive.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ declare_clippy_lint! {
1616
/// default-generated `Hash` implementation with an explicitly defined
1717
/// `PartialEq`. In particular, the following must hold for any type:
1818
///
19-
/// ```rust
19+
/// ```text
2020
/// k1 == k2 ⇒ hash(k1) == hash(k2)
2121
/// ```
2222
///
2323
/// **Known problems:** None.
2424
///
2525
/// **Example:**
26-
/// ```rust
26+
/// ```ignore
2727
/// #[derive(Hash)]
2828
/// struct Foo;
2929
///

clippy_lints/src/drop_forget_ref.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ declare_clippy_lint! {
1717
/// **Known problems:** None.
1818
///
1919
/// **Example:**
20-
/// ```rust
20+
/// ```ignore
2121
/// let mut lock_guard = mutex.lock();
2222
/// std::mem::drop(&lock_guard) // Should have been drop(lock_guard), mutex
2323
/// // still locked

clippy_lints/src/enum_variants.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ declare_clippy_lint! {
8888
/// **Known problems:** None.
8989
///
9090
/// **Example:**
91-
/// ```rust
91+
/// ```ignore
9292
/// // lib.rs
9393
/// mod foo;
9494
/// // foo.rs

clippy_lints/src/eq_op.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ declare_clippy_lint! {
1919
/// calls. We may introduce a whitelist of known pure functions in the future.
2020
///
2121
/// **Example:**
22-
/// ```rust
22+
/// ```ignore
2323
/// x + 1 == x + 1
2424
/// ```
2525
pub EQ_OP,
@@ -37,7 +37,7 @@ declare_clippy_lint! {
3737
/// **Known problems:** None
3838
///
3939
/// **Example:**
40-
/// ```rust
40+
/// ```ignore
4141
/// &x == y
4242
/// ```
4343
pub OP_REF,

clippy_lints/src/erasing_op.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ declare_clippy_lint! {
1515
/// **Known problems:** None.
1616
///
1717
/// **Example:**
18-
/// ```rust
18+
/// ```ignore
1919
/// 0 / x;
2020
/// 0 * x;
2121
/// x & 0

clippy_lints/src/eta_reduction.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ declare_clippy_lint! {
2323
/// details.
2424
///
2525
/// **Example:**
26-
/// ```rust
26+
/// ```ignore
2727
/// xs.map(|x| foo(x))
2828
/// ```
2929
/// where `foo(_)` is a plain function that takes the exact argument type of

clippy_lints/src/indexing_slicing.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ declare_clippy_lint! {
1919
/// **Known problems:** Hopefully none.
2020
///
2121
/// **Example:**
22-
/// ```rust
22+
/// ```no_run
23+
/// # #![allow(const_err)]
2324
/// let x = [1, 2, 3, 4];
2425
///
2526
/// // Bad

clippy_lints/src/infinite_iter.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@ declare_clippy_lint! {
1212
/// **Known problems:** None.
1313
///
1414
/// **Example:**
15-
/// ```rust
16-
/// repeat(1_u8).iter().collect::<Vec<_>>()
15+
/// ```no_run
16+
/// use std::iter;
17+
///
18+
/// iter::repeat(1_u8).collect::<Vec<_>>();
1719
/// ```
1820
pub INFINITE_ITER,
1921
correctness,

clippy_lints/src/invalid_ref.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ declare_clippy_lint! {
1313
/// **Known problems:** None.
1414
///
1515
/// **Example:**
16-
/// ```rust
17-
/// let bad_ref: &usize = std::mem::zeroed();
16+
/// ```no_run
17+
/// let bad_ref: &usize = unsafe { std::mem::zeroed() };
1818
/// ```
1919
pub INVALID_REF,
2020
correctness,

clippy_lints/src/len_zero.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ declare_clippy_lint! {
2222
/// **Known problems:** None.
2323
///
2424
/// **Example:**
25-
/// ```rust
25+
/// ```ignore
2626
/// if x.len() == 0 {
2727
/// ..
2828
/// }
@@ -31,7 +31,7 @@ declare_clippy_lint! {
3131
/// }
3232
/// ```
3333
/// instead use
34-
/// ```rust
34+
/// ```ignore
3535
/// if x.is_empty() {
3636
/// ..
3737
/// }
@@ -57,7 +57,7 @@ declare_clippy_lint! {
5757
/// **Known problems:** None.
5858
///
5959
/// **Example:**
60-
/// ```rust
60+
/// ```ignore
6161
/// impl X {
6262
/// pub fn len(&self) -> usize {
6363
/// ..

clippy_lints/src/literal_representation.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ declare_clippy_lint! {
2020
/// **Example:**
2121
///
2222
/// ```rust
23-
/// 61864918973511
23+
/// let x: u64 = 61864918973511;
2424
/// ```
2525
pub UNREADABLE_LITERAL,
2626
style,
@@ -40,7 +40,7 @@ declare_clippy_lint! {
4040
/// **Example:**
4141
///
4242
/// ```rust
43-
/// 2_32
43+
/// 2_32;
4444
/// ```
4545
pub MISTYPED_LITERAL_SUFFIXES,
4646
correctness,
@@ -59,7 +59,7 @@ declare_clippy_lint! {
5959
/// **Example:**
6060
///
6161
/// ```rust
62-
/// 618_64_9189_73_511
62+
/// let x: u64 = 618_64_9189_73_511;
6363
/// ```
6464
pub INCONSISTENT_DIGIT_GROUPING,
6565
style,
@@ -78,7 +78,7 @@ declare_clippy_lint! {
7878
/// **Example:**
7979
///
8080
/// ```rust
81-
/// 6186491_8973511
81+
/// let x: u64 = 6186491_8973511;
8282
/// ```
8383
pub LARGE_DIGIT_GROUPS,
8484
pedantic,

0 commit comments

Comments
 (0)