diff --git a/clippy_lints/src/assertions_on_constants.rs b/clippy_lints/src/assertions_on_constants.rs index 54ef63160db..8d366034ba5 100644 --- a/clippy_lints/src/assertions_on_constants.rs +++ b/clippy_lints/src/assertions_on_constants.rs @@ -15,13 +15,13 @@ declare_clippy_lint! { /// **Known problems:** None /// /// **Example:** - /// ```rust - /// assert!(false) + /// ```no_run + /// assert!(false); /// // or - /// assert!(true) + /// assert!(true); /// // or /// const B: bool = false; - /// assert!(B) + /// assert!(B); /// ``` pub ASSERTIONS_ON_CONSTANTS, style, diff --git a/clippy_lints/src/assign_ops.rs b/clippy_lints/src/assign_ops.rs index bfa35d4381a..d0c72ba92c0 100644 --- a/clippy_lints/src/assign_ops.rs +++ b/clippy_lints/src/assign_ops.rs @@ -17,7 +17,7 @@ declare_clippy_lint! { /// implementations that differ from the regular `Op` impl. /// /// **Example:** - /// ```rust + /// ```ignore /// let mut a = 5; /// ... /// a = a + b; @@ -39,7 +39,7 @@ declare_clippy_lint! { /// written as `a = a op a op b` as it's less confusing. /// /// **Example:** - /// ```rust + /// ```ignore /// let mut a = 5; /// ... /// a += a + b; diff --git a/clippy_lints/src/attrs.rs b/clippy_lints/src/attrs.rs index 205b11b3b91..f33febfa3b3 100644 --- a/clippy_lints/src/attrs.rs +++ b/clippy_lints/src/attrs.rs @@ -34,7 +34,7 @@ declare_clippy_lint! { /// done the measurement. /// /// **Example:** - /// ```rust + /// ```ignore /// #[inline(always)] /// fn not_quite_hot_code(..) { ... } /// ``` @@ -57,7 +57,7 @@ declare_clippy_lint! { /// **Known problems:** None. /// /// **Example:** - /// ```rust + /// ```ignore /// // Bad /// #[deny(dead_code)] /// extern crate foo; @@ -88,7 +88,7 @@ declare_clippy_lint! { /// **Example:** /// ```rust /// #[deprecated(since = "forever")] - /// fn something_else(..) { ... } + /// fn something_else() { /* ... */ } /// ``` pub DEPRECATED_SEMVER, correctness, diff --git a/clippy_lints/src/bit_mask.rs b/clippy_lints/src/bit_mask.rs index 7c5d2495952..52af7e2d93b 100644 --- a/clippy_lints/src/bit_mask.rs +++ b/clippy_lints/src/bit_mask.rs @@ -37,7 +37,7 @@ declare_clippy_lint! { /// **Known problems:** None. /// /// **Example:** - /// ```rust + /// ```ignore /// if (x & 1 == 2) { … } /// ``` pub BAD_BIT_MASK, @@ -65,7 +65,7 @@ declare_clippy_lint! { /// uncommon). /// /// **Example:** - /// ```rust + /// ```ignore /// if (x | 1 > 3) { … } /// ``` pub INEFFECTIVE_BIT_MASK, @@ -83,7 +83,7 @@ declare_clippy_lint! { /// **Known problems:** llvm generates better code for `x & 15 == 0` on x86 /// /// **Example:** - /// ```rust + /// ```ignore /// x & 0x1111 == 0 /// ``` pub VERBOSE_BIT_MASK, diff --git a/clippy_lints/src/block_in_if_condition.rs b/clippy_lints/src/block_in_if_condition.rs index 7c664866f59..400a6a61a6e 100644 --- a/clippy_lints/src/block_in_if_condition.rs +++ b/clippy_lints/src/block_in_if_condition.rs @@ -16,7 +16,7 @@ declare_clippy_lint! { /// /// **Example:** /// ```rust - /// if { true } .. + /// if { true } { /* ... */ } /// ``` pub BLOCK_IN_IF_CONDITION_EXPR, style, @@ -32,10 +32,10 @@ declare_clippy_lint! { /// **Known problems:** None. /// /// **Example:** - /// ```rust - /// if { let x = somefunc(); x } .. + /// ```ignore + /// if { let x = somefunc(); x } {} /// // or - /// if somefunc(|x| { x == 47 }) .. + /// if somefunc(|x| { x == 47 }) {} /// ``` pub BLOCK_IN_IF_CONDITION_STMT, style, diff --git a/clippy_lints/src/booleans.rs b/clippy_lints/src/booleans.rs index 5d05caf3aa8..f7e0157746f 100644 --- a/clippy_lints/src/booleans.rs +++ b/clippy_lints/src/booleans.rs @@ -21,7 +21,7 @@ declare_clippy_lint! { /// `&&`. Ignores `|`, `&` and `^`. /// /// **Example:** - /// ```rust + /// ```ignore /// if a && true // should be: if a /// if !(a == b) // should be: if a != b /// ``` @@ -39,7 +39,7 @@ declare_clippy_lint! { /// **Known problems:** Ignores short circuiting behavior. /// /// **Example:** - /// ```rust + /// ```ignore /// if a && b || a { ... } /// ``` /// The `b` is unnecessary, the expression is equivalent to `if a`. diff --git a/clippy_lints/src/const_static_lifetime.rs b/clippy_lints/src/const_static_lifetime.rs index e160008fa55..1e369044d24 100644 --- a/clippy_lints/src/const_static_lifetime.rs +++ b/clippy_lints/src/const_static_lifetime.rs @@ -13,12 +13,12 @@ declare_clippy_lint! { /// **Known problems:** None. /// /// **Example:** - /// ```rust + /// ```ignore /// const FOO: &'static [(&'static str, &'static str, fn(&Bar) -> bool)] = /// &[...] /// ``` /// This code can be rewritten as - /// ```rust + /// ```ignore /// const FOO: &[(&str, &str, fn(&Bar) -> bool)] = &[...] /// ``` pub CONST_STATIC_LIFETIME, diff --git a/clippy_lints/src/copies.rs b/clippy_lints/src/copies.rs index 60319045830..c6fbb38250c 100644 --- a/clippy_lints/src/copies.rs +++ b/clippy_lints/src/copies.rs @@ -18,7 +18,7 @@ declare_clippy_lint! { /// **Known problems:** Hopefully none. /// /// **Example:** - /// ```rust + /// ```ignore /// if a == b { /// … /// } else if a == b { @@ -29,7 +29,7 @@ declare_clippy_lint! { /// Note that this lint ignores all conditions with a function call as it could /// have side effects: /// - /// ```rust + /// ```ignore /// if foo() { /// … /// } else if foo() { // not linted @@ -50,7 +50,7 @@ declare_clippy_lint! { /// **Known problems:** Hopefully none. /// /// **Example:** - /// ```rust + /// ```ignore /// let foo = if … { /// 42 /// } else { diff --git a/clippy_lints/src/derive.rs b/clippy_lints/src/derive.rs index a00f7cfe263..2c77f8d37fa 100644 --- a/clippy_lints/src/derive.rs +++ b/clippy_lints/src/derive.rs @@ -16,14 +16,14 @@ declare_clippy_lint! { /// default-generated `Hash` implementation with an explicitly defined /// `PartialEq`. In particular, the following must hold for any type: /// - /// ```rust + /// ```text /// k1 == k2 ⇒ hash(k1) == hash(k2) /// ``` /// /// **Known problems:** None. /// /// **Example:** - /// ```rust + /// ```ignore /// #[derive(Hash)] /// struct Foo; /// diff --git a/clippy_lints/src/drop_forget_ref.rs b/clippy_lints/src/drop_forget_ref.rs index 08c523b038c..67649b93a25 100644 --- a/clippy_lints/src/drop_forget_ref.rs +++ b/clippy_lints/src/drop_forget_ref.rs @@ -17,7 +17,7 @@ declare_clippy_lint! { /// **Known problems:** None. /// /// **Example:** - /// ```rust + /// ```ignore /// let mut lock_guard = mutex.lock(); /// std::mem::drop(&lock_guard) // Should have been drop(lock_guard), mutex /// // still locked diff --git a/clippy_lints/src/enum_variants.rs b/clippy_lints/src/enum_variants.rs index 192668028f1..707fe93bd0c 100644 --- a/clippy_lints/src/enum_variants.rs +++ b/clippy_lints/src/enum_variants.rs @@ -88,7 +88,7 @@ declare_clippy_lint! { /// **Known problems:** None. /// /// **Example:** - /// ```rust + /// ```ignore /// // lib.rs /// mod foo; /// // foo.rs diff --git a/clippy_lints/src/eq_op.rs b/clippy_lints/src/eq_op.rs index 24b6371142f..44eba7a9fcb 100644 --- a/clippy_lints/src/eq_op.rs +++ b/clippy_lints/src/eq_op.rs @@ -19,7 +19,7 @@ declare_clippy_lint! { /// calls. We may introduce a whitelist of known pure functions in the future. /// /// **Example:** - /// ```rust + /// ```ignore /// x + 1 == x + 1 /// ``` pub EQ_OP, @@ -37,7 +37,7 @@ declare_clippy_lint! { /// **Known problems:** None /// /// **Example:** - /// ```rust + /// ```ignore /// &x == y /// ``` pub OP_REF, diff --git a/clippy_lints/src/erasing_op.rs b/clippy_lints/src/erasing_op.rs index 748673c96b1..247b3f678d8 100644 --- a/clippy_lints/src/erasing_op.rs +++ b/clippy_lints/src/erasing_op.rs @@ -15,7 +15,7 @@ declare_clippy_lint! { /// **Known problems:** None. /// /// **Example:** - /// ```rust + /// ```ignore /// 0 / x; /// 0 * x; /// x & 0 diff --git a/clippy_lints/src/eta_reduction.rs b/clippy_lints/src/eta_reduction.rs index cd3146cf1be..3571540c6c9 100644 --- a/clippy_lints/src/eta_reduction.rs +++ b/clippy_lints/src/eta_reduction.rs @@ -23,7 +23,7 @@ declare_clippy_lint! { /// details. /// /// **Example:** - /// ```rust + /// ```ignore /// xs.map(|x| foo(x)) /// ``` /// where `foo(_)` is a plain function that takes the exact argument type of diff --git a/clippy_lints/src/indexing_slicing.rs b/clippy_lints/src/indexing_slicing.rs index 90129d794ac..696ce74b022 100644 --- a/clippy_lints/src/indexing_slicing.rs +++ b/clippy_lints/src/indexing_slicing.rs @@ -19,7 +19,8 @@ declare_clippy_lint! { /// **Known problems:** Hopefully none. /// /// **Example:** - /// ```rust + /// ```no_run + /// # #![allow(const_err)] /// let x = [1, 2, 3, 4]; /// /// // Bad diff --git a/clippy_lints/src/infinite_iter.rs b/clippy_lints/src/infinite_iter.rs index bee28a4b741..1cee5348f44 100644 --- a/clippy_lints/src/infinite_iter.rs +++ b/clippy_lints/src/infinite_iter.rs @@ -12,8 +12,10 @@ declare_clippy_lint! { /// **Known problems:** None. /// /// **Example:** - /// ```rust - /// repeat(1_u8).iter().collect::>() + /// ```no_run + /// use std::iter; + /// + /// iter::repeat(1_u8).collect::>(); /// ``` pub INFINITE_ITER, correctness, diff --git a/clippy_lints/src/invalid_ref.rs b/clippy_lints/src/invalid_ref.rs index 63011726b4f..9d269b911fd 100644 --- a/clippy_lints/src/invalid_ref.rs +++ b/clippy_lints/src/invalid_ref.rs @@ -13,8 +13,8 @@ declare_clippy_lint! { /// **Known problems:** None. /// /// **Example:** - /// ```rust - /// let bad_ref: &usize = std::mem::zeroed(); + /// ```no_run + /// let bad_ref: &usize = unsafe { std::mem::zeroed() }; /// ``` pub INVALID_REF, correctness, diff --git a/clippy_lints/src/len_zero.rs b/clippy_lints/src/len_zero.rs index c802b267df2..cd7ae45c62a 100644 --- a/clippy_lints/src/len_zero.rs +++ b/clippy_lints/src/len_zero.rs @@ -22,7 +22,7 @@ declare_clippy_lint! { /// **Known problems:** None. /// /// **Example:** - /// ```rust + /// ```ignore /// if x.len() == 0 { /// .. /// } @@ -31,7 +31,7 @@ declare_clippy_lint! { /// } /// ``` /// instead use - /// ```rust + /// ```ignore /// if x.is_empty() { /// .. /// } @@ -57,7 +57,7 @@ declare_clippy_lint! { /// **Known problems:** None. /// /// **Example:** - /// ```rust + /// ```ignore /// impl X { /// pub fn len(&self) -> usize { /// .. diff --git a/clippy_lints/src/literal_representation.rs b/clippy_lints/src/literal_representation.rs index 92cc288abb6..7df8cbe95e9 100644 --- a/clippy_lints/src/literal_representation.rs +++ b/clippy_lints/src/literal_representation.rs @@ -20,7 +20,7 @@ declare_clippy_lint! { /// **Example:** /// /// ```rust - /// 61864918973511 + /// let x: u64 = 61864918973511; /// ``` pub UNREADABLE_LITERAL, style, @@ -40,7 +40,7 @@ declare_clippy_lint! { /// **Example:** /// /// ```rust - /// 2_32 + /// 2_32; /// ``` pub MISTYPED_LITERAL_SUFFIXES, correctness, @@ -59,7 +59,7 @@ declare_clippy_lint! { /// **Example:** /// /// ```rust - /// 618_64_9189_73_511 + /// let x: u64 = 618_64_9189_73_511; /// ``` pub INCONSISTENT_DIGIT_GROUPING, style, @@ -78,7 +78,7 @@ declare_clippy_lint! { /// **Example:** /// /// ```rust - /// 6186491_8973511 + /// let x: u64 = 6186491_8973511; /// ``` pub LARGE_DIGIT_GROUPS, pedantic, diff --git a/clippy_lints/src/loops.rs b/clippy_lints/src/loops.rs index 35d9bf38797..2cde33372a7 100644 --- a/clippy_lints/src/loops.rs +++ b/clippy_lints/src/loops.rs @@ -41,7 +41,7 @@ declare_clippy_lint! { /// **Known problems:** None. /// /// **Example:** - /// ```rust + /// ```ignore /// for i in 0..src.len() { /// dst[i + 64] = src[i]; /// } @@ -61,7 +61,7 @@ declare_clippy_lint! { /// **Known problems:** None. /// /// **Example:** - /// ```rust + /// ```ignore /// for i in 0..vec.len() { /// println!("{}", vec[i]); /// } @@ -81,7 +81,7 @@ declare_clippy_lint! { /// types. /// /// **Example:** - /// ```rust + /// ```ignore /// // with `y` a `Vec` or slice: /// for x in y.iter() { /// .. @@ -107,14 +107,14 @@ declare_clippy_lint! { /// **Known problems:** None /// /// **Example:** - /// ```rust + /// ```ignore /// // with `y` a `Vec` or slice: /// for x in y.into_iter() { /// .. /// } /// ``` /// can be rewritten to - /// ```rust + /// ```ignore /// for x in y { /// .. /// } @@ -137,7 +137,7 @@ declare_clippy_lint! { /// **Known problems:** None. /// /// **Example:** - /// ```rust + /// ```ignore /// for x in y.next() { /// .. /// } @@ -156,14 +156,14 @@ declare_clippy_lint! { /// **Known problems:** None. /// /// **Example:** - /// ```rust + /// ```ignore /// for x in option { /// .. /// } /// ``` /// /// This should be - /// ```rust + /// ```ignore /// if let Some(x) = option { /// .. /// } @@ -182,14 +182,14 @@ declare_clippy_lint! { /// **Known problems:** None. /// /// **Example:** - /// ```rust + /// ```ignore /// for x in result { /// .. /// } /// ``` /// /// This should be - /// ```rust + /// ```ignore /// if let Ok(x) = result { /// .. /// } @@ -237,7 +237,7 @@ declare_clippy_lint! { /// **Known problems:** None. /// /// **Example:** - /// ```rust + /// ```ignore /// vec.iter().map(|x| /* some operation returning () */).collect::>(); /// ``` pub UNUSED_COLLECT, @@ -256,7 +256,7 @@ declare_clippy_lint! { /// None /// /// **Example:** - /// ```rust + /// ```ignore /// let len = iterator.collect::>().len(); /// // should be /// let len = iterator.count(); @@ -280,7 +280,7 @@ declare_clippy_lint! { /// paths through the program, which would be complex and error-prone. /// /// **Example:** - /// ```rust + /// ```ignore /// for x in 5..10 - 5 { /// .. /// } // oops, stray `-` @@ -301,7 +301,7 @@ declare_clippy_lint! { /// **Known problems:** None. /// /// **Example:** - /// ```rust + /// ```ignore /// for i in 0..v.len() { foo(v[i]); /// for i in 0..v.len() { bar(i, v[i]); } /// ``` @@ -320,7 +320,7 @@ declare_clippy_lint! { /// **Known problems:** None. /// /// **Example:** - /// ```rust + /// ```no_run /// loop {} /// ``` pub EMPTY_LOOP, @@ -337,7 +337,7 @@ declare_clippy_lint! { /// **Known problems:** None. /// /// **Example:** - /// ```rust + /// ```ignore /// while let Some(val) = iter() { /// .. /// } @@ -357,7 +357,7 @@ declare_clippy_lint! { /// **Known problems:** None. /// /// **Example:** - /// ```rust + /// ```ignore /// for (k, _) in &map { /// .. /// } @@ -365,7 +365,7 @@ declare_clippy_lint! { /// /// could be replaced by /// - /// ```rust + /// ```ignore /// for k in map.keys() { /// .. /// } diff --git a/clippy_lints/src/matches.rs b/clippy_lints/src/matches.rs index 101a31e3086..2fc3a4fd5c1 100644 --- a/clippy_lints/src/matches.rs +++ b/clippy_lints/src/matches.rs @@ -27,7 +27,7 @@ declare_clippy_lint! { /// **Known problems:** None. /// /// **Example:** - /// ```rust + /// ```ignore /// match x { /// Some(ref foo) => bar(foo), /// _ => (), @@ -59,7 +59,7 @@ declare_clippy_lint! { /// /// Using `if let` with `else`: /// - /// ```rust + /// ```ignore /// if let Some(ref foo) = x { /// bar(foo); /// } else { @@ -82,7 +82,7 @@ declare_clippy_lint! { /// **Known problems:** None. /// /// **Example:** - /// ```rust + /// ```ignore /// match x { /// &A(ref y) => foo(y), /// &B => bar(), @@ -103,7 +103,7 @@ declare_clippy_lint! { /// **Known problems:** None. /// /// **Example:** - /// ```rust + /// ```ignore /// let condition: bool = true; /// match condition { /// true => foo(), @@ -111,7 +111,7 @@ declare_clippy_lint! { /// } /// ``` /// Use if/else instead: - /// ```rust + /// ```ignore /// let condition: bool = true; /// if condition { /// foo(); @@ -157,7 +157,7 @@ declare_clippy_lint! { /// /// **Example:** /// ```rust - /// let x: Result(i32, &str) = Ok(3); + /// let x: Result = Ok(3); /// match x { /// Ok(_) => println!("ok"), /// Err(_) => panic!("err"), diff --git a/clippy_lints/src/mem_discriminant.rs b/clippy_lints/src/mem_discriminant.rs index 17a9131640b..d263d808a8b 100644 --- a/clippy_lints/src/mem_discriminant.rs +++ b/clippy_lints/src/mem_discriminant.rs @@ -17,6 +17,8 @@ declare_clippy_lint! { /// /// **Example:** /// ```rust + /// use std::mem; + /// /// mem::discriminant(&"hello"); /// mem::discriminant(&&Some(2)); /// ``` diff --git a/clippy_lints/src/mem_replace.rs b/clippy_lints/src/mem_replace.rs index 4d0fae2ac1c..60193618aac 100644 --- a/clippy_lints/src/mem_replace.rs +++ b/clippy_lints/src/mem_replace.rs @@ -17,6 +17,8 @@ declare_clippy_lint! { /// /// **Example:** /// ```rust + /// use std::mem; + /// /// let mut an_option = Some(0); /// let replaced = mem::replace(&mut an_option, None); /// ``` diff --git a/clippy_lints/src/methods/mod.rs b/clippy_lints/src/methods/mod.rs index 75865f9123b..5ffdced712b 100644 --- a/clippy_lints/src/methods/mod.rs +++ b/clippy_lints/src/methods/mod.rs @@ -84,7 +84,7 @@ declare_clippy_lint! { /// **Known problems:** None. /// /// **Example:** - /// ```rust + /// ```ignore /// struct X; /// impl X { /// fn add(&self, other: &X) -> X { @@ -116,7 +116,7 @@ declare_clippy_lint! { /// **Known problems:** None. /// /// **Example:** - /// ```rust + /// ```ignore /// impl X { /// fn as_str(self) -> &str { /// .. @@ -160,7 +160,7 @@ declare_clippy_lint! { /// **Known problems:** The error type needs to implement `Debug` /// /// **Example:** - /// ```rust + /// ```ignore /// x.ok().expect("why did I do this again?") /// ``` pub OK_EXPECT, @@ -228,7 +228,7 @@ declare_clippy_lint! { /// **Known problems:** The order of the arguments is not in execution order. /// /// **Example:** - /// ```rust + /// ```ignore /// opt.map_or(None, |a| a + 1) /// ``` pub OPTION_MAP_OR_NONE, @@ -445,7 +445,7 @@ declare_clippy_lint! { /// **Known problems:** None. /// /// **Example:** - /// ```rust + /// ```ignore /// impl Foo { /// fn new(..) -> NotAFoo { /// } @@ -568,13 +568,13 @@ declare_clippy_lint! { /// /// **Example:** /// ```rust - /// let some_vec = vec![0, 1, 2, 3]; + /// let mut some_vec = vec![0, 1, 2, 3]; /// let last = some_vec.get(3).unwrap(); /// *some_vec.get_mut(0).unwrap() = 1; /// ``` /// The correct use would be: /// ```rust - /// let some_vec = vec![0, 1, 2, 3]; + /// let mut some_vec = vec![0, 1, 2, 3]; /// let last = some_vec[3]; /// some_vec[0] = 1; /// ``` @@ -605,7 +605,7 @@ declare_clippy_lint! { /// let def = String::from("def"); /// let mut s = String::new(); /// s.push_str(abc); - /// s.push_str(&def)); + /// s.push_str(&def); /// ``` pub STRING_EXTEND_CHARS, style, @@ -645,7 +645,7 @@ declare_clippy_lint! { /// **Known problems:** None. /// /// **Example:** - /// ```rust + /// ```ignore /// name.chars().last() == Some('_') || name.chars().next_back() == Some('-') /// ``` pub CHARS_LAST_CMP, diff --git a/clippy_lints/src/minmax.rs b/clippy_lints/src/minmax.rs index 22bc25094be..47f4f5fcf2d 100644 --- a/clippy_lints/src/minmax.rs +++ b/clippy_lints/src/minmax.rs @@ -15,7 +15,7 @@ declare_clippy_lint! { /// **Known problems:** None /// /// **Example:** - /// ```rust + /// ```ignore /// min(0, max(100, x)) /// ``` /// It will always be equal to `0`. Probably the author meant to clamp the value diff --git a/clippy_lints/src/misc.rs b/clippy_lints/src/misc.rs index 34e276dcc4b..f62d723e6aa 100644 --- a/clippy_lints/src/misc.rs +++ b/clippy_lints/src/misc.rs @@ -34,7 +34,7 @@ declare_clippy_lint! { /// dereferences, e.g. changing `*x` to `x` within the function. /// /// **Example:** - /// ```rust + /// ```ignore /// fn foo(ref x: u8) -> bool { /// .. /// } @@ -53,7 +53,7 @@ declare_clippy_lint! { /// **Known problems:** None. /// /// **Example:** - /// ```rust + /// ```ignore /// x == NAN /// ``` pub CMP_NAN, @@ -74,7 +74,7 @@ declare_clippy_lint! { /// **Known problems:** None. /// /// **Example:** - /// ```rust + /// ```ignore /// y == 1.23f64 /// y != x // where both are floats /// ``` @@ -113,7 +113,7 @@ declare_clippy_lint! { /// **Known problems:** None. /// /// **Example:** - /// ```rust + /// ```ignore /// x % 1 /// ``` pub MODULO_ONE, @@ -130,7 +130,7 @@ declare_clippy_lint! { /// **Known problems:** None. /// /// **Example:** - /// ```rust + /// ```ignore /// match v { /// Some(x) => (), /// y @ _ => (), // easier written as `y`, @@ -193,7 +193,7 @@ declare_clippy_lint! { /// /// **Example:** /// - /// ```rust + /// ```ignore /// 0 as *const u32 /// ``` pub ZERO_PTR, diff --git a/clippy_lints/src/misc_early.rs b/clippy_lints/src/misc_early.rs index e522326066c..e42f0bfae89 100644 --- a/clippy_lints/src/misc_early.rs +++ b/clippy_lints/src/misc_early.rs @@ -18,7 +18,7 @@ declare_clippy_lint! { /// **Known problems:** None. /// /// **Example:** - /// ```rust + /// ```ignore /// let { a: _, b: ref b, c: _ } = .. /// ``` pub UNNEEDED_FIELD_PATTERN, @@ -71,6 +71,7 @@ declare_clippy_lint! { /// /// **Example:** /// ```rust + /// let mut x = 3; /// --x; /// ``` pub DOUBLE_NEG, @@ -159,7 +160,7 @@ declare_clippy_lint! { /// /// **Example:** /// - /// ```rust + /// ```ignore /// impl Foo { /// fn impl_func(&self) -> u32 { /// 42 diff --git a/clippy_lints/src/mut_reference.rs b/clippy_lints/src/mut_reference.rs index 69f41e23508..136fb8b5572 100644 --- a/clippy_lints/src/mut_reference.rs +++ b/clippy_lints/src/mut_reference.rs @@ -15,7 +15,7 @@ declare_clippy_lint! { /// **Known problems:** None. /// /// **Example:** - /// ```rust + /// ```ignore /// my_vec.push(&mut value) /// ``` pub UNNECESSARY_MUT_PASSED, diff --git a/clippy_lints/src/neg_multiply.rs b/clippy_lints/src/neg_multiply.rs index dde998a9a5c..757a3cb6cd5 100644 --- a/clippy_lints/src/neg_multiply.rs +++ b/clippy_lints/src/neg_multiply.rs @@ -15,7 +15,7 @@ declare_clippy_lint! { /// **Known problems:** This only catches integers (for now). /// /// **Example:** - /// ```rust + /// ```ignore /// x * -1 /// ``` pub NEG_MULTIPLY, diff --git a/clippy_lints/src/new_without_default.rs b/clippy_lints/src/new_without_default.rs index 127438da917..701cfe20590 100644 --- a/clippy_lints/src/new_without_default.rs +++ b/clippy_lints/src/new_without_default.rs @@ -29,7 +29,7 @@ declare_clippy_lint! { /// /// **Example:** /// - /// ```rust + /// ```ignore /// struct Foo(Bar); /// /// impl Foo { @@ -41,7 +41,7 @@ declare_clippy_lint! { /// /// Instead, use: /// - /// ```rust + /// ```ignore /// struct Foo(Bar); /// /// impl Default for Foo { diff --git a/clippy_lints/src/non_expressive_names.rs b/clippy_lints/src/non_expressive_names.rs index 9bb3a1d3d6b..7bdeec0a56f 100644 --- a/clippy_lints/src/non_expressive_names.rs +++ b/clippy_lints/src/non_expressive_names.rs @@ -16,7 +16,7 @@ declare_clippy_lint! { /// **Known problems:** None? /// /// **Example:** - /// ```rust + /// ```ignore /// let checked_exp = something; /// let checked_expr = something_else; /// ``` @@ -35,7 +35,7 @@ declare_clippy_lint! { /// **Known problems:** None? /// /// **Example:** - /// ```rust + /// ```ignore /// let (a, b, c, d, e, f, g) = (...); /// ``` pub MANY_SINGLE_CHAR_NAMES, diff --git a/clippy_lints/src/ok_if_let.rs b/clippy_lints/src/ok_if_let.rs index b82d0372b81..11c392b581a 100644 --- a/clippy_lints/src/ok_if_let.rs +++ b/clippy_lints/src/ok_if_let.rs @@ -13,7 +13,7 @@ declare_clippy_lint! { /// **Known problems:** None. /// /// **Example:** - /// ```rust + /// ```ignore /// for result in iter { /// if let Some(bench) = try!(result).parse().ok() { /// vec.push(bench) @@ -22,7 +22,7 @@ declare_clippy_lint! { /// ``` /// Could be written: /// - /// ```rust + /// ```ignore /// for result in iter { /// if let Ok(bench) = try!(result).parse() { /// vec.push(bench) diff --git a/clippy_lints/src/open_options.rs b/clippy_lints/src/open_options.rs index 65257973bea..43c7f3884d3 100644 --- a/clippy_lints/src/open_options.rs +++ b/clippy_lints/src/open_options.rs @@ -16,7 +16,9 @@ declare_clippy_lint! { /// /// **Example:** /// ```rust - /// OpenOptions::new().read(true).truncate(true) + /// use std::fs::OpenOptions; + /// + /// OpenOptions::new().read(true).truncate(true); /// ``` pub NONSENSICAL_OPEN_OPTIONS, correctness, diff --git a/clippy_lints/src/panic_unimplemented.rs b/clippy_lints/src/panic_unimplemented.rs index bd73f5a0572..6d1e6d0c66f 100644 --- a/clippy_lints/src/panic_unimplemented.rs +++ b/clippy_lints/src/panic_unimplemented.rs @@ -18,7 +18,7 @@ declare_clippy_lint! { /// **Known problems:** None. /// /// **Example:** - /// ```rust + /// ```no_run /// panic!("This `panic!` is probably missing a parameter there: {}"); /// ``` pub PANIC_PARAMS, @@ -34,7 +34,7 @@ declare_clippy_lint! { /// **Known problems:** None. /// /// **Example:** - /// ```rust + /// ```no_run /// unimplemented!(); /// ``` pub UNIMPLEMENTED, diff --git a/clippy_lints/src/ptr.rs b/clippy_lints/src/ptr.rs index 68fb5b0b20f..331f4216d26 100644 --- a/clippy_lints/src/ptr.rs +++ b/clippy_lints/src/ptr.rs @@ -41,7 +41,7 @@ declare_clippy_lint! { /// function before applying the lint suggestions in this case. /// /// **Example:** - /// ```rust + /// ```ignore /// fn foo(&Vec) { .. } /// ``` pub PTR_ARG, @@ -59,7 +59,7 @@ declare_clippy_lint! { /// **Known problems:** None. /// /// **Example:** - /// ```rust + /// ```ignore /// if x == ptr::null { /// .. /// } @@ -86,7 +86,7 @@ declare_clippy_lint! { /// case is unlikely anyway. /// /// **Example:** - /// ```rust + /// ```ignore /// fn foo(&Foo) -> &mut Bar { .. } /// ``` pub MUT_FROM_REF, diff --git a/clippy_lints/src/question_mark.rs b/clippy_lints/src/question_mark.rs index 13ae2c29b55..762401098e6 100644 --- a/clippy_lints/src/question_mark.rs +++ b/clippy_lints/src/question_mark.rs @@ -18,7 +18,7 @@ declare_clippy_lint! { /// **Known problems:** None /// /// **Example:** - /// ```rust + /// ```ignore /// if option.is_none() { /// return None; /// } @@ -26,7 +26,7 @@ declare_clippy_lint! { /// /// Could be written: /// - /// ```rust + /// ```ignore /// option?; /// ``` pub QUESTION_MARK, diff --git a/clippy_lints/src/ranges.rs b/clippy_lints/src/ranges.rs index 353b1700b45..928f209fc44 100644 --- a/clippy_lints/src/ranges.rs +++ b/clippy_lints/src/ranges.rs @@ -19,7 +19,7 @@ declare_clippy_lint! { /// **Known problems:** None. /// /// **Example:** - /// ```rust + /// ```ignore /// for x in (5..5).step_by(0) { /// .. /// } diff --git a/clippy_lints/src/redundant_field_names.rs b/clippy_lints/src/redundant_field_names.rs index d05560653ef..7e53035d9dc 100644 --- a/clippy_lints/src/redundant_field_names.rs +++ b/clippy_lints/src/redundant_field_names.rs @@ -21,11 +21,11 @@ declare_clippy_lint! { /// bar: u8, /// } /// - /// let foo = Foo{ bar: bar } + /// let foo = Foo { bar: bar }; /// ``` /// the last line can be simplified to - /// ```rust - /// let foo = Foo{ bar } + /// ```ignore + /// let foo = Foo { bar }; /// ``` pub REDUNDANT_FIELD_NAMES, style, diff --git a/clippy_lints/src/regex.rs b/clippy_lints/src/regex.rs index a875256870d..65b8f7c62b9 100644 --- a/clippy_lints/src/regex.rs +++ b/clippy_lints/src/regex.rs @@ -20,7 +20,7 @@ declare_clippy_lint! { /// **Known problems:** None. /// /// **Example:** - /// ```rust + /// ```ignore /// Regex::new("|") /// ``` pub INVALID_REGEX, @@ -39,7 +39,7 @@ declare_clippy_lint! { /// **Known problems:** None. /// /// **Example:** - /// ```rust + /// ```ignore /// Regex::new("^foobar") /// ``` pub TRIVIAL_REGEX, @@ -58,7 +58,7 @@ declare_clippy_lint! { /// **Known problems:** None. /// /// **Example:** - /// ```rust + /// ```ignore /// regex!("foo|bar") /// ``` pub REGEX_MACRO, diff --git a/clippy_lints/src/returns.rs b/clippy_lints/src/returns.rs index 2ea4b8daf8c..789ce8948fa 100644 --- a/clippy_lints/src/returns.rs +++ b/clippy_lints/src/returns.rs @@ -19,13 +19,13 @@ declare_clippy_lint! { /// /// **Example:** /// ```rust - /// fn foo(x: usize) { + /// fn foo(x: usize) -> usize { /// return x; /// } /// ``` /// simplify to /// ```rust - /// fn foo(x: usize) { + /// fn foo(x: usize) -> usize { /// x /// } /// ``` diff --git a/clippy_lints/src/suspicious_trait_impl.rs b/clippy_lints/src/suspicious_trait_impl.rs index cb7fc0fee80..0b242d614d0 100644 --- a/clippy_lints/src/suspicious_trait_impl.rs +++ b/clippy_lints/src/suspicious_trait_impl.rs @@ -14,7 +14,7 @@ declare_clippy_lint! { /// **Known problems:** None. /// /// **Example:** - /// ```rust + /// ```ignore /// impl Add for Foo { /// type Output = Foo; /// @@ -37,7 +37,7 @@ declare_clippy_lint! { /// **Known problems:** None. /// /// **Example:** - /// ```rust + /// ```ignore /// impl AddAssign for Foo { /// fn add_assign(&mut self, other: Foo) { /// *self = *self - other; diff --git a/clippy_lints/src/transmute.rs b/clippy_lints/src/transmute.rs index aa4f808ee3f..13226793e7e 100644 --- a/clippy_lints/src/transmute.rs +++ b/clippy_lints/src/transmute.rs @@ -19,7 +19,7 @@ declare_clippy_lint! { /// sized objects in `extradata` arguments to save an allocation. /// /// **Example:** - /// ```rust + /// ```ignore /// let ptr: *const T = core::intrinsics::transmute('x') /// ``` pub WRONG_TRANSMUTE, diff --git a/clippy_lints/src/types.rs b/clippy_lints/src/types.rs index 3b057081c73..9071d6b7703 100644 --- a/clippy_lints/src/types.rs +++ b/clippy_lints/src/types.rs @@ -509,7 +509,7 @@ declare_clippy_lint! { /// **Known problems:** None. /// /// **Example:** - /// ```rust + /// ```ignore /// if { /// foo(); /// } == { @@ -519,7 +519,7 @@ declare_clippy_lint! { /// } /// ``` /// is equal to - /// ```rust + /// ```ignore /// { /// foo(); /// bar(); @@ -848,7 +848,7 @@ declare_clippy_lint! { /// /// **Example** /// - /// ```rust + /// ```ignore /// // Bad /// fn fun() -> i32 {} /// let a = fun as i64; @@ -1536,7 +1536,7 @@ declare_clippy_lint! { /// like `#[cfg(target_pointer_width = "64")] ..` instead. /// /// **Example:** - /// ```rust + /// ```ignore /// vec.len() <= 0 /// 100 > std::i32::MAX /// ``` @@ -1961,7 +1961,7 @@ declare_clippy_lint! { /// pieces of code, possibly including external crates. /// /// **Example:** - /// ```rust + /// ```ignore /// impl Serialize for HashMap { ... } /// /// pub foo(map: &mut HashMap) { .. } @@ -2302,7 +2302,7 @@ declare_clippy_lint! { /// **Known problems:** None. /// /// **Example:** - /// ```rust + /// ```ignore /// fn x(r: &i32) { /// unsafe { /// *(r as *const _ as *mut _) += 1; @@ -2312,7 +2312,7 @@ declare_clippy_lint! { /// /// Instead consider using interior mutability types. /// - /// ```rust + /// ```ignore /// fn x(r: &UnsafeCell) { /// unsafe { /// *r.get() += 1; diff --git a/clippy_lints/src/write.rs b/clippy_lints/src/write.rs index e433bd69cb0..236875f0aca 100644 --- a/clippy_lints/src/write.rs +++ b/clippy_lints/src/write.rs @@ -35,11 +35,11 @@ declare_clippy_lint! { /// **Known problems:** None. /// /// **Example:** - /// ```rust + /// ```ignore /// print!("Hello {}!\n", name); /// ``` /// use println!() instead - /// ```rust + /// ```ignore /// println!("Hello {}!", name); /// ``` pub PRINT_WITH_NEWLINE, @@ -113,12 +113,12 @@ declare_clippy_lint! { /// **Known problems:** None. /// /// **Example:** - /// ```rust - /// writeln!(""); + /// ```ignore + /// writeln!(buf, ""); /// ``` pub WRITELN_EMPTY_STRING, style, - "using `writeln!(\"\")` with an empty string" + "using `writeln!(buf, \"\")` with an empty string" } declare_clippy_lint! { @@ -132,7 +132,7 @@ declare_clippy_lint! { /// **Known problems:** None. /// /// **Example:** - /// ```rust + /// ```ignore /// write!(buf, "Hello {}!\n", name); /// ``` pub WRITE_WITH_NEWLINE, @@ -151,7 +151,7 @@ declare_clippy_lint! { /// -- e.g., `writeln!(buf, "{}", env!("FOO"))`. /// /// **Example:** - /// ```rust + /// ```ignore /// writeln!(buf, "{}", "foo"); /// ``` pub WRITE_LITERAL,