Skip to content

Commit ca6a9be

Browse files
committed
Auto merge of #4338 - flip1995:rollup-9cm4jbr, r=flip1995
Rollup of 4 pull requests Successful merges: - #4329 (Doctests: Enable running doc tests for pedantic lints) - #4330 (Doctests: Enable running doc tests for nursery lints) - #4331 (Doctests: Enable running doc tests for restriction lints) - #4332 (Split up cast.rs tests, run-rustfix for unnecessary_cast) Failed merges: r? @ghost changelog: none
2 parents a90b3ba + 9259eeb commit ca6a9be

35 files changed

+261
-120
lines changed

clippy_lints/src/arithmetic.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ declare_clippy_lint! {
1616
///
1717
/// **Example:**
1818
/// ```rust
19-
/// a + 1
19+
/// # let a = 0;
20+
/// a + 1;
2021
/// ```
2122
pub INTEGER_ARITHMETIC,
2223
restriction,
@@ -33,7 +34,8 @@ declare_clippy_lint! {
3334
///
3435
/// **Example:**
3536
/// ```rust
36-
/// a + 1.0
37+
/// # let a = 0.0;
38+
/// a + 1.0;
3739
/// ```
3840
pub FLOAT_ARITHMETIC,
3941
restriction,

clippy_lints/src/attrs.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -113,19 +113,19 @@ declare_clippy_lint! {
113113
///
114114
/// **Example:**
115115
/// ```rust
116-
/// // Bad
117-
/// #[inline(always)]
118-
///
119-
/// fn not_quite_good_code(..) { ... }
120-
///
121116
/// // Good (as inner attribute)
122117
/// #![inline(always)]
123118
///
124-
/// fn this_is_fine(..) { ... }
119+
/// fn this_is_fine() { }
120+
///
121+
/// // Bad
122+
/// #[inline(always)]
123+
///
124+
/// fn not_quite_good_code() { }
125125
///
126126
/// // Good (as outer attribute)
127127
/// #[inline(always)]
128-
/// fn this_is_fine_too(..) { ... }
128+
/// fn this_is_fine_too() { }
129129
/// ```
130130
pub EMPTY_LINE_AFTER_OUTER_ATTR,
131131
nursery,

clippy_lints/src/checked_conversions.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ declare_clippy_lint! {
2727
/// Could be written:
2828
///
2929
/// ```rust
30+
/// # use std::convert::TryFrom;
31+
/// # let foo = 1;
3032
/// # let _ =
3133
/// i32::try_from(foo).is_ok()
3234
/// # ;

clippy_lints/src/copy_iterator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ declare_clippy_lint! {
1313
/// **Known problems:** None.
1414
///
1515
/// **Example:**
16-
/// ```rust
16+
/// ```rust,ignore
1717
/// #[derive(Copy, Clone)]
1818
/// struct Countdown(u8);
1919
///

clippy_lints/src/derive.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@ declare_clippy_lint! {
4949
/// **Known problems:** Bounds of generic types are sometimes wrong: https://github.com/rust-lang/rust/issues/26925
5050
///
5151
/// **Example:**
52-
/// ```rust
52+
/// ```rust,ignore
5353
/// #[derive(Copy)]
5454
/// struct Foo;
5555
///
5656
/// impl Clone for Foo {
57-
/// ..
57+
/// // ..
5858
/// }
5959
/// ```
6060
pub EXPL_IMPL_CLONE_ON_COPY,

clippy_lints/src/doc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ declare_clippy_lint! {
2727
/// /// Do something with the foo_bar parameter. See also
2828
/// /// that::other::module::foo.
2929
/// // ^ `foo_bar` and `that::other::module::foo` should be ticked.
30-
/// fn doit(foo_bar) { .. }
30+
/// fn doit(foo_bar: usize) {}
3131
/// ```
3232
pub DOC_MARKDOWN,
3333
pedantic,

clippy_lints/src/else_if_without_else.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ declare_clippy_lint! {
1616
///
1717
/// **Example:**
1818
/// ```rust
19+
/// # fn a() {}
20+
/// # fn b() {}
21+
/// # let x: i32 = 1;
1922
/// if x.is_positive() {
2023
/// a();
2124
/// } else if x.is_negative() {
@@ -26,6 +29,9 @@ declare_clippy_lint! {
2629
/// Could be written:
2730
///
2831
/// ```rust
32+
/// # fn a() {}
33+
/// # fn b() {}
34+
/// # let x: i32 = 1;
2935
/// if x.is_positive() {
3036
/// a();
3137
/// } else if x.is_negative() {

clippy_lints/src/if_not_else.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ declare_clippy_lint! {
1717
///
1818
/// **Example:**
1919
/// ```rust
20+
/// # let v: Vec<usize> = vec![];
21+
/// # fn a() {}
22+
/// # fn b() {}
2023
/// if !v.is_empty() {
2124
/// a()
2225
/// } else {
@@ -27,6 +30,9 @@ declare_clippy_lint! {
2730
/// Could be written:
2831
///
2932
/// ```rust
33+
/// # let v: Vec<usize> = vec![];
34+
/// # fn a() {}
35+
/// # fn b() {}
3036
/// if v.is_empty() {
3137
/// b()
3238
/// } else {

clippy_lints/src/indexing_slicing.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ declare_clippy_lint! {
4747
/// **Known problems:** Hopefully none.
4848
///
4949
/// **Example:**
50-
/// ```rust
50+
/// ```rust,no_run
5151
/// // Vector
5252
/// let x = vec![0; 5];
5353
///

clippy_lints/src/infinite_iter.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ declare_clippy_lint! {
3434
///
3535
/// **Example:**
3636
/// ```rust
37-
/// [0..].iter().zip(infinite_iter.take_while(|x| x > 5))
37+
/// let infinite_iter = 0..;
38+
/// [0..].iter().zip(infinite_iter.take_while(|x| *x > 5));
3839
/// ```
3940
pub MAYBE_INFINITE_ITER,
4041
pedantic,

0 commit comments

Comments
 (0)