diff --git a/clippy_lints/src/casts/mod.rs b/clippy_lints/src/casts/mod.rs index fe8e372b6..74ea70d1a 100644 --- a/clippy_lints/src/casts/mod.rs +++ b/clippy_lints/src/casts/mod.rs @@ -220,15 +220,13 @@ declare_clippy_lint! { /// ### Example /// ```rust /// fn fun() -> i32 { 1 } - /// # let _ = - /// fun as i64; + /// let _ = fun as i64; /// ``` /// /// Use instead: /// ```rust /// # fn fun() -> i32 { 1 } - /// # let _ = - /// fun as usize; + /// let _ = fun as usize; /// ``` #[clippy::version = "pre 1.29.0"] pub FN_TO_NUMERIC_CAST, @@ -251,8 +249,7 @@ declare_clippy_lint! { /// fn fn1() -> i16 { /// 1 /// }; - /// # let _ = - /// fn1 as i32; + /// let _ = fn1 as i32; /// ``` /// /// Use instead: @@ -287,8 +284,7 @@ declare_clippy_lint! { /// fn fn1() -> u16 { /// 1 /// }; - /// # let _ = - /// fn1 as usize; + /// let _ = fn1 as usize; /// ``` /// /// Use instead: @@ -297,8 +293,7 @@ declare_clippy_lint! { /// fn fn2() -> u16 { /// 1 /// }; - /// # let _ = - /// fn2() as usize; + /// let _ = fn2() as usize; /// /// // or /// @@ -306,8 +301,7 @@ declare_clippy_lint! { /// fn fn3() -> u16 { /// 1 /// } - /// # let _ = - /// fn3 as fn() -> u16; + /// let _ = fn3 as fn() -> u16; /// ``` #[clippy::version = "1.58.0"] pub FN_TO_NUMERIC_CAST_ANY, diff --git a/clippy_lints/src/checked_conversions.rs b/clippy_lints/src/checked_conversions.rs index 1010340c7..4b99d1d61 100644 --- a/clippy_lints/src/checked_conversions.rs +++ b/clippy_lints/src/checked_conversions.rs @@ -22,18 +22,14 @@ declare_clippy_lint! { /// ### Example /// ```rust /// # let foo: u32 = 5; - /// # let _ = - /// foo <= i32::MAX as u32 - /// # ; + /// foo <= i32::MAX as u32; /// ``` /// - /// Could be written: - /// + /// Use instead: /// ```rust /// # let foo = 1; - /// # let _ = - /// i32::try_from(foo).is_ok() - /// # ; + /// # #[allow(unused)] + /// i32::try_from(foo).is_ok(); /// ``` #[clippy::version = "1.37.0"] pub CHECKED_CONVERSIONS, diff --git a/clippy_lints/src/indexing_slicing.rs b/clippy_lints/src/indexing_slicing.rs index 301686612..4a375752e 100644 --- a/clippy_lints/src/indexing_slicing.rs +++ b/clippy_lints/src/indexing_slicing.rs @@ -67,16 +67,14 @@ declare_clippy_lint! { /// /// Use instead: /// ```rust + /// # #![allow(unused)] + /// /// # let x = vec![0; 5]; /// # let y = [0, 1, 2, 3]; - /// # let _ = /// x.get(2); - /// # let _ = /// x.get(2..100); /// - /// # let _ = /// y.get(10); - /// # let _ = /// y.get(10..100); /// ``` #[clippy::version = "pre 1.29.0"] diff --git a/clippy_lints/src/infinite_iter.rs b/clippy_lints/src/infinite_iter.rs index fc8e473dd..27fa90422 100644 --- a/clippy_lints/src/infinite_iter.rs +++ b/clippy_lints/src/infinite_iter.rs @@ -41,7 +41,7 @@ declare_clippy_lint! { /// ### Example /// ```rust /// let infinite_iter = 0..; - /// # let _ = + /// # #[allow(unused)] /// [0..].iter().zip(infinite_iter.take_while(|x| *x > 5)); /// ``` #[clippy::version = "pre 1.29.0"] diff --git a/clippy_lints/src/methods/mod.rs b/clippy_lints/src/methods/mod.rs index 9d78f0a9f..e1ea8426e 100644 --- a/clippy_lints/src/methods/mod.rs +++ b/clippy_lints/src/methods/mod.rs @@ -131,18 +131,14 @@ declare_clippy_lint! { /// ### Examples /// ```rust /// # let vec = vec!["string".to_string()]; - /// # let _ = /// vec.iter().cloned().take(10); - /// # let _ = /// vec.iter().cloned().last(); /// ``` /// /// Use instead: /// ```rust /// # let vec = vec!["string".to_string()]; - /// # let _ = /// vec.iter().take(10).cloned(); - /// # let _ = /// vec.iter().last().cloned(); /// ``` #[clippy::version = "1.59.0"] @@ -590,7 +586,6 @@ declare_clippy_lint! { /// let vec = vec![vec![1]]; /// let opt = Some(5); /// - /// # let _ = /// vec.iter().map(|x| x.iter()).flatten(); /// opt.map(|x| Some(x * 2)).flatten(); /// ``` @@ -599,7 +594,6 @@ declare_clippy_lint! { /// ```rust /// # let vec = vec![vec![1]]; /// # let opt = Some(5); - /// # let _ = /// vec.iter().flat_map(|x| x.iter()); /// opt.and_then(|x| Some(x * 2)); /// ``` @@ -620,7 +614,7 @@ declare_clippy_lint! { /// /// ### Example /// ```rust - /// # let _ = + /// # #![allow(unused)] /// (0_i32..10) /// .filter(|n| n.checked_add(1).is_some()) /// .map(|n| n.checked_add(1).unwrap()); @@ -628,7 +622,7 @@ declare_clippy_lint! { /// /// Use instead: /// ```rust - /// # let _ = + /// # #[allow(unused)] /// (0_i32..10).filter_map(|n| n.checked_add(1)); /// ``` #[clippy::version = "1.51.0"] @@ -721,11 +715,10 @@ declare_clippy_lint! { /// /// ### Example /// ```rust + /// # #![allow(unused)] /// let vec = vec![1]; - /// # let _ = /// vec.iter().find(|x| **x == 0).is_some(); /// - /// # let _ = /// "hello world".find("world").is_none(); /// ``` /// @@ -734,7 +727,7 @@ declare_clippy_lint! { /// let vec = vec![1]; /// vec.iter().any(|x| *x == 0); /// - /// # let _ = + /// # #[allow(unused)] /// !"hello world".contains("world"); /// ``` #[clippy::version = "pre 1.29.0"] @@ -1428,13 +1421,12 @@ declare_clippy_lint! { /// /// ### Example /// ```rust - /// # let _ = + /// # #[allow(unused)] /// (0..3).fold(false, |acc, x| acc || x > 2); /// ``` /// /// Use instead: /// ```rust - /// # let _ = /// (0..3).any(|x| x > 2); /// ``` #[clippy::version = "pre 1.29.0"] @@ -1515,14 +1507,14 @@ declare_clippy_lint! { /// /// ### Example /// ```rust - /// # let _ = - /// (&vec![3, 4, 5]).into_iter(); + /// # let vec = vec![3, 4, 5]; + /// (&vec).into_iter(); /// ``` /// /// Use instead: /// ```rust - /// # let _ = - /// (&vec![3, 4, 5]).iter(); + /// # let vec = vec![3, 4, 5]; + /// (&vec).iter(); /// ``` #[clippy::version = "1.32.0"] pub INTO_ITER_ON_REF, @@ -1931,13 +1923,13 @@ declare_clippy_lint! { /// /// ### Example /// ```rust - /// # let _ = + /// # #[allow(unused)] /// "Hello".bytes().nth(3); /// ``` /// /// Use instead: /// ```rust - /// # let _ = + /// # #[allow(unused)] /// "Hello".as_bytes().get(3); /// ``` #[clippy::version = "1.52.0"] @@ -1982,19 +1974,18 @@ declare_clippy_lint! { /// /// ### Example /// ```rust + /// # #![allow(unused)] /// let some_vec = vec![0, 1, 2, 3]; - /// # let _ = + /// /// some_vec.iter().count(); - /// # let _ = /// &some_vec[..].iter().count(); /// ``` /// /// Use instead: /// ```rust /// let some_vec = vec![0, 1, 2, 3]; - /// # let _ = + /// /// some_vec.len(); - /// # let _ = /// &some_vec[..].len(); /// ``` #[clippy::version = "1.52.0"] diff --git a/clippy_lints/src/needless_borrowed_ref.rs b/clippy_lints/src/needless_borrowed_ref.rs index 55da6e0f0..05c012b92 100644 --- a/clippy_lints/src/needless_borrowed_ref.rs +++ b/clippy_lints/src/needless_borrowed_ref.rs @@ -29,14 +29,14 @@ declare_clippy_lint! { /// ### Example /// ```rust /// let mut v = Vec::::new(); - /// # let _ = + /// # #[allow(unused)] /// v.iter_mut().filter(|&ref a| a.is_empty()); /// ``` /// /// Use instead: /// ```rust /// let mut v = Vec::::new(); - /// # let _ = + /// # #[allow(unused)] /// v.iter_mut().filter(|a| a.is_empty()); /// ``` #[clippy::version = "pre 1.29.0"] diff --git a/clippy_lints/src/ranges.rs b/clippy_lints/src/ranges.rs index be7eae026..056637c20 100644 --- a/clippy_lints/src/ranges.rs +++ b/clippy_lints/src/ranges.rs @@ -27,15 +27,13 @@ declare_clippy_lint! { /// ### Example /// ```rust /// # let x = vec![1]; - /// # let _ = - /// x.iter().zip(0..x.len()); + /// let _ = x.iter().zip(0..x.len()); /// ``` /// /// Use instead: /// ```rust /// # let x = vec![1]; - /// # let _ = - /// x.iter().enumerate(); + /// let _ = x.iter().enumerate(); /// ``` #[clippy::version = "pre 1.29.0"] pub RANGE_ZIP_WITH_LEN, diff --git a/clippy_lints/src/strings.rs b/clippy_lints/src/strings.rs index 9ea2de001..71f3e6b6a 100644 --- a/clippy_lints/src/strings.rs +++ b/clippy_lints/src/strings.rs @@ -224,13 +224,11 @@ declare_clippy_lint! { /// /// ### Example /// ```rust - /// # let _ = /// std::str::from_utf8(&"Hello World!".as_bytes()[6..11]).unwrap(); /// ``` /// /// Use instead: /// ```rust - /// # let _ = /// &"Hello World!"[6..11]; /// ``` #[clippy::version = "1.50.0"] diff --git a/clippy_lints/src/write.rs b/clippy_lints/src/write.rs index bb74f2a7f..67b2bc8c3 100644 --- a/clippy_lints/src/write.rs +++ b/clippy_lints/src/write.rs @@ -178,7 +178,6 @@ declare_clippy_lint! { /// ```rust /// # use std::fmt::Write; /// # let mut buf = String::new(); - /// # let _ = /// writeln!(buf, ""); /// ``` /// @@ -186,7 +185,6 @@ declare_clippy_lint! { /// ```rust /// # use std::fmt::Write; /// # let mut buf = String::new(); - /// # let _ = /// writeln!(buf); /// ``` #[clippy::version = "pre 1.29.0"] @@ -210,7 +208,6 @@ declare_clippy_lint! { /// # use std::fmt::Write; /// # let mut buf = String::new(); /// # let name = "World"; - /// # let _ = /// write!(buf, "Hello {}!\n", name); /// ``` /// @@ -219,7 +216,6 @@ declare_clippy_lint! { /// # use std::fmt::Write; /// # let mut buf = String::new(); /// # let name = "World"; - /// # let _ = /// writeln!(buf, "Hello {}!", name); /// ``` #[clippy::version = "pre 1.29.0"] @@ -245,7 +241,6 @@ declare_clippy_lint! { /// ```rust /// # use std::fmt::Write; /// # let mut buf = String::new(); - /// # let _ = /// writeln!(buf, "{}", "foo"); /// ``` /// @@ -253,7 +248,6 @@ declare_clippy_lint! { /// ```rust /// # use std::fmt::Write; /// # let mut buf = String::new(); - /// # let _ = /// writeln!(buf, "foo"); /// ``` #[clippy::version = "pre 1.29.0"]