mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-04 04:39:16 +00:00
fix or ignore failing doc tests
This commit is contained in:
parent
fe96ffeac9
commit
a9de64a151
@ -15,13 +15,13 @@ declare_clippy_lint! {
|
|||||||
/// **Known problems:** None
|
/// **Known problems:** None
|
||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```no_run
|
||||||
/// assert!(false)
|
/// assert!(false);
|
||||||
/// // or
|
/// // or
|
||||||
/// assert!(true)
|
/// assert!(true);
|
||||||
/// // or
|
/// // or
|
||||||
/// const B: bool = false;
|
/// const B: bool = false;
|
||||||
/// assert!(B)
|
/// assert!(B);
|
||||||
/// ```
|
/// ```
|
||||||
pub ASSERTIONS_ON_CONSTANTS,
|
pub ASSERTIONS_ON_CONSTANTS,
|
||||||
style,
|
style,
|
||||||
|
@ -17,7 +17,7 @@ declare_clippy_lint! {
|
|||||||
/// implementations that differ from the regular `Op` impl.
|
/// implementations that differ from the regular `Op` impl.
|
||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// let mut a = 5;
|
/// let mut a = 5;
|
||||||
/// ...
|
/// ...
|
||||||
/// a = a + b;
|
/// a = a + b;
|
||||||
@ -39,7 +39,7 @@ declare_clippy_lint! {
|
|||||||
/// written as `a = a op a op b` as it's less confusing.
|
/// written as `a = a op a op b` as it's less confusing.
|
||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// let mut a = 5;
|
/// let mut a = 5;
|
||||||
/// ...
|
/// ...
|
||||||
/// a += a + b;
|
/// a += a + b;
|
||||||
|
@ -34,7 +34,7 @@ declare_clippy_lint! {
|
|||||||
/// done the measurement.
|
/// done the measurement.
|
||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// #[inline(always)]
|
/// #[inline(always)]
|
||||||
/// fn not_quite_hot_code(..) { ... }
|
/// fn not_quite_hot_code(..) { ... }
|
||||||
/// ```
|
/// ```
|
||||||
@ -57,7 +57,7 @@ declare_clippy_lint! {
|
|||||||
/// **Known problems:** None.
|
/// **Known problems:** None.
|
||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// // Bad
|
/// // Bad
|
||||||
/// #[deny(dead_code)]
|
/// #[deny(dead_code)]
|
||||||
/// extern crate foo;
|
/// extern crate foo;
|
||||||
@ -88,7 +88,7 @@ declare_clippy_lint! {
|
|||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// #[deprecated(since = "forever")]
|
/// #[deprecated(since = "forever")]
|
||||||
/// fn something_else(..) { ... }
|
/// fn something_else() { /* ... */ }
|
||||||
/// ```
|
/// ```
|
||||||
pub DEPRECATED_SEMVER,
|
pub DEPRECATED_SEMVER,
|
||||||
correctness,
|
correctness,
|
||||||
|
@ -37,7 +37,7 @@ declare_clippy_lint! {
|
|||||||
/// **Known problems:** None.
|
/// **Known problems:** None.
|
||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// if (x & 1 == 2) { … }
|
/// if (x & 1 == 2) { … }
|
||||||
/// ```
|
/// ```
|
||||||
pub BAD_BIT_MASK,
|
pub BAD_BIT_MASK,
|
||||||
@ -65,7 +65,7 @@ declare_clippy_lint! {
|
|||||||
/// uncommon).
|
/// uncommon).
|
||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// if (x | 1 > 3) { … }
|
/// if (x | 1 > 3) { … }
|
||||||
/// ```
|
/// ```
|
||||||
pub INEFFECTIVE_BIT_MASK,
|
pub INEFFECTIVE_BIT_MASK,
|
||||||
@ -83,7 +83,7 @@ declare_clippy_lint! {
|
|||||||
/// **Known problems:** llvm generates better code for `x & 15 == 0` on x86
|
/// **Known problems:** llvm generates better code for `x & 15 == 0` on x86
|
||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// x & 0x1111 == 0
|
/// x & 0x1111 == 0
|
||||||
/// ```
|
/// ```
|
||||||
pub VERBOSE_BIT_MASK,
|
pub VERBOSE_BIT_MASK,
|
||||||
|
@ -16,7 +16,7 @@ declare_clippy_lint! {
|
|||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// if { true } ..
|
/// if { true } { /* ... */ }
|
||||||
/// ```
|
/// ```
|
||||||
pub BLOCK_IN_IF_CONDITION_EXPR,
|
pub BLOCK_IN_IF_CONDITION_EXPR,
|
||||||
style,
|
style,
|
||||||
@ -32,10 +32,10 @@ declare_clippy_lint! {
|
|||||||
/// **Known problems:** None.
|
/// **Known problems:** None.
|
||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// if { let x = somefunc(); x } ..
|
/// if { let x = somefunc(); x } {}
|
||||||
/// // or
|
/// // or
|
||||||
/// if somefunc(|x| { x == 47 }) ..
|
/// if somefunc(|x| { x == 47 }) {}
|
||||||
/// ```
|
/// ```
|
||||||
pub BLOCK_IN_IF_CONDITION_STMT,
|
pub BLOCK_IN_IF_CONDITION_STMT,
|
||||||
style,
|
style,
|
||||||
|
@ -21,7 +21,7 @@ declare_clippy_lint! {
|
|||||||
/// `&&`. Ignores `|`, `&` and `^`.
|
/// `&&`. Ignores `|`, `&` and `^`.
|
||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// if a && true // should be: if a
|
/// if a && true // should be: if a
|
||||||
/// if !(a == b) // should be: if a != b
|
/// if !(a == b) // should be: if a != b
|
||||||
/// ```
|
/// ```
|
||||||
@ -39,7 +39,7 @@ declare_clippy_lint! {
|
|||||||
/// **Known problems:** Ignores short circuiting behavior.
|
/// **Known problems:** Ignores short circuiting behavior.
|
||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// if a && b || a { ... }
|
/// if a && b || a { ... }
|
||||||
/// ```
|
/// ```
|
||||||
/// The `b` is unnecessary, the expression is equivalent to `if a`.
|
/// The `b` is unnecessary, the expression is equivalent to `if a`.
|
||||||
|
@ -13,12 +13,12 @@ declare_clippy_lint! {
|
|||||||
/// **Known problems:** None.
|
/// **Known problems:** None.
|
||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// const FOO: &'static [(&'static str, &'static str, fn(&Bar) -> bool)] =
|
/// const FOO: &'static [(&'static str, &'static str, fn(&Bar) -> bool)] =
|
||||||
/// &[...]
|
/// &[...]
|
||||||
/// ```
|
/// ```
|
||||||
/// This code can be rewritten as
|
/// This code can be rewritten as
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// const FOO: &[(&str, &str, fn(&Bar) -> bool)] = &[...]
|
/// const FOO: &[(&str, &str, fn(&Bar) -> bool)] = &[...]
|
||||||
/// ```
|
/// ```
|
||||||
pub CONST_STATIC_LIFETIME,
|
pub CONST_STATIC_LIFETIME,
|
||||||
|
@ -18,7 +18,7 @@ declare_clippy_lint! {
|
|||||||
/// **Known problems:** Hopefully none.
|
/// **Known problems:** Hopefully none.
|
||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// if a == b {
|
/// if a == b {
|
||||||
/// …
|
/// …
|
||||||
/// } else 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
|
/// Note that this lint ignores all conditions with a function call as it could
|
||||||
/// have side effects:
|
/// have side effects:
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// if foo() {
|
/// if foo() {
|
||||||
/// …
|
/// …
|
||||||
/// } else if foo() { // not linted
|
/// } else if foo() { // not linted
|
||||||
@ -50,7 +50,7 @@ declare_clippy_lint! {
|
|||||||
/// **Known problems:** Hopefully none.
|
/// **Known problems:** Hopefully none.
|
||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// let foo = if … {
|
/// let foo = if … {
|
||||||
/// 42
|
/// 42
|
||||||
/// } else {
|
/// } else {
|
||||||
|
@ -16,14 +16,14 @@ declare_clippy_lint! {
|
|||||||
/// default-generated `Hash` implementation with an explicitly defined
|
/// default-generated `Hash` implementation with an explicitly defined
|
||||||
/// `PartialEq`. In particular, the following must hold for any type:
|
/// `PartialEq`. In particular, the following must hold for any type:
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```text
|
||||||
/// k1 == k2 ⇒ hash(k1) == hash(k2)
|
/// k1 == k2 ⇒ hash(k1) == hash(k2)
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// **Known problems:** None.
|
/// **Known problems:** None.
|
||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// #[derive(Hash)]
|
/// #[derive(Hash)]
|
||||||
/// struct Foo;
|
/// struct Foo;
|
||||||
///
|
///
|
||||||
|
@ -17,7 +17,7 @@ declare_clippy_lint! {
|
|||||||
/// **Known problems:** None.
|
/// **Known problems:** None.
|
||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// let mut lock_guard = mutex.lock();
|
/// let mut lock_guard = mutex.lock();
|
||||||
/// std::mem::drop(&lock_guard) // Should have been drop(lock_guard), mutex
|
/// std::mem::drop(&lock_guard) // Should have been drop(lock_guard), mutex
|
||||||
/// // still locked
|
/// // still locked
|
||||||
|
@ -88,7 +88,7 @@ declare_clippy_lint! {
|
|||||||
/// **Known problems:** None.
|
/// **Known problems:** None.
|
||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// // lib.rs
|
/// // lib.rs
|
||||||
/// mod foo;
|
/// mod foo;
|
||||||
/// // foo.rs
|
/// // foo.rs
|
||||||
|
@ -19,7 +19,7 @@ declare_clippy_lint! {
|
|||||||
/// calls. We may introduce a whitelist of known pure functions in the future.
|
/// calls. We may introduce a whitelist of known pure functions in the future.
|
||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// x + 1 == x + 1
|
/// x + 1 == x + 1
|
||||||
/// ```
|
/// ```
|
||||||
pub EQ_OP,
|
pub EQ_OP,
|
||||||
@ -37,7 +37,7 @@ declare_clippy_lint! {
|
|||||||
/// **Known problems:** None
|
/// **Known problems:** None
|
||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// &x == y
|
/// &x == y
|
||||||
/// ```
|
/// ```
|
||||||
pub OP_REF,
|
pub OP_REF,
|
||||||
|
@ -15,7 +15,7 @@ declare_clippy_lint! {
|
|||||||
/// **Known problems:** None.
|
/// **Known problems:** None.
|
||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// 0 / x;
|
/// 0 / x;
|
||||||
/// 0 * x;
|
/// 0 * x;
|
||||||
/// x & 0
|
/// x & 0
|
||||||
|
@ -23,7 +23,7 @@ declare_clippy_lint! {
|
|||||||
/// details.
|
/// details.
|
||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// xs.map(|x| foo(x))
|
/// xs.map(|x| foo(x))
|
||||||
/// ```
|
/// ```
|
||||||
/// where `foo(_)` is a plain function that takes the exact argument type of
|
/// where `foo(_)` is a plain function that takes the exact argument type of
|
||||||
|
@ -19,7 +19,8 @@ declare_clippy_lint! {
|
|||||||
/// **Known problems:** Hopefully none.
|
/// **Known problems:** Hopefully none.
|
||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```no_run
|
||||||
|
/// # #![allow(const_err)]
|
||||||
/// let x = [1, 2, 3, 4];
|
/// let x = [1, 2, 3, 4];
|
||||||
///
|
///
|
||||||
/// // Bad
|
/// // Bad
|
||||||
|
@ -12,8 +12,10 @@ declare_clippy_lint! {
|
|||||||
/// **Known problems:** None.
|
/// **Known problems:** None.
|
||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```no_run
|
||||||
/// repeat(1_u8).iter().collect::<Vec<_>>()
|
/// use std::iter;
|
||||||
|
///
|
||||||
|
/// iter::repeat(1_u8).collect::<Vec<_>>();
|
||||||
/// ```
|
/// ```
|
||||||
pub INFINITE_ITER,
|
pub INFINITE_ITER,
|
||||||
correctness,
|
correctness,
|
||||||
|
@ -13,8 +13,8 @@ declare_clippy_lint! {
|
|||||||
/// **Known problems:** None.
|
/// **Known problems:** None.
|
||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```no_run
|
||||||
/// let bad_ref: &usize = std::mem::zeroed();
|
/// let bad_ref: &usize = unsafe { std::mem::zeroed() };
|
||||||
/// ```
|
/// ```
|
||||||
pub INVALID_REF,
|
pub INVALID_REF,
|
||||||
correctness,
|
correctness,
|
||||||
|
@ -22,7 +22,7 @@ declare_clippy_lint! {
|
|||||||
/// **Known problems:** None.
|
/// **Known problems:** None.
|
||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// if x.len() == 0 {
|
/// if x.len() == 0 {
|
||||||
/// ..
|
/// ..
|
||||||
/// }
|
/// }
|
||||||
@ -31,7 +31,7 @@ declare_clippy_lint! {
|
|||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
/// instead use
|
/// instead use
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// if x.is_empty() {
|
/// if x.is_empty() {
|
||||||
/// ..
|
/// ..
|
||||||
/// }
|
/// }
|
||||||
@ -57,7 +57,7 @@ declare_clippy_lint! {
|
|||||||
/// **Known problems:** None.
|
/// **Known problems:** None.
|
||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// impl X {
|
/// impl X {
|
||||||
/// pub fn len(&self) -> usize {
|
/// pub fn len(&self) -> usize {
|
||||||
/// ..
|
/// ..
|
||||||
|
@ -20,7 +20,7 @@ declare_clippy_lint! {
|
|||||||
/// **Example:**
|
/// **Example:**
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// 61864918973511
|
/// let x: u64 = 61864918973511;
|
||||||
/// ```
|
/// ```
|
||||||
pub UNREADABLE_LITERAL,
|
pub UNREADABLE_LITERAL,
|
||||||
style,
|
style,
|
||||||
@ -40,7 +40,7 @@ declare_clippy_lint! {
|
|||||||
/// **Example:**
|
/// **Example:**
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// 2_32
|
/// 2_32;
|
||||||
/// ```
|
/// ```
|
||||||
pub MISTYPED_LITERAL_SUFFIXES,
|
pub MISTYPED_LITERAL_SUFFIXES,
|
||||||
correctness,
|
correctness,
|
||||||
@ -59,7 +59,7 @@ declare_clippy_lint! {
|
|||||||
/// **Example:**
|
/// **Example:**
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// 618_64_9189_73_511
|
/// let x: u64 = 618_64_9189_73_511;
|
||||||
/// ```
|
/// ```
|
||||||
pub INCONSISTENT_DIGIT_GROUPING,
|
pub INCONSISTENT_DIGIT_GROUPING,
|
||||||
style,
|
style,
|
||||||
@ -78,7 +78,7 @@ declare_clippy_lint! {
|
|||||||
/// **Example:**
|
/// **Example:**
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// 6186491_8973511
|
/// let x: u64 = 6186491_8973511;
|
||||||
/// ```
|
/// ```
|
||||||
pub LARGE_DIGIT_GROUPS,
|
pub LARGE_DIGIT_GROUPS,
|
||||||
pedantic,
|
pedantic,
|
||||||
|
@ -41,7 +41,7 @@ declare_clippy_lint! {
|
|||||||
/// **Known problems:** None.
|
/// **Known problems:** None.
|
||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// for i in 0..src.len() {
|
/// for i in 0..src.len() {
|
||||||
/// dst[i + 64] = src[i];
|
/// dst[i + 64] = src[i];
|
||||||
/// }
|
/// }
|
||||||
@ -61,7 +61,7 @@ declare_clippy_lint! {
|
|||||||
/// **Known problems:** None.
|
/// **Known problems:** None.
|
||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// for i in 0..vec.len() {
|
/// for i in 0..vec.len() {
|
||||||
/// println!("{}", vec[i]);
|
/// println!("{}", vec[i]);
|
||||||
/// }
|
/// }
|
||||||
@ -81,7 +81,7 @@ declare_clippy_lint! {
|
|||||||
/// types.
|
/// types.
|
||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// // with `y` a `Vec` or slice:
|
/// // with `y` a `Vec` or slice:
|
||||||
/// for x in y.iter() {
|
/// for x in y.iter() {
|
||||||
/// ..
|
/// ..
|
||||||
@ -107,14 +107,14 @@ declare_clippy_lint! {
|
|||||||
/// **Known problems:** None
|
/// **Known problems:** None
|
||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// // with `y` a `Vec` or slice:
|
/// // with `y` a `Vec` or slice:
|
||||||
/// for x in y.into_iter() {
|
/// for x in y.into_iter() {
|
||||||
/// ..
|
/// ..
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
/// can be rewritten to
|
/// can be rewritten to
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// for x in y {
|
/// for x in y {
|
||||||
/// ..
|
/// ..
|
||||||
/// }
|
/// }
|
||||||
@ -137,7 +137,7 @@ declare_clippy_lint! {
|
|||||||
/// **Known problems:** None.
|
/// **Known problems:** None.
|
||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// for x in y.next() {
|
/// for x in y.next() {
|
||||||
/// ..
|
/// ..
|
||||||
/// }
|
/// }
|
||||||
@ -156,14 +156,14 @@ declare_clippy_lint! {
|
|||||||
/// **Known problems:** None.
|
/// **Known problems:** None.
|
||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// for x in option {
|
/// for x in option {
|
||||||
/// ..
|
/// ..
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// This should be
|
/// This should be
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// if let Some(x) = option {
|
/// if let Some(x) = option {
|
||||||
/// ..
|
/// ..
|
||||||
/// }
|
/// }
|
||||||
@ -182,14 +182,14 @@ declare_clippy_lint! {
|
|||||||
/// **Known problems:** None.
|
/// **Known problems:** None.
|
||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// for x in result {
|
/// for x in result {
|
||||||
/// ..
|
/// ..
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// This should be
|
/// This should be
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// if let Ok(x) = result {
|
/// if let Ok(x) = result {
|
||||||
/// ..
|
/// ..
|
||||||
/// }
|
/// }
|
||||||
@ -237,7 +237,7 @@ declare_clippy_lint! {
|
|||||||
/// **Known problems:** None.
|
/// **Known problems:** None.
|
||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// vec.iter().map(|x| /* some operation returning () */).collect::<Vec<_>>();
|
/// vec.iter().map(|x| /* some operation returning () */).collect::<Vec<_>>();
|
||||||
/// ```
|
/// ```
|
||||||
pub UNUSED_COLLECT,
|
pub UNUSED_COLLECT,
|
||||||
@ -256,7 +256,7 @@ declare_clippy_lint! {
|
|||||||
/// None
|
/// None
|
||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// let len = iterator.collect::<Vec<_>>().len();
|
/// let len = iterator.collect::<Vec<_>>().len();
|
||||||
/// // should be
|
/// // should be
|
||||||
/// let len = iterator.count();
|
/// let len = iterator.count();
|
||||||
@ -280,7 +280,7 @@ declare_clippy_lint! {
|
|||||||
/// paths through the program, which would be complex and error-prone.
|
/// paths through the program, which would be complex and error-prone.
|
||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// for x in 5..10 - 5 {
|
/// for x in 5..10 - 5 {
|
||||||
/// ..
|
/// ..
|
||||||
/// } // oops, stray `-`
|
/// } // oops, stray `-`
|
||||||
@ -301,7 +301,7 @@ declare_clippy_lint! {
|
|||||||
/// **Known problems:** None.
|
/// **Known problems:** None.
|
||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// for i in 0..v.len() { foo(v[i]);
|
/// for i in 0..v.len() { foo(v[i]);
|
||||||
/// for i in 0..v.len() { bar(i, v[i]); }
|
/// for i in 0..v.len() { bar(i, v[i]); }
|
||||||
/// ```
|
/// ```
|
||||||
@ -320,7 +320,7 @@ declare_clippy_lint! {
|
|||||||
/// **Known problems:** None.
|
/// **Known problems:** None.
|
||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```no_run
|
||||||
/// loop {}
|
/// loop {}
|
||||||
/// ```
|
/// ```
|
||||||
pub EMPTY_LOOP,
|
pub EMPTY_LOOP,
|
||||||
@ -337,7 +337,7 @@ declare_clippy_lint! {
|
|||||||
/// **Known problems:** None.
|
/// **Known problems:** None.
|
||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// while let Some(val) = iter() {
|
/// while let Some(val) = iter() {
|
||||||
/// ..
|
/// ..
|
||||||
/// }
|
/// }
|
||||||
@ -357,7 +357,7 @@ declare_clippy_lint! {
|
|||||||
/// **Known problems:** None.
|
/// **Known problems:** None.
|
||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// for (k, _) in &map {
|
/// for (k, _) in &map {
|
||||||
/// ..
|
/// ..
|
||||||
/// }
|
/// }
|
||||||
@ -365,7 +365,7 @@ declare_clippy_lint! {
|
|||||||
///
|
///
|
||||||
/// could be replaced by
|
/// could be replaced by
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// for k in map.keys() {
|
/// for k in map.keys() {
|
||||||
/// ..
|
/// ..
|
||||||
/// }
|
/// }
|
||||||
|
@ -27,7 +27,7 @@ declare_clippy_lint! {
|
|||||||
/// **Known problems:** None.
|
/// **Known problems:** None.
|
||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// match x {
|
/// match x {
|
||||||
/// Some(ref foo) => bar(foo),
|
/// Some(ref foo) => bar(foo),
|
||||||
/// _ => (),
|
/// _ => (),
|
||||||
@ -59,7 +59,7 @@ declare_clippy_lint! {
|
|||||||
///
|
///
|
||||||
/// Using `if let` with `else`:
|
/// Using `if let` with `else`:
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// if let Some(ref foo) = x {
|
/// if let Some(ref foo) = x {
|
||||||
/// bar(foo);
|
/// bar(foo);
|
||||||
/// } else {
|
/// } else {
|
||||||
@ -82,7 +82,7 @@ declare_clippy_lint! {
|
|||||||
/// **Known problems:** None.
|
/// **Known problems:** None.
|
||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// match x {
|
/// match x {
|
||||||
/// &A(ref y) => foo(y),
|
/// &A(ref y) => foo(y),
|
||||||
/// &B => bar(),
|
/// &B => bar(),
|
||||||
@ -103,7 +103,7 @@ declare_clippy_lint! {
|
|||||||
/// **Known problems:** None.
|
/// **Known problems:** None.
|
||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// let condition: bool = true;
|
/// let condition: bool = true;
|
||||||
/// match condition {
|
/// match condition {
|
||||||
/// true => foo(),
|
/// true => foo(),
|
||||||
@ -111,7 +111,7 @@ declare_clippy_lint! {
|
|||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
/// Use if/else instead:
|
/// Use if/else instead:
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// let condition: bool = true;
|
/// let condition: bool = true;
|
||||||
/// if condition {
|
/// if condition {
|
||||||
/// foo();
|
/// foo();
|
||||||
@ -157,7 +157,7 @@ declare_clippy_lint! {
|
|||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// let x: Result(i32, &str) = Ok(3);
|
/// let x: Result<i32, &str> = Ok(3);
|
||||||
/// match x {
|
/// match x {
|
||||||
/// Ok(_) => println!("ok"),
|
/// Ok(_) => println!("ok"),
|
||||||
/// Err(_) => panic!("err"),
|
/// Err(_) => panic!("err"),
|
||||||
|
@ -17,6 +17,8 @@ declare_clippy_lint! {
|
|||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```rust
|
||||||
|
/// use std::mem;
|
||||||
|
///
|
||||||
/// mem::discriminant(&"hello");
|
/// mem::discriminant(&"hello");
|
||||||
/// mem::discriminant(&&Some(2));
|
/// mem::discriminant(&&Some(2));
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -17,6 +17,8 @@ declare_clippy_lint! {
|
|||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```rust
|
||||||
|
/// use std::mem;
|
||||||
|
///
|
||||||
/// let mut an_option = Some(0);
|
/// let mut an_option = Some(0);
|
||||||
/// let replaced = mem::replace(&mut an_option, None);
|
/// let replaced = mem::replace(&mut an_option, None);
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -84,7 +84,7 @@ declare_clippy_lint! {
|
|||||||
/// **Known problems:** None.
|
/// **Known problems:** None.
|
||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// struct X;
|
/// struct X;
|
||||||
/// impl X {
|
/// impl X {
|
||||||
/// fn add(&self, other: &X) -> X {
|
/// fn add(&self, other: &X) -> X {
|
||||||
@ -116,7 +116,7 @@ declare_clippy_lint! {
|
|||||||
/// **Known problems:** None.
|
/// **Known problems:** None.
|
||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// impl X {
|
/// impl X {
|
||||||
/// fn as_str(self) -> &str {
|
/// fn as_str(self) -> &str {
|
||||||
/// ..
|
/// ..
|
||||||
@ -160,7 +160,7 @@ declare_clippy_lint! {
|
|||||||
/// **Known problems:** The error type needs to implement `Debug`
|
/// **Known problems:** The error type needs to implement `Debug`
|
||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// x.ok().expect("why did I do this again?")
|
/// x.ok().expect("why did I do this again?")
|
||||||
/// ```
|
/// ```
|
||||||
pub OK_EXPECT,
|
pub OK_EXPECT,
|
||||||
@ -228,7 +228,7 @@ declare_clippy_lint! {
|
|||||||
/// **Known problems:** The order of the arguments is not in execution order.
|
/// **Known problems:** The order of the arguments is not in execution order.
|
||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// opt.map_or(None, |a| a + 1)
|
/// opt.map_or(None, |a| a + 1)
|
||||||
/// ```
|
/// ```
|
||||||
pub OPTION_MAP_OR_NONE,
|
pub OPTION_MAP_OR_NONE,
|
||||||
@ -445,7 +445,7 @@ declare_clippy_lint! {
|
|||||||
/// **Known problems:** None.
|
/// **Known problems:** None.
|
||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// impl Foo {
|
/// impl Foo {
|
||||||
/// fn new(..) -> NotAFoo {
|
/// fn new(..) -> NotAFoo {
|
||||||
/// }
|
/// }
|
||||||
@ -568,13 +568,13 @@ declare_clippy_lint! {
|
|||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```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();
|
/// let last = some_vec.get(3).unwrap();
|
||||||
/// *some_vec.get_mut(0).unwrap() = 1;
|
/// *some_vec.get_mut(0).unwrap() = 1;
|
||||||
/// ```
|
/// ```
|
||||||
/// The correct use would be:
|
/// The correct use would be:
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// let some_vec = vec![0, 1, 2, 3];
|
/// let mut some_vec = vec![0, 1, 2, 3];
|
||||||
/// let last = some_vec[3];
|
/// let last = some_vec[3];
|
||||||
/// some_vec[0] = 1;
|
/// some_vec[0] = 1;
|
||||||
/// ```
|
/// ```
|
||||||
@ -605,7 +605,7 @@ declare_clippy_lint! {
|
|||||||
/// let def = String::from("def");
|
/// let def = String::from("def");
|
||||||
/// let mut s = String::new();
|
/// let mut s = String::new();
|
||||||
/// s.push_str(abc);
|
/// s.push_str(abc);
|
||||||
/// s.push_str(&def));
|
/// s.push_str(&def);
|
||||||
/// ```
|
/// ```
|
||||||
pub STRING_EXTEND_CHARS,
|
pub STRING_EXTEND_CHARS,
|
||||||
style,
|
style,
|
||||||
@ -645,7 +645,7 @@ declare_clippy_lint! {
|
|||||||
/// **Known problems:** None.
|
/// **Known problems:** None.
|
||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// name.chars().last() == Some('_') || name.chars().next_back() == Some('-')
|
/// name.chars().last() == Some('_') || name.chars().next_back() == Some('-')
|
||||||
/// ```
|
/// ```
|
||||||
pub CHARS_LAST_CMP,
|
pub CHARS_LAST_CMP,
|
||||||
|
@ -15,7 +15,7 @@ declare_clippy_lint! {
|
|||||||
/// **Known problems:** None
|
/// **Known problems:** None
|
||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// min(0, max(100, x))
|
/// min(0, max(100, x))
|
||||||
/// ```
|
/// ```
|
||||||
/// It will always be equal to `0`. Probably the author meant to clamp the value
|
/// It will always be equal to `0`. Probably the author meant to clamp the value
|
||||||
|
@ -34,7 +34,7 @@ declare_clippy_lint! {
|
|||||||
/// dereferences, e.g. changing `*x` to `x` within the function.
|
/// dereferences, e.g. changing `*x` to `x` within the function.
|
||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// fn foo(ref x: u8) -> bool {
|
/// fn foo(ref x: u8) -> bool {
|
||||||
/// ..
|
/// ..
|
||||||
/// }
|
/// }
|
||||||
@ -53,7 +53,7 @@ declare_clippy_lint! {
|
|||||||
/// **Known problems:** None.
|
/// **Known problems:** None.
|
||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// x == NAN
|
/// x == NAN
|
||||||
/// ```
|
/// ```
|
||||||
pub CMP_NAN,
|
pub CMP_NAN,
|
||||||
@ -74,7 +74,7 @@ declare_clippy_lint! {
|
|||||||
/// **Known problems:** None.
|
/// **Known problems:** None.
|
||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// y == 1.23f64
|
/// y == 1.23f64
|
||||||
/// y != x // where both are floats
|
/// y != x // where both are floats
|
||||||
/// ```
|
/// ```
|
||||||
@ -113,7 +113,7 @@ declare_clippy_lint! {
|
|||||||
/// **Known problems:** None.
|
/// **Known problems:** None.
|
||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// x % 1
|
/// x % 1
|
||||||
/// ```
|
/// ```
|
||||||
pub MODULO_ONE,
|
pub MODULO_ONE,
|
||||||
@ -130,7 +130,7 @@ declare_clippy_lint! {
|
|||||||
/// **Known problems:** None.
|
/// **Known problems:** None.
|
||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// match v {
|
/// match v {
|
||||||
/// Some(x) => (),
|
/// Some(x) => (),
|
||||||
/// y @ _ => (), // easier written as `y`,
|
/// y @ _ => (), // easier written as `y`,
|
||||||
@ -193,7 +193,7 @@ declare_clippy_lint! {
|
|||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// 0 as *const u32
|
/// 0 as *const u32
|
||||||
/// ```
|
/// ```
|
||||||
pub ZERO_PTR,
|
pub ZERO_PTR,
|
||||||
|
@ -18,7 +18,7 @@ declare_clippy_lint! {
|
|||||||
/// **Known problems:** None.
|
/// **Known problems:** None.
|
||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// let { a: _, b: ref b, c: _ } = ..
|
/// let { a: _, b: ref b, c: _ } = ..
|
||||||
/// ```
|
/// ```
|
||||||
pub UNNEEDED_FIELD_PATTERN,
|
pub UNNEEDED_FIELD_PATTERN,
|
||||||
@ -71,6 +71,7 @@ declare_clippy_lint! {
|
|||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```rust
|
||||||
|
/// let mut x = 3;
|
||||||
/// --x;
|
/// --x;
|
||||||
/// ```
|
/// ```
|
||||||
pub DOUBLE_NEG,
|
pub DOUBLE_NEG,
|
||||||
@ -159,7 +160,7 @@ declare_clippy_lint! {
|
|||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// impl<u32> Foo<u32> {
|
/// impl<u32> Foo<u32> {
|
||||||
/// fn impl_func(&self) -> u32 {
|
/// fn impl_func(&self) -> u32 {
|
||||||
/// 42
|
/// 42
|
||||||
|
@ -15,7 +15,7 @@ declare_clippy_lint! {
|
|||||||
/// **Known problems:** None.
|
/// **Known problems:** None.
|
||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// my_vec.push(&mut value)
|
/// my_vec.push(&mut value)
|
||||||
/// ```
|
/// ```
|
||||||
pub UNNECESSARY_MUT_PASSED,
|
pub UNNECESSARY_MUT_PASSED,
|
||||||
|
@ -15,7 +15,7 @@ declare_clippy_lint! {
|
|||||||
/// **Known problems:** This only catches integers (for now).
|
/// **Known problems:** This only catches integers (for now).
|
||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// x * -1
|
/// x * -1
|
||||||
/// ```
|
/// ```
|
||||||
pub NEG_MULTIPLY,
|
pub NEG_MULTIPLY,
|
||||||
|
@ -29,7 +29,7 @@ declare_clippy_lint! {
|
|||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// struct Foo(Bar);
|
/// struct Foo(Bar);
|
||||||
///
|
///
|
||||||
/// impl Foo {
|
/// impl Foo {
|
||||||
@ -41,7 +41,7 @@ declare_clippy_lint! {
|
|||||||
///
|
///
|
||||||
/// Instead, use:
|
/// Instead, use:
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// struct Foo(Bar);
|
/// struct Foo(Bar);
|
||||||
///
|
///
|
||||||
/// impl Default for Foo {
|
/// impl Default for Foo {
|
||||||
|
@ -16,7 +16,7 @@ declare_clippy_lint! {
|
|||||||
/// **Known problems:** None?
|
/// **Known problems:** None?
|
||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// let checked_exp = something;
|
/// let checked_exp = something;
|
||||||
/// let checked_expr = something_else;
|
/// let checked_expr = something_else;
|
||||||
/// ```
|
/// ```
|
||||||
@ -35,7 +35,7 @@ declare_clippy_lint! {
|
|||||||
/// **Known problems:** None?
|
/// **Known problems:** None?
|
||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// let (a, b, c, d, e, f, g) = (...);
|
/// let (a, b, c, d, e, f, g) = (...);
|
||||||
/// ```
|
/// ```
|
||||||
pub MANY_SINGLE_CHAR_NAMES,
|
pub MANY_SINGLE_CHAR_NAMES,
|
||||||
|
@ -13,7 +13,7 @@ declare_clippy_lint! {
|
|||||||
/// **Known problems:** None.
|
/// **Known problems:** None.
|
||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// for result in iter {
|
/// for result in iter {
|
||||||
/// if let Some(bench) = try!(result).parse().ok() {
|
/// if let Some(bench) = try!(result).parse().ok() {
|
||||||
/// vec.push(bench)
|
/// vec.push(bench)
|
||||||
@ -22,7 +22,7 @@ declare_clippy_lint! {
|
|||||||
/// ```
|
/// ```
|
||||||
/// Could be written:
|
/// Could be written:
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// for result in iter {
|
/// for result in iter {
|
||||||
/// if let Ok(bench) = try!(result).parse() {
|
/// if let Ok(bench) = try!(result).parse() {
|
||||||
/// vec.push(bench)
|
/// vec.push(bench)
|
||||||
|
@ -16,7 +16,9 @@ declare_clippy_lint! {
|
|||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// OpenOptions::new().read(true).truncate(true)
|
/// use std::fs::OpenOptions;
|
||||||
|
///
|
||||||
|
/// OpenOptions::new().read(true).truncate(true);
|
||||||
/// ```
|
/// ```
|
||||||
pub NONSENSICAL_OPEN_OPTIONS,
|
pub NONSENSICAL_OPEN_OPTIONS,
|
||||||
correctness,
|
correctness,
|
||||||
|
@ -18,7 +18,7 @@ declare_clippy_lint! {
|
|||||||
/// **Known problems:** None.
|
/// **Known problems:** None.
|
||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```no_run
|
||||||
/// panic!("This `panic!` is probably missing a parameter there: {}");
|
/// panic!("This `panic!` is probably missing a parameter there: {}");
|
||||||
/// ```
|
/// ```
|
||||||
pub PANIC_PARAMS,
|
pub PANIC_PARAMS,
|
||||||
@ -34,7 +34,7 @@ declare_clippy_lint! {
|
|||||||
/// **Known problems:** None.
|
/// **Known problems:** None.
|
||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```no_run
|
||||||
/// unimplemented!();
|
/// unimplemented!();
|
||||||
/// ```
|
/// ```
|
||||||
pub UNIMPLEMENTED,
|
pub UNIMPLEMENTED,
|
||||||
|
@ -41,7 +41,7 @@ declare_clippy_lint! {
|
|||||||
/// function before applying the lint suggestions in this case.
|
/// function before applying the lint suggestions in this case.
|
||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// fn foo(&Vec<u32>) { .. }
|
/// fn foo(&Vec<u32>) { .. }
|
||||||
/// ```
|
/// ```
|
||||||
pub PTR_ARG,
|
pub PTR_ARG,
|
||||||
@ -59,7 +59,7 @@ declare_clippy_lint! {
|
|||||||
/// **Known problems:** None.
|
/// **Known problems:** None.
|
||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// if x == ptr::null {
|
/// if x == ptr::null {
|
||||||
/// ..
|
/// ..
|
||||||
/// }
|
/// }
|
||||||
@ -86,7 +86,7 @@ declare_clippy_lint! {
|
|||||||
/// case is unlikely anyway.
|
/// case is unlikely anyway.
|
||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// fn foo(&Foo) -> &mut Bar { .. }
|
/// fn foo(&Foo) -> &mut Bar { .. }
|
||||||
/// ```
|
/// ```
|
||||||
pub MUT_FROM_REF,
|
pub MUT_FROM_REF,
|
||||||
|
@ -18,7 +18,7 @@ declare_clippy_lint! {
|
|||||||
/// **Known problems:** None
|
/// **Known problems:** None
|
||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// if option.is_none() {
|
/// if option.is_none() {
|
||||||
/// return None;
|
/// return None;
|
||||||
/// }
|
/// }
|
||||||
@ -26,7 +26,7 @@ declare_clippy_lint! {
|
|||||||
///
|
///
|
||||||
/// Could be written:
|
/// Could be written:
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// option?;
|
/// option?;
|
||||||
/// ```
|
/// ```
|
||||||
pub QUESTION_MARK,
|
pub QUESTION_MARK,
|
||||||
|
@ -19,7 +19,7 @@ declare_clippy_lint! {
|
|||||||
/// **Known problems:** None.
|
/// **Known problems:** None.
|
||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// for x in (5..5).step_by(0) {
|
/// for x in (5..5).step_by(0) {
|
||||||
/// ..
|
/// ..
|
||||||
/// }
|
/// }
|
||||||
|
@ -21,11 +21,11 @@ declare_clippy_lint! {
|
|||||||
/// bar: u8,
|
/// bar: u8,
|
||||||
/// }
|
/// }
|
||||||
///
|
///
|
||||||
/// let foo = Foo{ bar: bar }
|
/// let foo = Foo { bar: bar };
|
||||||
/// ```
|
/// ```
|
||||||
/// the last line can be simplified to
|
/// the last line can be simplified to
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// let foo = Foo{ bar }
|
/// let foo = Foo { bar };
|
||||||
/// ```
|
/// ```
|
||||||
pub REDUNDANT_FIELD_NAMES,
|
pub REDUNDANT_FIELD_NAMES,
|
||||||
style,
|
style,
|
||||||
|
@ -20,7 +20,7 @@ declare_clippy_lint! {
|
|||||||
/// **Known problems:** None.
|
/// **Known problems:** None.
|
||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// Regex::new("|")
|
/// Regex::new("|")
|
||||||
/// ```
|
/// ```
|
||||||
pub INVALID_REGEX,
|
pub INVALID_REGEX,
|
||||||
@ -39,7 +39,7 @@ declare_clippy_lint! {
|
|||||||
/// **Known problems:** None.
|
/// **Known problems:** None.
|
||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// Regex::new("^foobar")
|
/// Regex::new("^foobar")
|
||||||
/// ```
|
/// ```
|
||||||
pub TRIVIAL_REGEX,
|
pub TRIVIAL_REGEX,
|
||||||
@ -58,7 +58,7 @@ declare_clippy_lint! {
|
|||||||
/// **Known problems:** None.
|
/// **Known problems:** None.
|
||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// regex!("foo|bar")
|
/// regex!("foo|bar")
|
||||||
/// ```
|
/// ```
|
||||||
pub REGEX_MACRO,
|
pub REGEX_MACRO,
|
||||||
|
@ -19,13 +19,13 @@ declare_clippy_lint! {
|
|||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// fn foo(x: usize) {
|
/// fn foo(x: usize) -> usize {
|
||||||
/// return x;
|
/// return x;
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
/// simplify to
|
/// simplify to
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// fn foo(x: usize) {
|
/// fn foo(x: usize) -> usize {
|
||||||
/// x
|
/// x
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -14,7 +14,7 @@ declare_clippy_lint! {
|
|||||||
/// **Known problems:** None.
|
/// **Known problems:** None.
|
||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// impl Add for Foo {
|
/// impl Add for Foo {
|
||||||
/// type Output = Foo;
|
/// type Output = Foo;
|
||||||
///
|
///
|
||||||
@ -37,7 +37,7 @@ declare_clippy_lint! {
|
|||||||
/// **Known problems:** None.
|
/// **Known problems:** None.
|
||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// impl AddAssign for Foo {
|
/// impl AddAssign for Foo {
|
||||||
/// fn add_assign(&mut self, other: Foo) {
|
/// fn add_assign(&mut self, other: Foo) {
|
||||||
/// *self = *self - other;
|
/// *self = *self - other;
|
||||||
|
@ -19,7 +19,7 @@ declare_clippy_lint! {
|
|||||||
/// sized objects in `extradata` arguments to save an allocation.
|
/// sized objects in `extradata` arguments to save an allocation.
|
||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// let ptr: *const T = core::intrinsics::transmute('x')
|
/// let ptr: *const T = core::intrinsics::transmute('x')
|
||||||
/// ```
|
/// ```
|
||||||
pub WRONG_TRANSMUTE,
|
pub WRONG_TRANSMUTE,
|
||||||
|
@ -509,7 +509,7 @@ declare_clippy_lint! {
|
|||||||
/// **Known problems:** None.
|
/// **Known problems:** None.
|
||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// if {
|
/// if {
|
||||||
/// foo();
|
/// foo();
|
||||||
/// } == {
|
/// } == {
|
||||||
@ -519,7 +519,7 @@ declare_clippy_lint! {
|
|||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
/// is equal to
|
/// is equal to
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// {
|
/// {
|
||||||
/// foo();
|
/// foo();
|
||||||
/// bar();
|
/// bar();
|
||||||
@ -848,7 +848,7 @@ declare_clippy_lint! {
|
|||||||
///
|
///
|
||||||
/// **Example**
|
/// **Example**
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// // Bad
|
/// // Bad
|
||||||
/// fn fun() -> i32 {}
|
/// fn fun() -> i32 {}
|
||||||
/// let a = fun as i64;
|
/// let a = fun as i64;
|
||||||
@ -1536,7 +1536,7 @@ declare_clippy_lint! {
|
|||||||
/// like `#[cfg(target_pointer_width = "64")] ..` instead.
|
/// like `#[cfg(target_pointer_width = "64")] ..` instead.
|
||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// vec.len() <= 0
|
/// vec.len() <= 0
|
||||||
/// 100 > std::i32::MAX
|
/// 100 > std::i32::MAX
|
||||||
/// ```
|
/// ```
|
||||||
@ -1961,7 +1961,7 @@ declare_clippy_lint! {
|
|||||||
/// pieces of code, possibly including external crates.
|
/// pieces of code, possibly including external crates.
|
||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// impl<K: Hash + Eq, V> Serialize for HashMap<K, V> { ... }
|
/// impl<K: Hash + Eq, V> Serialize for HashMap<K, V> { ... }
|
||||||
///
|
///
|
||||||
/// pub foo(map: &mut HashMap<i32, i32>) { .. }
|
/// pub foo(map: &mut HashMap<i32, i32>) { .. }
|
||||||
@ -2302,7 +2302,7 @@ declare_clippy_lint! {
|
|||||||
/// **Known problems:** None.
|
/// **Known problems:** None.
|
||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// fn x(r: &i32) {
|
/// fn x(r: &i32) {
|
||||||
/// unsafe {
|
/// unsafe {
|
||||||
/// *(r as *const _ as *mut _) += 1;
|
/// *(r as *const _ as *mut _) += 1;
|
||||||
@ -2312,7 +2312,7 @@ declare_clippy_lint! {
|
|||||||
///
|
///
|
||||||
/// Instead consider using interior mutability types.
|
/// Instead consider using interior mutability types.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// fn x(r: &UnsafeCell<i32>) {
|
/// fn x(r: &UnsafeCell<i32>) {
|
||||||
/// unsafe {
|
/// unsafe {
|
||||||
/// *r.get() += 1;
|
/// *r.get() += 1;
|
||||||
|
@ -35,11 +35,11 @@ declare_clippy_lint! {
|
|||||||
/// **Known problems:** None.
|
/// **Known problems:** None.
|
||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// print!("Hello {}!\n", name);
|
/// print!("Hello {}!\n", name);
|
||||||
/// ```
|
/// ```
|
||||||
/// use println!() instead
|
/// use println!() instead
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// println!("Hello {}!", name);
|
/// println!("Hello {}!", name);
|
||||||
/// ```
|
/// ```
|
||||||
pub PRINT_WITH_NEWLINE,
|
pub PRINT_WITH_NEWLINE,
|
||||||
@ -113,12 +113,12 @@ declare_clippy_lint! {
|
|||||||
/// **Known problems:** None.
|
/// **Known problems:** None.
|
||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// writeln!("");
|
/// writeln!(buf, "");
|
||||||
/// ```
|
/// ```
|
||||||
pub WRITELN_EMPTY_STRING,
|
pub WRITELN_EMPTY_STRING,
|
||||||
style,
|
style,
|
||||||
"using `writeln!(\"\")` with an empty string"
|
"using `writeln!(buf, \"\")` with an empty string"
|
||||||
}
|
}
|
||||||
|
|
||||||
declare_clippy_lint! {
|
declare_clippy_lint! {
|
||||||
@ -132,7 +132,7 @@ declare_clippy_lint! {
|
|||||||
/// **Known problems:** None.
|
/// **Known problems:** None.
|
||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// write!(buf, "Hello {}!\n", name);
|
/// write!(buf, "Hello {}!\n", name);
|
||||||
/// ```
|
/// ```
|
||||||
pub WRITE_WITH_NEWLINE,
|
pub WRITE_WITH_NEWLINE,
|
||||||
@ -151,7 +151,7 @@ declare_clippy_lint! {
|
|||||||
/// -- e.g., `writeln!(buf, "{}", env!("FOO"))`.
|
/// -- e.g., `writeln!(buf, "{}", env!("FOO"))`.
|
||||||
///
|
///
|
||||||
/// **Example:**
|
/// **Example:**
|
||||||
/// ```rust
|
/// ```ignore
|
||||||
/// writeln!(buf, "{}", "foo");
|
/// writeln!(buf, "{}", "foo");
|
||||||
/// ```
|
/// ```
|
||||||
pub WRITE_LITERAL,
|
pub WRITE_LITERAL,
|
||||||
|
Loading…
Reference in New Issue
Block a user