Skip to content

Commit 3dc9183

Browse files
committed
Auto merge of #4325 - phansch:doctests_complexity, r=flip1995
Doctests: Enable running doc tests for complexity lints changelog: none master: `113 passed; 0 failed; 91 ignored; 0 measured; 0 filtered out` this PR: `181 passed; 0 failed; 110 ignored; 0 measured; 0 filtered out` cc #4319
2 parents a24c704 + eb68dc9 commit 3dc9183

33 files changed

+157
-85
lines changed

clippy_lints/src/assign_ops.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ declare_clippy_lint! {
4545
/// **Example:**
4646
/// ```rust
4747
/// let mut a = 5;
48-
/// ...
48+
/// let b = 2;
49+
/// // ...
4950
/// a += a + b;
5051
/// ```
5152
pub MISREFACTORED_ASSIGN_OP,

clippy_lints/src/double_comparison.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,17 @@ declare_clippy_lint! {
1818
///
1919
/// **Example:**
2020
/// ```rust
21-
/// x == y || x < y
21+
/// # let x = 1;
22+
/// # let y = 2;
23+
/// if x == y || x < y {}
2224
/// ```
2325
///
2426
/// Could be written as:
2527
///
2628
/// ```rust
27-
/// x <= y
29+
/// # let x = 1;
30+
/// # let y = 2;
31+
/// if x <= y {}
2832
/// ```
2933
pub DOUBLE_COMPARISONS,
3034
complexity,

clippy_lints/src/double_parens.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ declare_clippy_lint! {
1313
///
1414
/// **Example:**
1515
/// ```rust
16-
/// ((0))
17-
/// foo((0))
18-
/// ((1, 2))
16+
/// # fn foo(bar: usize) {}
17+
/// ((0));
18+
/// foo((0));
19+
/// ((1, 2));
1920
/// ```
2021
pub DOUBLE_PARENS,
2122
complexity,

clippy_lints/src/duration_subsec.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ declare_clippy_lint! {
2020
///
2121
/// **Example:**
2222
/// ```rust
23+
/// # use std::time::Duration;
2324
/// let dur = Duration::new(5, 0);
2425
/// let _micros = dur.subsec_nanos() / 1_000;
2526
/// let _millis = dur.subsec_nanos() / 1_000_000;

clippy_lints/src/eval_order_dependence.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ declare_clippy_lint! {
4242
/// shorthand.
4343
///
4444
/// **Example:**
45-
/// ```rust
45+
/// ```rust,no_run
46+
/// # fn b() -> bool { true }
47+
/// # fn c() -> bool { true }
4648
/// let a = b() || panic!() || c();
4749
/// // `c()` is dead, `panic!()` is only called if `b()` returns `false`
4850
/// let x = (a, b, c, panic!());

clippy_lints/src/explicit_write.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@ declare_clippy_lint! {
1616
///
1717
/// **Example:**
1818
/// ```rust
19+
/// # use std::io::Write;
20+
/// # let bar = "furchtbar";
1921
/// // this would be clearer as `eprintln!("foo: {:?}", bar);`
20-
/// writeln!(&mut io::stderr(), "foo: {:?}", bar).unwrap();
22+
/// writeln!(&mut std::io::stderr(), "foo: {:?}", bar).unwrap();
2123
/// ```
2224
pub EXPLICIT_WRITE,
2325
complexity,

clippy_lints/src/format.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ declare_clippy_lint! {
2626
///
2727
/// **Examples:**
2828
/// ```rust
29-
/// format!("foo")
30-
/// format!("{}", foo)
29+
/// # let foo = "foo";
30+
/// format!("foo");
31+
/// format!("{}", foo);
3132
/// ```
3233
pub USELESS_FORMAT,
3334
complexity,

clippy_lints/src/functions.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ declare_clippy_lint! {
2323
///
2424
/// **Example:**
2525
/// ```rust
26+
/// # struct Color;
2627
/// fn foo(x: u32, y: u32, name: &str, c: Color, w: f32, h: f32, a: f32, b: f32) {
27-
/// ..
28+
/// // ..
2829
/// }
2930
/// ```
3031
pub TOO_MANY_ARGUMENTS,

clippy_lints/src/identity_op.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ declare_clippy_lint! {
1717
///
1818
/// **Example:**
1919
/// ```rust
20-
/// x / 1 + 0 * 1 - 0 | 0
20+
/// # let x = 1;
21+
/// x / 1 + 0 * 1 - 0 | 0;
2122
/// ```
2223
pub IDENTITY_OP,
2324
complexity,

clippy_lints/src/int_plus_one.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,17 @@ declare_clippy_lint! {
1717
///
1818
/// **Example:**
1919
/// ```rust
20-
/// x >= y + 1
20+
/// # let x = 1;
21+
/// # let y = 1;
22+
/// if x >= y + 1 {}
2123
/// ```
2224
///
23-
/// Could be written:
25+
/// Could be written as:
2426
///
2527
/// ```rust
26-
/// x > y
28+
/// # let x = 1;
29+
/// # let y = 1;
30+
/// if x > y {}
2731
/// ```
2832
pub INT_PLUS_ONE,
2933
complexity,

0 commit comments

Comments
 (0)