Merge pull request #2579 from rust-lang-nursery/lint_audit_mcve

lint audit: Implementation + move one lint
This commit is contained in:
Oliver Schneider 2018-03-29 14:34:21 +02:00 committed by GitHub
commit a47734c41d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
127 changed files with 941 additions and 669 deletions

View File

@ -7,7 +7,16 @@
A collection of lints to catch common mistakes and improve your [Rust](https://github.com/rust-lang/rust) code.
[There are 208 lints included in this crate!](https://rust-lang-nursery.github.io/rust-clippy/master/index.html)
[There are 248 lints included in this crate!](https://rust-lang-nursery.github.io/rust-clippy/master/index.html)
We have a bunch of lint categories to allow you to choose how much clippy is supposed to ~~annoy~~ help you:
* `clippy` (everything that has no false positives)
* `clippy_pedantic` (everything)
* `clippy_style` (code that should be written in a more idiomatic way)
* `complexity` (code that does something simple but in a complex way)
* `perf` (code that can be written in a faster way)
* **`correctness`** (code that is just outright wrong or very very useless)
More to come, please [file an issue](https://github.com/rust-lang-nursery/rust-clippy/issues) if you have ideas!

View File

@ -26,9 +26,9 @@ use utils::span_lint;
/// ```rust
/// let x = 3.14;
/// ```
declare_lint! {
declare_clippy_lint! {
pub APPROX_CONSTANT,
Warn,
correctness,
"the approximate of a known float constant (in `std::fXX::consts`)"
}

View File

@ -15,8 +15,9 @@ use utils::span_lint;
/// ```rust
/// a + 1
/// ```
declare_restriction_lint! {
declare_clippy_lint! {
pub INTEGER_ARITHMETIC,
restriction,
"any integer arithmetic statement"
}
@ -31,8 +32,9 @@ declare_restriction_lint! {
/// ```rust
/// a + 1.0
/// ```
declare_restriction_lint! {
declare_clippy_lint! {
pub FLOAT_ARITHMETIC,
restriction,
"any floating-point arithmetic statement"
}

View File

@ -19,9 +19,9 @@ use consts::{constant, Constant};
/// x[9];
/// &x[2..9];
/// ```
declare_lint! {
declare_clippy_lint! {
pub OUT_OF_BOUNDS_INDEXING,
Deny,
correctness,
"out of bounds constant indexing"
}
@ -39,8 +39,9 @@ declare_lint! {
/// x[2];
/// &x[0..2];
/// ```
declare_restriction_lint! {
declare_clippy_lint! {
pub INDEXING_SLICING,
restriction,
"indexing/slicing usage"
}

View File

@ -18,8 +18,9 @@ use utils::{higher, sugg};
/// ```rust
/// a += 1;
/// ```
declare_restriction_lint! {
declare_clippy_lint! {
pub ASSIGN_OPS,
restriction,
"any compound assignment operation"
}
@ -37,9 +38,9 @@ declare_restriction_lint! {
/// ...
/// a = a + b;
/// ```
declare_lint! {
declare_clippy_lint! {
pub ASSIGN_OP_PATTERN,
Warn,
style,
"assigning the result of an operation on a variable to that same variable"
}
@ -57,9 +58,9 @@ declare_lint! {
/// ...
/// a += a + b;
/// ```
declare_lint! {
declare_clippy_lint! {
pub MISREFACTORED_ASSIGN_OP,
Warn,
complexity,
"having a variable on both sides of an assign op"
}

View File

@ -29,9 +29,9 @@ use utils::{in_macro, last_line_of_span, match_def_path, opt_def_id, paths, snip
/// #[inline(always)]
/// fn not_quite_hot_code(..) { ... }
/// ```
declare_lint! {
declare_clippy_lint! {
pub INLINE_ALWAYS,
Warn,
pedantic,
"use of `#[inline(always)]`"
}
@ -53,9 +53,9 @@ declare_lint! {
/// #[allow(unused_import)]
/// use foo::bar;
/// ```
declare_lint! {
declare_clippy_lint! {
pub USELESS_ATTRIBUTE,
Warn,
correctness,
"use of lint attributes on `extern crate` items"
}
@ -72,9 +72,9 @@ declare_lint! {
/// #[deprecated(since = "forever")]
/// fn something_else(..) { ... }
/// ```
declare_lint! {
declare_clippy_lint! {
pub DEPRECATED_SEMVER,
Warn,
correctness,
"use of `#[deprecated(since = \"x\")]` where x is not semver"
}
@ -103,9 +103,9 @@ declare_lint! {
/// #[inline(always)]
/// fn this_is_fine_too(..) { ... }
/// ```
declare_lint! {
declare_clippy_lint! {
pub EMPTY_LINE_AFTER_OUTER_ATTR,
Warn,
style,
"empty line after outer attribute"
}

View File

@ -36,9 +36,9 @@ use consts::{constant, Constant};
/// ```rust
/// if (x & 1 == 2) { … }
/// ```
declare_lint! {
declare_clippy_lint! {
pub BAD_BIT_MASK,
Warn,
correctness,
"expressions of the form `_ & mask == select` that will only ever return `true` or `false`"
}
@ -64,9 +64,9 @@ declare_lint! {
/// ```rust
/// if (x | 1 > 3) { … }
/// ```
declare_lint! {
declare_clippy_lint! {
pub INEFFECTIVE_BIT_MASK,
Warn,
correctness,
"expressions where a bit mask will be rendered useless by a comparison, e.g. `(x | 1) > 2`"
}
@ -82,9 +82,9 @@ declare_lint! {
/// ```rust
/// x & 0x1111 == 0
/// ```
declare_lint! {
declare_clippy_lint! {
pub VERBOSE_BIT_MASK,
Warn,
style,
"expressions where a bit mask is less readable than the corresponding method call"
}

View File

@ -14,9 +14,9 @@ use utils::span_lint;
/// ```rust
/// let foo = 3.14;
/// ```
declare_lint! {
declare_clippy_lint! {
pub BLACKLISTED_NAME,
Warn,
style,
"usage of a blacklisted/placeholder name"
}

View File

@ -15,9 +15,9 @@ use utils::*;
/// ```rust
/// if { true } ..
/// ```
declare_lint! {
declare_clippy_lint! {
pub BLOCK_IN_IF_CONDITION_EXPR,
Warn,
style,
"braces that can be eliminated in conditions, e.g. `if { true } ...`"
}
@ -34,9 +34,9 @@ declare_lint! {
/// // or
/// if somefunc(|x| { x == 47 }) ..
/// ```
declare_lint! {
declare_clippy_lint! {
pub BLOCK_IN_IF_CONDITION_STMT,
Warn,
style,
"complex blocks in conditions, e.g. `if { let x = true; x } ...`"
}

View File

@ -20,9 +20,9 @@ use utils::{in_macro, snippet_opt, span_lint_and_then, SpanlessEq};
/// if a && true // should be: if a
/// if !(a == b) // should be: if a != b
/// ```
declare_lint! {
declare_clippy_lint! {
pub NONMINIMAL_BOOL,
Allow,
complexity,
"boolean expressions that can be written more concisely"
}
@ -38,9 +38,9 @@ declare_lint! {
/// if a && b || a { ... }
/// ```
/// The `b` is unnecessary, the expression is equivalent to `if a`.
declare_lint! {
declare_clippy_lint! {
pub LOGIC_BUG,
Warn,
correctness,
"boolean expressions that contain terminals which can be eliminated"
}

View File

@ -20,9 +20,9 @@ use utils::{contains_name, get_pat_name, match_type, paths, single_segment_path,
/// ```rust
/// &my_data.filter(|&x| x == 0u8).count() // use bytecount::count instead
/// ```
declare_lint! {
declare_clippy_lint! {
pub NAIVE_BYTECOUNT,
Warn,
perf,
"use of naive `<slice>.filter(|&x| x == y).count()` to count byte values"
}

View File

@ -62,9 +62,9 @@ use utils::sugg::Sugg;
/// …
/// }
/// ```
declare_lint! {
declare_clippy_lint! {
pub COLLAPSIBLE_IF,
Warn,
style,
"`if`s that can be collapsed (e.g. `if x { if y { ... } }` and `else { if x { ... } }`)"
}

View File

@ -18,9 +18,9 @@ use utils::{in_macro, snippet, span_lint_and_then};
/// ```rust
/// const FOO: &[(&str, &str, fn(&Bar) -> bool)] = &[...]
/// ```
declare_lint! {
declare_clippy_lint! {
pub CONST_STATIC_LIFETIME,
Warn,
style,
"Using explicit `'static` lifetime for constants when elision rules would allow omitting them."
}

View File

@ -33,9 +33,9 @@ use utils::{get_parent_expr, in_macro, snippet, span_lint_and_then, span_note_an
/// …
/// }
/// ```
declare_lint! {
declare_clippy_lint! {
pub IFS_SAME_COND,
Warn,
correctness,
"consecutive `ifs` with the same condition"
}
@ -54,9 +54,9 @@ declare_lint! {
/// 42
/// };
/// ```
declare_lint! {
declare_clippy_lint! {
pub IF_SAME_THEN_ELSE,
Warn,
correctness,
"if with the same *then* and *else* blocks"
}
@ -95,9 +95,9 @@ declare_lint! {
/// Quz => quz(),
/// }
/// ```
declare_lint! {
declare_clippy_lint! {
pub MATCH_SAME_ARMS,
Warn,
pedantic,
"`match` with identical arm bodies"
}

View File

@ -19,9 +19,9 @@ use utils::{in_macro, is_allowed, match_type, paths, span_help_and_lint, LimitSt
/// complexity.
///
/// **Example:** No. You'll see it when you get the warning.
declare_lint! {
declare_clippy_lint! {
pub CYCLOMATIC_COMPLEXITY,
Warn,
complexity,
"functions that should be split up into multiple functions"
}

View File

@ -28,9 +28,9 @@ use utils::{is_automatically_derived, is_copy, match_path, span_lint_and_then};
/// ...
/// }
/// ```
declare_lint! {
declare_clippy_lint! {
pub DERIVE_HASH_XOR_EQ,
Warn,
correctness,
"deriving `Hash` but implementing `PartialEq` explicitly"
}
@ -43,7 +43,7 @@ declare_lint! {
/// nothing more than copy the object, which is what `#[derive(Copy, Clone)]`
/// gets you.
///
/// **Known problems:** None.
/// **Known problems:** Bounds of generic types are sometimes wrong: https://github.com/rust-lang/rust/issues/26925
///
/// **Example:**
/// ```rust
@ -54,9 +54,9 @@ declare_lint! {
/// ..
/// }
/// ```
declare_lint! {
declare_clippy_lint! {
pub EXPL_IMPL_CLONE_ON_COPY,
Warn,
pedantic,
"implementing `Clone` explicitly on `Copy` types"
}

View File

@ -25,9 +25,9 @@ use url::Url;
/// // ^ `foo_bar` and `that::other::module::foo` should be ticked.
/// fn doit(foo_bar) { .. }
/// ```
declare_lint! {
declare_clippy_lint! {
pub DOC_MARKDOWN,
Warn,
pedantic,
"presence of `_`, `::` or camel-case outside backticks in documentation"
}

View File

@ -23,9 +23,9 @@ use utils::{snippet, span_lint_and_sugg, SpanlessEq};
/// ```rust
/// x <= y
/// ```
declare_lint! {
declare_clippy_lint! {
pub DOUBLE_COMPARISONS,
Deny,
complexity,
"unnecessary double comparisons that can be simplified"
}

View File

@ -14,8 +14,9 @@ use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintContext, LintPass}
/// foo((0))
/// ((1, 2))
/// ```
declare_lint! {
pub DOUBLE_PARENS, Warn,
declare_clippy_lint! {
pub DOUBLE_PARENS,
complexity,
"Warn on unnecessary double parentheses"
}

View File

@ -20,9 +20,9 @@ use utils::{is_copy, match_def_path, opt_def_id, paths, span_note_and_lint};
/// still locked
/// operation_that_requires_mutex_to_be_unlocked();
/// ```
declare_lint! {
declare_clippy_lint! {
pub DROP_REF,
Warn,
correctness,
"calls to `std::mem::drop` with a reference instead of an owned value"
}
@ -41,9 +41,9 @@ declare_lint! {
/// let x = Box::new(1);
/// std::mem::forget(&x) // Should have been forget(x), x will still be dropped
/// ```
declare_lint! {
declare_clippy_lint! {
pub FORGET_REF,
Warn,
correctness,
"calls to `std::mem::forget` with a reference instead of an owned value"
}
@ -62,9 +62,9 @@ declare_lint! {
/// std::mem::drop(x) // A copy of x is passed to the function, leaving the
/// original unaffected
/// ```
declare_lint! {
declare_clippy_lint! {
pub DROP_COPY,
Warn,
correctness,
"calls to `std::mem::drop` with a value that implements Copy"
}
@ -89,9 +89,9 @@ declare_lint! {
/// std::mem::forget(x) // A copy of x is passed to the function, leaving the
/// original unaffected
/// ```
declare_lint! {
declare_clippy_lint! {
pub FORGET_COPY,
Warn,
correctness,
"calls to `std::mem::forget` with a value that implements Copy"
}

View File

@ -32,8 +32,9 @@ use utils::{in_external_macro, span_lint_and_sugg};
/// // we don't care about zero
/// }
/// ```
declare_restriction_lint! {
declare_clippy_lint! {
pub ELSE_IF_WITHOUT_ELSE,
restriction,
"if expression with an `else if`, but without a final `else` branch"
}

View File

@ -16,9 +16,9 @@ use utils::span_lint_and_then;
/// ```rust
/// enum Test {}
/// ```
declare_lint! {
declare_clippy_lint! {
pub EMPTY_ENUM,
Allow,
pedantic,
"enum with no variants"
}

View File

@ -24,9 +24,9 @@ use utils::{get_item_name, match_type, paths, snippet, span_lint_and_then, walk_
/// ```rust
/// m.entry(k).or_insert(v);
/// ```
declare_lint! {
declare_clippy_lint! {
pub MAP_ENTRY,
Warn,
perf,
"use of `contains_key` followed by `insert` on a `HashMap` or `BTreeMap`"
}

View File

@ -27,9 +27,9 @@ use rustc::mir::interpret::GlobalId;
/// Y = 0
/// }
/// ```
declare_lint! {
declare_clippy_lint! {
pub ENUM_CLIKE_UNPORTABLE_VARIANT,
Warn,
correctness,
"C-like enums that are `repr(isize/usize)` and have values that don't fit into an `i32`"
}

View File

@ -19,9 +19,9 @@ use utils::span_lint;
/// ```rust
/// use std::cmp::Ordering::*;
/// ```
declare_lint! {
declare_clippy_lint! {
pub ENUM_GLOB_USE,
Allow,
pedantic,
"use items that import all variants of an enum"
}

View File

@ -22,9 +22,9 @@ use utils::{camel_case_from, camel_case_until, in_macro};
/// HummingbirdCake,
/// }
/// ```
declare_lint! {
declare_clippy_lint! {
pub ENUM_VARIANT_NAMES,
Warn,
style,
"enums where all variants share a prefix/postfix"
}
@ -43,9 +43,9 @@ declare_lint! {
/// HummingbirdCake,
/// }
/// ```
declare_lint! {
declare_clippy_lint! {
pub PUB_ENUM_VARIANT_NAMES,
Allow,
pedantic,
"enums where all variants share a prefix/postfix"
}
@ -62,9 +62,9 @@ declare_lint! {
/// struct BlackForestCake;
/// }
/// ```
declare_lint! {
declare_clippy_lint! {
pub STUTTER,
Allow,
pedantic,
"type names prefixed/postfixed with their containing module's name"
}
@ -92,9 +92,9 @@ declare_lint! {
/// ...
/// }
/// ```
declare_lint! {
declare_clippy_lint! {
pub MODULE_INCEPTION,
Warn,
style,
"modules that have the same name as their parent module"
}

View File

@ -17,9 +17,9 @@ use utils::{in_macro, implements_trait, is_copy, multispan_sugg, snippet, span_l
/// ```rust
/// x + 1 == x + 1
/// ```
declare_lint! {
declare_clippy_lint! {
pub EQ_OP,
Warn,
correctness,
"equal operands on both sides of a comparison or bitwise combination (e.g. `x == x`)"
}
@ -35,9 +35,9 @@ declare_lint! {
/// ```rust
/// &x == y
/// ```
declare_lint! {
declare_clippy_lint! {
pub OP_REF,
Warn,
style,
"taking a reference to satisfy the type constraints on `==`"
}

View File

@ -16,9 +16,9 @@ use utils::{in_macro, span_lint};
/// ```rust
/// 0 / x; 0 * x; x & 0
/// ```
declare_lint! {
declare_clippy_lint! {
pub ERASING_OP,
Warn,
correctness,
"using erasing operations, e.g. `x * 0` or `y & 0`"
}

View File

@ -32,9 +32,9 @@ pub struct Pass {
/// println!("{}", *x);
/// }
/// ```
declare_lint! {
declare_clippy_lint! {
pub BOXED_LOCAL,
Warn,
perf,
"using `Box<T>` where unnecessary"
}

View File

@ -22,9 +22,9 @@ pub struct EtaPass;
/// ```
/// where `foo(_)` is a plain function that takes the exact argument type of
/// `x`.
declare_lint! {
declare_clippy_lint! {
pub REDUNDANT_CLOSURE,
Warn,
style,
"redundant closures, i.e. `|a| foo(a)` (which can be written as just `foo`)"
}

View File

@ -21,9 +21,9 @@ use utils::{get_parent_expr, span_lint, span_note_and_lint};
/// let a = {x = 1; 1} + x;
/// // Unclear whether a is 1 or 2.
/// ```
declare_lint! {
declare_clippy_lint! {
pub EVAL_ORDER_DEPENDENCE,
Warn,
complexity,
"whether a variable read occurs before a write depends on sub-expression evaluation order"
}
@ -43,9 +43,9 @@ declare_lint! {
/// let x = (a, b, c, panic!());
/// // can simply be replaced by `panic!()`
/// ```
declare_lint! {
declare_clippy_lint! {
pub DIVERGING_SUB_EXPRESSION,
Warn,
complexity,
"whether an expression contains a diverging sub expression"
}

View File

@ -15,9 +15,9 @@ use utils::opt_def_id;
/// // this would be clearer as `eprintln!("foo: {:?}", bar);`
/// writeln!(&mut io::stderr(), "foo: {:?}", bar).unwrap();
/// ```
declare_lint! {
declare_clippy_lint! {
pub EXPLICIT_WRITE,
Warn,
complexity,
"using the `write!()` family of functions instead of the `print!()` family \
of functions, when using the latter would work"
}

View File

@ -20,8 +20,9 @@ use utils::paths::{BEGIN_PANIC, BEGIN_PANIC_FMT, FROM_TRAIT, OPTION, RESULT};
/// }
/// }
/// ```
declare_lint! {
pub FALLIBLE_IMPL_FROM, Allow,
declare_clippy_lint! {
pub FALLIBLE_IMPL_FROM,
nursery,
"Warn on impls of `From<..>` that contain `panic!()` or `unwrap()`"
}

View File

@ -21,9 +21,9 @@ use utils::{is_expn_of, match_def_path, match_type, opt_def_id, resolve_node, sn
/// format!("foo")
/// format!("{}", foo)
/// ```
declare_lint! {
declare_clippy_lint! {
pub USELESS_FORMAT,
Warn,
complexity,
"useless use of `format!`"
}

View File

@ -15,9 +15,9 @@ use syntax::ptr::P;
/// ```rust,ignore
/// a =- 42; // confusing, should it be `a -= 42` or `a = -42`?
/// ```
declare_lint! {
declare_clippy_lint! {
pub SUSPICIOUS_ASSIGNMENT_FORMATTING,
Warn,
style,
"suspicious formatting of `*=`, `-=` or `!=`"
}
@ -41,9 +41,9 @@ declare_lint! {
/// if bar { // this is the `else` block of the previous `if`, but should it be?
/// }
/// ```
declare_lint! {
declare_clippy_lint! {
pub SUSPICIOUS_ELSE_FORMATTING,
Warn,
style,
"suspicious formatting of `else if`"
}
@ -61,9 +61,9 @@ declare_lint! {
/// -4, -5, -6
/// ];
/// ```
declare_lint! {
declare_clippy_lint! {
pub POSSIBLE_MISSING_COMMA,
Warn,
correctness,
"possible missing comma in array"
}

View File

@ -22,9 +22,9 @@ use utils::{iter_input_pats, span_lint, type_is_unsafe_function};
/// fn foo(x: u32, y: u32, name: &str, c: Color, w: f32, h: f32, a: f32, b:
/// f32) { .. }
/// ```
declare_lint! {
declare_clippy_lint! {
pub TOO_MANY_ARGUMENTS,
Warn,
complexity,
"functions with too many arguments"
}
@ -48,9 +48,9 @@ declare_lint! {
/// ```rust
/// pub fn foo(x: *const u8) { println!("{}", unsafe { *x }); }
/// ```
declare_lint! {
declare_clippy_lint! {
pub NOT_UNSAFE_PTR_ARG_DEREF,
Warn,
correctness,
"public functions dereferencing raw pointer arguments but not marked `unsafe`"
}

View File

@ -15,9 +15,9 @@ use utils::{opt_def_id, paths, resolve_node};
/// // format!() returns a `String`
/// let s: String = format!("hello").into();
/// ```
declare_lint! {
declare_clippy_lint! {
pub IDENTITY_CONVERSION,
Warn,
complexity,
"using always-identical `Into`/`From` conversions"
}

View File

@ -16,9 +16,9 @@ use rustc::ty;
/// ```rust
/// x / 1 + 0 * 1 - 0 | 0
/// ```
declare_lint! {
declare_clippy_lint! {
pub IDENTITY_OP,
Warn,
complexity,
"using identity operations, e.g. `x + 0` or `y / 1`"
}

View File

@ -28,9 +28,9 @@ use utils::{match_qpath, paths, snippet, span_lint_and_then};
/// if Some(42).is_some() {}
/// ```
///
declare_lint! {
declare_clippy_lint! {
pub IF_LET_REDUNDANT_PATTERN_MATCHING,
Warn,
style,
"use the proper utility function avoiding an `if let`"
}

View File

@ -31,9 +31,9 @@ use utils::{in_external_macro, span_help_and_lint};
/// a()
/// }
/// ```
declare_lint! {
declare_clippy_lint! {
pub IF_NOT_ELSE,
Allow,
pedantic,
"`if` branches that could be swapped so no negation operation is necessary on the condition"
}

View File

@ -13,9 +13,9 @@ use utils::{get_trait_def_id, higher, implements_trait, match_qpath, paths, span
/// ```rust
/// repeat(1_u8).iter().collect::<Vec<_>>()
/// ```
declare_lint! {
declare_clippy_lint! {
pub INFINITE_ITER,
Warn,
correctness,
"infinite iteration"
}
@ -31,9 +31,9 @@ declare_lint! {
/// ```rust
/// [0..].iter().zip(infinite_iter.take_while(|x| x > 5))
/// ```
declare_lint! {
declare_clippy_lint! {
pub MAYBE_INFINITE_ITER,
Allow,
pedantic,
"possible infinite iteration"
}

View File

@ -20,9 +20,9 @@ use utils::sugg::DiagnosticBuilderExt;
/// fn name(&self) -> &'static str;
/// }
/// ```
declare_lint! {
declare_clippy_lint! {
pub INLINE_FN_WITHOUT_BODY,
Warn,
correctness,
"use of `#[inline]` on trait methods without bodies"
}

View File

@ -22,9 +22,9 @@ use utils::{snippet_opt, span_lint_and_then};
/// ```rust
/// x > y
/// ```
declare_lint! {
declare_clippy_lint! {
pub INT_PLUS_ONE,
Allow,
complexity,
"instead of using x >= y + 1, use x > y"
}

View File

@ -13,9 +13,9 @@ use utils::{match_def_path, opt_def_id, paths, span_help_and_lint};
/// ```rust
/// let bad_ref: &usize = std::mem::zeroed();
/// ```
declare_lint! {
declare_clippy_lint! {
pub INVALID_REF,
Warn,
correctness,
"creation of invalid reference"
}

View File

@ -26,9 +26,9 @@ use utils::{in_macro, span_lint};
/// foo(); // prints "foo"
/// }
/// ```
declare_lint! {
declare_clippy_lint! {
pub ITEMS_AFTER_STATEMENTS,
Allow,
pedantic,
"blocks where an item comes after a statement"
}

View File

@ -21,9 +21,9 @@ use rustc::ty::layout::LayoutOf;
/// B([i32; 8000]),
/// }
/// ```
declare_lint! {
declare_clippy_lint! {
pub LARGE_ENUM_VARIANT,
Warn,
perf,
"large size difference between variants on an enum"
}

View File

@ -22,9 +22,9 @@ use utils::{get_item_name, in_macro, snippet, span_lint, span_lint_and_sugg, wal
/// ```rust
/// if x.len() == 0 { .. }
/// ```
declare_lint! {
declare_clippy_lint! {
pub LEN_ZERO,
Warn,
style,
"checking `.len() == 0` or `.len() > 0` (or similar) when `.is_empty()` \
could be used instead"
}
@ -46,9 +46,9 @@ declare_lint! {
/// pub fn len(&self) -> usize { .. }
/// }
/// ```
declare_lint! {
declare_clippy_lint! {
pub LEN_WITHOUT_IS_EMPTY,
Warn,
style,
"traits or impls with a public `len` method but no corresponding `is_empty` method"
}

View File

@ -44,9 +44,9 @@ use utils::{snippet, span_lint_and_then};
/// None
/// };
/// ```
declare_lint! {
declare_clippy_lint! {
pub USELESS_LET_IF_SEQ,
Warn,
style,
"unidiomatic `let mut` declaration followed by initialization in `if`"
}

View File

@ -60,10 +60,34 @@ extern crate url;
#[macro_use]
extern crate if_chain;
macro_rules! declare_restriction_lint {
{ pub $name:tt, $description:tt } => {
macro_rules! declare_clippy_lint {
{ pub $name:tt, style, $description:tt } => {
declare_lint! { pub $name, Warn, $description }
};
{ pub $name:tt, correctness, $description:tt } => {
declare_lint! { pub $name, Deny, $description }
};
{ pub $name:tt, complexity, $description:tt } => {
declare_lint! { pub $name, Warn, $description }
};
{ pub $name:tt, perf, $description:tt } => {
declare_lint! { pub $name, Warn, $description }
};
{ pub $name:tt, pedantic, $description:tt } => {
declare_lint! { pub $name, Allow, $description }
};
{ pub $name:tt, restriction, $description:tt } => {
declare_lint! { pub $name, Allow, $description }
};
{ pub $name:tt, nursery, $description:tt } => {
declare_lint! { pub $name, Allow, $description }
};
{ pub $name:tt, internal, $description:tt } => {
declare_lint! { pub $name, Allow, $description }
};
{ pub $name:tt, internal_warn, $description:tt } => {
declare_lint! { pub $name, Warn, $description }
};
}
pub mod consts;
@ -380,57 +404,58 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry) {
reg.register_late_lint_pass(box redundant_field_names::RedundantFieldNames);
reg.register_lint_group("clippy_restrictions", vec![
reg.register_lint_group("clippy_restriction", vec![
arithmetic::FLOAT_ARITHMETIC,
arithmetic::INTEGER_ARITHMETIC,
array_indexing::INDEXING_SLICING,
assign_ops::ASSIGN_OPS,
else_if_without_else::ELSE_IF_WITHOUT_ELSE,
literal_representation::DECIMAL_LITERAL_REPRESENTATION,
methods::CLONE_ON_REF_PTR,
misc::FLOAT_CMP_CONST,
]);
reg.register_lint_group("clippy_pedantic", vec![
booleans::NONMINIMAL_BOOL,
empty_enum::EMPTY_ENUM,
enum_glob_use::ENUM_GLOB_USE,
enum_variants::PUB_ENUM_VARIANT_NAMES,
enum_variants::STUTTER,
fallible_impl_from::FALLIBLE_IMPL_FROM,
if_not_else::IF_NOT_ELSE,
infinite_iter::MAYBE_INFINITE_ITER,
int_plus_one::INT_PLUS_ONE,
items_after_statements::ITEMS_AFTER_STATEMENTS,
matches::SINGLE_MATCH_ELSE,
mem_forget::MEM_FORGET,
methods::FILTER_MAP,
methods::OPTION_MAP_UNWRAP_OR,
methods::OPTION_MAP_UNWRAP_OR_ELSE,
methods::CLONE_ON_REF_PTR,
methods::OPTION_UNWRAP_USED,
methods::RESULT_MAP_UNWRAP_OR_ELSE,
methods::RESULT_UNWRAP_USED,
methods::WRONG_PUB_SELF_CONVENTION,
misc::USED_UNDERSCORE_BINDING,
misc_early::UNSEPARATED_LITERAL_SUFFIX,
misc::FLOAT_CMP_CONST,
missing_doc::MISSING_DOCS_IN_PRIVATE_ITEMS,
mut_mut::MUT_MUT,
mutex_atomic::MUTEX_INTEGER,
non_expressive_names::SIMILAR_NAMES,
print::PRINT_STDOUT,
print::USE_DEBUG,
ranges::RANGE_PLUS_ONE,
replace_consts::REPLACE_CONSTS,
shadow::SHADOW_REUSE,
shadow::SHADOW_SAME,
shadow::SHADOW_UNRELATED,
strings::STRING_ADD,
]);
reg.register_lint_group("clippy_pedantic", vec![
attrs::INLINE_ALWAYS,
copies::MATCH_SAME_ARMS,
derive::EXPL_IMPL_CLONE_ON_COPY,
doc::DOC_MARKDOWN,
empty_enum::EMPTY_ENUM,
enum_glob_use::ENUM_GLOB_USE,
enum_variants::PUB_ENUM_VARIANT_NAMES,
enum_variants::STUTTER,
if_not_else::IF_NOT_ELSE,
infinite_iter::MAYBE_INFINITE_ITER,
items_after_statements::ITEMS_AFTER_STATEMENTS,
matches::SINGLE_MATCH_ELSE,
methods::FILTER_MAP,
methods::OPTION_MAP_UNWRAP_OR,
methods::OPTION_MAP_UNWRAP_OR_ELSE,
methods::RESULT_MAP_UNWRAP_OR_ELSE,
misc::USED_UNDERSCORE_BINDING,
misc_early::UNSEPARATED_LITERAL_SUFFIX,
mut_mut::MUT_MUT,
needless_continue::NEEDLESS_CONTINUE,
non_expressive_names::SIMILAR_NAMES,
replace_consts::REPLACE_CONSTS,
strings::STRING_ADD_ASSIGN,
types::CAST_POSSIBLE_TRUNCATION,
types::CAST_POSSIBLE_WRAP,
types::CAST_PRECISION_LOSS,
types::CAST_SIGN_LOSS,
types::INVALID_UPCAST_COMPARISONS,
types::LINKEDLIST,
unicode::NON_ASCII_LITERAL,
unicode::UNICODE_NOT_NFC,
use_self::USE_SELF,
@ -448,7 +473,6 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry) {
assign_ops::MISREFACTORED_ASSIGN_OP,
attrs::DEPRECATED_SEMVER,
attrs::EMPTY_LINE_AFTER_OUTER_ATTR,
attrs::INLINE_ALWAYS,
attrs::USELESS_ATTRIBUTE,
bit_mask::BAD_BIT_MASK,
bit_mask::INEFFECTIVE_BIT_MASK,
@ -457,16 +481,14 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry) {
block_in_if_condition::BLOCK_IN_IF_CONDITION_EXPR,
block_in_if_condition::BLOCK_IN_IF_CONDITION_STMT,
booleans::LOGIC_BUG,
booleans::NONMINIMAL_BOOL,
bytecount::NAIVE_BYTECOUNT,
collapsible_if::COLLAPSIBLE_IF,
const_static_lifetime::CONST_STATIC_LIFETIME,
copies::IF_SAME_THEN_ELSE,
copies::IFS_SAME_COND,
copies::MATCH_SAME_ARMS,
cyclomatic_complexity::CYCLOMATIC_COMPLEXITY,
derive::DERIVE_HASH_XOR_EQ,
derive::EXPL_IMPL_CLONE_ON_COPY,
doc::DOC_MARKDOWN,
double_comparison::DOUBLE_COMPARISONS,
double_parens::DOUBLE_PARENS,
drop_forget_ref::DROP_COPY,
@ -496,6 +518,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry) {
if_let_redundant_pattern_matching::IF_LET_REDUNDANT_PATTERN_MATCHING,
infinite_iter::INFINITE_ITER,
inline_fn_without_body::INLINE_FN_WITHOUT_BODY,
int_plus_one::INT_PLUS_ONE,
invalid_ref::INVALID_REF,
large_enum_variant::LARGE_ENUM_VARIANT,
len_zero::LEN_WITHOUT_IS_EMPTY,
@ -573,7 +596,6 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry) {
needless_bool::NEEDLESS_BOOL,
needless_borrow::NEEDLESS_BORROW,
needless_borrowed_ref::NEEDLESS_BORROWED_REFERENCE,
needless_continue::NEEDLESS_CONTINUE,
needless_pass_by_value::NEEDLESS_PASS_BY_VALUE,
needless_update::NEEDLESS_UPDATE,
neg_multiply::NEG_MULTIPLY,
@ -628,7 +650,6 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry) {
types::CHAR_LIT_AS_U8,
types::IMPLICIT_HASHER,
types::LET_UNIT_VALUE,
types::LINKEDLIST,
types::OPTION_OPTION,
types::TYPE_COMPLEXITY,
types::UNIT_ARG,
@ -641,6 +662,218 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry) {
vec::USELESS_VEC,
zero_div_zero::ZERO_DIVIDED_BY_ZERO,
]);
reg.register_lint_group("clippy_style", vec![
assign_ops::ASSIGN_OP_PATTERN,
attrs::EMPTY_LINE_AFTER_OUTER_ATTR,
bit_mask::VERBOSE_BIT_MASK,
blacklisted_name::BLACKLISTED_NAME,
block_in_if_condition::BLOCK_IN_IF_CONDITION_EXPR,
block_in_if_condition::BLOCK_IN_IF_CONDITION_STMT,
collapsible_if::COLLAPSIBLE_IF,
const_static_lifetime::CONST_STATIC_LIFETIME,
enum_variants::ENUM_VARIANT_NAMES,
enum_variants::MODULE_INCEPTION,
eq_op::OP_REF,
eta_reduction::REDUNDANT_CLOSURE,
formatting::SUSPICIOUS_ASSIGNMENT_FORMATTING,
formatting::SUSPICIOUS_ELSE_FORMATTING,
if_let_redundant_pattern_matching::IF_LET_REDUNDANT_PATTERN_MATCHING,
len_zero::LEN_WITHOUT_IS_EMPTY,
len_zero::LEN_ZERO,
let_if_seq::USELESS_LET_IF_SEQ,
literal_representation::INCONSISTENT_DIGIT_GROUPING,
literal_representation::LARGE_DIGIT_GROUPS,
literal_representation::UNREADABLE_LITERAL,
loops::EMPTY_LOOP,
loops::EXPLICIT_INTO_ITER_LOOP,
loops::EXPLICIT_ITER_LOOP,
loops::FOR_KV_MAP,
loops::NEEDLESS_RANGE_LOOP,
loops::WHILE_LET_ON_ITERATOR,
map_clone::MAP_CLONE,
matches::MATCH_BOOL,
matches::MATCH_OVERLAPPING_ARM,
matches::MATCH_REF_PATS,
matches::MATCH_WILD_ERR_ARM,
matches::SINGLE_MATCH,
methods::CHARS_LAST_CMP,
methods::GET_UNWRAP,
methods::ITER_CLONED_COLLECT,
methods::ITER_SKIP_NEXT,
methods::NEW_RET_NO_SELF,
methods::OK_EXPECT,
methods::OPTION_MAP_OR_NONE,
methods::SHOULD_IMPLEMENT_TRAIT,
methods::STRING_EXTEND_CHARS,
methods::UNNECESSARY_FOLD,
methods::WRONG_SELF_CONVENTION,
misc::REDUNDANT_PATTERN,
misc::TOPLEVEL_REF_ARG,
misc::ZERO_PTR,
misc_early::BUILTIN_TYPE_SHADOW,
misc_early::DOUBLE_NEG,
misc_early::DUPLICATE_UNDERSCORE_ARGUMENT,
misc_early::MIXED_CASE_HEX_LITERALS,
misc_early::UNNEEDED_FIELD_PATTERN,
mut_reference::UNNECESSARY_MUT_PASSED,
needless_pass_by_value::NEEDLESS_PASS_BY_VALUE,
neg_multiply::NEG_MULTIPLY,
new_without_default::NEW_WITHOUT_DEFAULT,
new_without_default::NEW_WITHOUT_DEFAULT_DERIVE,
non_expressive_names::JUST_UNDERSCORES_AND_DIGITS,
non_expressive_names::MANY_SINGLE_CHAR_NAMES,
ok_if_let::IF_LET_SOME_RESULT,
panic::PANIC_PARAMS,
print::PRINT_WITH_NEWLINE,
print::PRINTLN_EMPTY_STRING,
ptr::CMP_NULL,
ptr::PTR_ARG,
question_mark::QUESTION_MARK,
ranges::RANGE_MINUS_ONE,
redundant_field_names::REDUNDANT_FIELD_NAMES,
regex::REGEX_MACRO,
regex::TRIVIAL_REGEX,
returns::LET_AND_RETURN,
returns::NEEDLESS_RETURN,
strings::STRING_LIT_AS_BYTES,
types::IMPLICIT_HASHER,
types::LET_UNIT_VALUE,
unsafe_removed_from_name::UNSAFE_REMOVED_FROM_NAME,
]);
reg.register_lint_group("clippy_complexity", vec![
assign_ops::MISREFACTORED_ASSIGN_OP,
booleans::NONMINIMAL_BOOL,
cyclomatic_complexity::CYCLOMATIC_COMPLEXITY,
double_comparison::DOUBLE_COMPARISONS,
double_parens::DOUBLE_PARENS,
eval_order_dependence::DIVERGING_SUB_EXPRESSION,
eval_order_dependence::EVAL_ORDER_DEPENDENCE,
explicit_write::EXPLICIT_WRITE,
format::USELESS_FORMAT,
functions::TOO_MANY_ARGUMENTS,
identity_conversion::IDENTITY_CONVERSION,
identity_op::IDENTITY_OP,
int_plus_one::INT_PLUS_ONE,
lifetimes::NEEDLESS_LIFETIMES,
lifetimes::UNUSED_LIFETIMES,
loops::EXPLICIT_COUNTER_LOOP,
loops::MUT_RANGE_BOUND,
loops::WHILE_LET_LOOP,
matches::MATCH_AS_REF,
methods::CHARS_NEXT_CMP,
methods::CLONE_ON_COPY,
methods::FILTER_NEXT,
methods::SEARCH_IS_SOME,
methods::USELESS_ASREF,
misc::SHORT_CIRCUIT_STATEMENT,
misc_early::REDUNDANT_CLOSURE_CALL,
misc_early::ZERO_PREFIXED_LITERAL,
needless_bool::BOOL_COMPARISON,
needless_bool::NEEDLESS_BOOL,
needless_borrow::NEEDLESS_BORROW,
needless_borrowed_ref::NEEDLESS_BORROWED_REFERENCE,
needless_update::NEEDLESS_UPDATE,
no_effect::NO_EFFECT,
no_effect::UNNECESSARY_OPERATION,
overflow_check_conditional::OVERFLOW_CHECK_CONDITIONAL,
partialeq_ne_impl::PARTIALEQ_NE_IMPL,
precedence::PRECEDENCE,
ranges::RANGE_ZIP_WITH_LEN,
reference::DEREF_ADDROF,
swap::MANUAL_SWAP,
temporary_assignment::TEMPORARY_ASSIGNMENT,
transmute::CROSSPOINTER_TRANSMUTE,
transmute::MISALIGNED_TRANSMUTE,
transmute::TRANSMUTE_BYTES_TO_STR,
transmute::TRANSMUTE_INT_TO_BOOL,
transmute::TRANSMUTE_INT_TO_CHAR,
transmute::TRANSMUTE_INT_TO_FLOAT,
transmute::TRANSMUTE_PTR_TO_REF,
transmute::USELESS_TRANSMUTE,
types::BORROWED_BOX,
types::CAST_LOSSLESS,
types::CHAR_LIT_AS_U8,
types::OPTION_OPTION,
types::TYPE_COMPLEXITY,
types::UNIT_ARG,
types::UNNECESSARY_CAST,
unused_label::UNUSED_LABEL,
zero_div_zero::ZERO_DIVIDED_BY_ZERO,
]);
reg.register_lint_group("clippy_correctness", vec![
approx_const::APPROX_CONSTANT,
array_indexing::OUT_OF_BOUNDS_INDEXING,
attrs::DEPRECATED_SEMVER,
attrs::USELESS_ATTRIBUTE,
bit_mask::BAD_BIT_MASK,
bit_mask::INEFFECTIVE_BIT_MASK,
booleans::LOGIC_BUG,
copies::IF_SAME_THEN_ELSE,
copies::IFS_SAME_COND,
derive::DERIVE_HASH_XOR_EQ,
drop_forget_ref::DROP_COPY,
drop_forget_ref::DROP_REF,
drop_forget_ref::FORGET_COPY,
drop_forget_ref::FORGET_REF,
enum_clike::ENUM_CLIKE_UNPORTABLE_VARIANT,
eq_op::EQ_OP,
erasing_op::ERASING_OP,
formatting::POSSIBLE_MISSING_COMMA,
functions::NOT_UNSAFE_PTR_ARG_DEREF,
infinite_iter::INFINITE_ITER,
inline_fn_without_body::INLINE_FN_WITHOUT_BODY,
invalid_ref::INVALID_REF,
loops::FOR_LOOP_OVER_OPTION,
loops::FOR_LOOP_OVER_RESULT,
loops::ITER_NEXT_LOOP,
loops::NEVER_LOOP,
loops::REVERSE_RANGE_LOOP,
loops::WHILE_IMMUTABLE_CONDITION,
methods::CLONE_DOUBLE_REF,
methods::TEMPORARY_CSTRING_AS_PTR,
minmax::MIN_MAX,
misc::CMP_NAN,
misc::FLOAT_CMP,
misc::MODULO_ONE,
open_options::NONSENSICAL_OPEN_OPTIONS,
ptr::MUT_FROM_REF,
ranges::ITERATOR_STEP_BY_ZERO,
regex::INVALID_REGEX,
serde_api::SERDE_API_MISUSE,
suspicious_trait_impl::SUSPICIOUS_ARITHMETIC_IMPL,
suspicious_trait_impl::SUSPICIOUS_OP_ASSIGN_IMPL,
swap::ALMOST_SWAPPED,
transmute::WRONG_TRANSMUTE,
types::ABSURD_EXTREME_COMPARISONS,
types::UNIT_CMP,
unicode::ZERO_WIDTH_SPACE,
unused_io_amount::UNUSED_IO_AMOUNT,
]);
reg.register_lint_group("clippy_perf", vec![
bytecount::NAIVE_BYTECOUNT,
entry::MAP_ENTRY,
escape::BOXED_LOCAL,
large_enum_variant::LARGE_ENUM_VARIANT,
loops::MANUAL_MEMCPY,
loops::UNUSED_COLLECT,
methods::ITER_NTH,
methods::OR_FUN_CALL,
methods::SINGLE_CHAR_PATTERN,
misc::CMP_OWNED,
mutex_atomic::MUTEX_ATOMIC,
types::BOX_VEC,
vec::USELESS_VEC,
]);
reg.register_lint_group("clippy_nursery", vec![
fallible_impl_from::FALLIBLE_IMPL_FROM,
mutex_atomic::MUTEX_INTEGER,
ranges::RANGE_PLUS_ONE,
]);
}
// only exists to let the dogfood integration test works.

View File

@ -22,9 +22,9 @@ use syntax::symbol::keywords;
/// ```rust
/// fn in_and_out<'a>(x: &'a u8, y: u8) -> &'a u8 { x }
/// ```
declare_lint! {
declare_clippy_lint! {
pub NEEDLESS_LIFETIMES,
Warn,
complexity,
"using explicit lifetimes for references in function arguments when elision rules \
would allow omitting them"
}
@ -42,9 +42,9 @@ declare_lint! {
/// ```rust
/// fn unused_lifetime<'a>(x: u8) { .. }
/// ```
declare_lint! {
declare_clippy_lint! {
pub UNUSED_LIFETIMES,
Warn,
complexity,
"unused lifetimes in function definitions"
}

View File

@ -18,9 +18,9 @@ use utils::{in_external_macro, snippet_opt, span_lint_and_sugg};
/// ```rust
/// 61864918973511
/// ```
declare_lint! {
declare_clippy_lint! {
pub UNREADABLE_LITERAL,
Warn,
style,
"long integer literal without underscores"
}
@ -37,9 +37,9 @@ declare_lint! {
/// ```rust
/// 618_64_9189_73_511
/// ```
declare_lint! {
declare_clippy_lint! {
pub INCONSISTENT_DIGIT_GROUPING,
Warn,
style,
"integer literals with digits grouped inconsistently"
}
@ -56,9 +56,9 @@ declare_lint! {
/// ```rust
/// 6186491_8973511
/// ```
declare_lint! {
declare_clippy_lint! {
pub LARGE_DIGIT_GROUPS,
Warn,
style,
"grouping digits into groups that are too large"
}
@ -74,8 +74,9 @@ declare_lint! {
/// `255` => `0xFF`
/// `65_535` => `0xFFFF`
/// `4_042_322_160` => `0xF0F0_F0F0`
declare_restriction_lint! {
declare_clippy_lint! {
pub DECIMAL_LITERAL_REPRESENTATION,
restriction,
"using decimal representation when hexadecimal would be better"
}

View File

@ -38,9 +38,9 @@ use utils::paths;
/// dst[i + 64] = src[i];
/// }
/// ```
declare_lint! {
declare_clippy_lint! {
pub MANUAL_MEMCPY,
Warn,
perf,
"manually copying items between slices"
}
@ -58,9 +58,9 @@ declare_lint! {
/// println!("{}", vec[i]);
/// }
/// ```
declare_lint! {
declare_clippy_lint! {
pub NEEDLESS_RANGE_LOOP,
Warn,
style,
"for-looping over a range of indices where an iterator over items would do"
}
@ -77,9 +77,9 @@ declare_lint! {
/// // with `y` a `Vec` or slice:
/// for x in y.iter() { .. }
/// ```
declare_lint! {
declare_clippy_lint! {
pub EXPLICIT_ITER_LOOP,
Warn,
style,
"for-looping over `_.iter()` or `_.iter_mut()` when `&_` or `&mut _` would do"
}
@ -95,9 +95,9 @@ declare_lint! {
/// // with `y` a `Vec` or slice:
/// for x in y.into_iter() { .. }
/// ```
declare_lint! {
declare_clippy_lint! {
pub EXPLICIT_INTO_ITER_LOOP,
Warn,
style,
"for-looping over `_.into_iter()` when `_` would do"
}
@ -117,9 +117,9 @@ declare_lint! {
/// ```rust
/// for x in y.next() { .. }
/// ```
declare_lint! {
declare_clippy_lint! {
pub ITER_NEXT_LOOP,
Warn,
correctness,
"for-looping over `_.next()` which is probably not intended"
}
@ -139,9 +139,9 @@ declare_lint! {
/// ```rust
/// if let Some(x) = option { .. }
/// ```
declare_lint! {
declare_clippy_lint! {
pub FOR_LOOP_OVER_OPTION,
Warn,
correctness,
"for-looping over an `Option`, which is more clearly expressed as an `if let`"
}
@ -161,9 +161,9 @@ declare_lint! {
/// ```rust
/// if let Ok(x) = result { .. }
/// ```
declare_lint! {
declare_clippy_lint! {
pub FOR_LOOP_OVER_RESULT,
Warn,
correctness,
"for-looping over a `Result`, which is more clearly expressed as an `if let`"
}
@ -189,9 +189,9 @@ declare_lint! {
/// // .. do something with x
/// }
/// ```
declare_lint! {
declare_clippy_lint! {
pub WHILE_LET_LOOP,
Warn,
complexity,
"`loop { if let { ... } else break }`, which can be written as a `while let` loop"
}
@ -207,9 +207,9 @@ declare_lint! {
/// ```rust
/// vec.iter().map(|x| /* some operation returning () */).collect::<Vec<_>>();
/// ```
declare_lint! {
declare_clippy_lint! {
pub UNUSED_COLLECT,
Warn,
perf,
"`collect()`ing an iterator without using the result; this is usually better \
written as a for loop"
}
@ -230,9 +230,9 @@ declare_lint! {
/// ```rust
/// for x in 5..10-5 { .. } // oops, stray `-`
/// ```
declare_lint! {
declare_clippy_lint! {
pub REVERSE_RANGE_LOOP,
Warn,
correctness,
"iteration over an empty range, such as `10..0` or `5..5`"
}
@ -250,9 +250,9 @@ declare_lint! {
/// for i in 0..v.len() { foo(v[i]);
/// for i in 0..v.len() { bar(i, v[i]); }
/// ```
declare_lint! {
declare_clippy_lint! {
pub EXPLICIT_COUNTER_LOOP,
Warn,
complexity,
"for-looping with an explicit counter when `_.enumerate()` would do"
}
@ -268,9 +268,9 @@ declare_lint! {
/// ```rust
/// loop {}
/// ```
declare_lint! {
declare_clippy_lint! {
pub EMPTY_LOOP,
Warn,
style,
"empty `loop {}`, which should block or sleep"
}
@ -285,9 +285,9 @@ declare_lint! {
/// ```rust
/// while let Some(val) = iter() { .. }
/// ```
declare_lint! {
declare_clippy_lint! {
pub WHILE_LET_ON_ITERATOR,
Warn,
style,
"using a while-let loop instead of a for loop on an iterator"
}
@ -309,9 +309,9 @@ declare_lint! {
/// ```rust
/// for k in map.keys() { .. }
/// ```
declare_lint! {
declare_clippy_lint! {
pub FOR_KV_MAP,
Warn,
style,
"looping on a map using `iter` when `keys` or `values` would do"
}
@ -327,17 +327,29 @@ declare_lint! {
/// ```rust
/// loop { ..; break; }
/// ```
declare_lint! {
declare_clippy_lint! {
pub NEVER_LOOP,
Warn,
correctness,
"any loop that will always `break` or `return`"
}
/// TODO: add documentation
declare_lint! {
/// **What it does:** Checks for loops which have a range bound that is a mutable variable
///
/// **Why is this bad?** One might think that modifying the mutable variable changes the loop bounds
///
/// **Known problems:** None
///
/// **Example:**
/// ```rust
/// let mut foo = 42;
/// for i in 0..foo {
/// foo -= 1;
/// println!("{}", i); // prints numbers from 0 to 42, not 0 to 21
/// }
/// ```
declare_clippy_lint! {
pub MUT_RANGE_BOUND,
Warn,
complexity,
"for loop over a range where one of the bounds is a mutable variable"
}
@ -358,9 +370,9 @@ declare_lint! {
/// println!("let me loop forever!");
/// }
/// ```
declare_lint! {
declare_clippy_lint! {
pub WHILE_IMMUTABLE_CONDITION,
Warn,
correctness,
"variables used within while expression are not mutated in the body"
}

View File

@ -18,9 +18,9 @@ use utils::{get_arg_name, is_adjusted, iter_input_pats, match_qpath, match_trait
/// ```rust
/// x.map(|e| e.clone());
/// ```
declare_lint! {
declare_clippy_lint! {
pub MAP_CLONE,
Warn,
style,
"using `.map(|x| x.clone())` to clone an iterator or option's contents"
}

View File

@ -25,9 +25,9 @@ use consts::{constant, Constant};
/// _ => ()
/// }
/// ```
declare_lint! {
declare_clippy_lint! {
pub SINGLE_MATCH,
Warn,
style,
"a match statement with a single nontrivial arm (i.e. where the other arm \
is `_ => {}`) instead of `if let`"
}
@ -46,9 +46,9 @@ declare_lint! {
/// _ => bar(other_ref),
/// }
/// ```
declare_lint! {
declare_clippy_lint! {
pub SINGLE_MATCH_ELSE,
Allow,
pedantic,
"a match statement with a two arms where the second arm's pattern is a wildcard \
instead of `if let`"
}
@ -70,9 +70,9 @@ declare_lint! {
/// _ => frob(&x),
/// }
/// ```
declare_lint! {
declare_clippy_lint! {
pub MATCH_REF_PATS,
Warn,
style,
"a match or `if let` with all arms prefixed with `&` instead of deref-ing the match expression"
}
@ -91,9 +91,9 @@ declare_lint! {
/// false => bar(),
/// }
/// ```
declare_lint! {
declare_clippy_lint! {
pub MATCH_BOOL,
Warn,
style,
"a match on a boolean expression instead of an `if..else` block"
}
@ -113,9 +113,9 @@ declare_lint! {
/// _ => (),
/// }
/// ```
declare_lint! {
declare_clippy_lint! {
pub MATCH_OVERLAPPING_ARM,
Warn,
style,
"a match with overlapping arms"
}
@ -135,9 +135,9 @@ declare_lint! {
/// Err(_) => panic!("err"),
/// }
/// ```
declare_lint! {
declare_clippy_lint! {
pub MATCH_WILD_ERR_ARM,
Warn,
style,
"a match with `Err(_)` arm and take drastic actions"
}
@ -156,9 +156,9 @@ declare_lint! {
/// Some(ref v) => Some(v),
/// };
/// ```
declare_lint! {
declare_clippy_lint! {
pub MATCH_AS_REF,
Warn,
complexity,
"a match on an Option value instead of using `as_ref()` or `as_mut`"
}

View File

@ -14,9 +14,9 @@ use utils::{match_def_path, opt_def_id, paths, span_lint};
/// ```rust
/// mem::forget(Rc::new(55)))
/// ```
declare_lint! {
declare_clippy_lint! {
pub MEM_FORGET,
Allow,
restriction,
"`mem::forget` usage on `Drop` types, likely to cause memory leaks"
}

View File

@ -31,9 +31,9 @@ pub struct Pass;
/// ```rust
/// x.unwrap()
/// ```
declare_lint! {
declare_clippy_lint! {
pub OPTION_UNWRAP_USED,
Allow,
restriction,
"using `Option.unwrap()`, which should at least get a better message using `expect()`"
}
@ -53,9 +53,9 @@ declare_lint! {
/// ```rust
/// x.unwrap()
/// ```
declare_lint! {
declare_clippy_lint! {
pub RESULT_UNWRAP_USED,
Allow,
restriction,
"using `Result.unwrap()`, which might be better handled"
}
@ -79,9 +79,9 @@ declare_lint! {
/// fn add(&self, other: &X) -> X { .. }
/// }
/// ```
declare_lint! {
declare_clippy_lint! {
pub SHOULD_IMPLEMENT_TRAIT,
Warn,
style,
"defining a method that should be implementing a std trait"
}
@ -108,9 +108,9 @@ declare_lint! {
/// fn as_str(self) -> &str { .. }
/// }
/// ```
declare_lint! {
declare_clippy_lint! {
pub WRONG_SELF_CONVENTION,
Warn,
style,
"defining a method named with an established prefix (like \"into_\") that takes \
`self` with the wrong convention"
}
@ -130,9 +130,9 @@ declare_lint! {
/// pub fn as_str(self) -> &str { .. }
/// }
/// ```
declare_lint! {
declare_clippy_lint! {
pub WRONG_PUB_SELF_CONVENTION,
Allow,
restriction,
"defining a public method named with an established prefix (like \"into_\") that takes \
`self` with the wrong convention"
}
@ -142,15 +142,15 @@ declare_lint! {
/// **Why is this bad?** Because you usually call `expect()` on the `Result`
/// directly to get a better error message.
///
/// **Known problems:** None.
/// **Known problems:** The error type needs to implement `Debug`
///
/// **Example:**
/// ```rust
/// x.ok().expect("why did I do this again?")
/// ```
declare_lint! {
declare_clippy_lint! {
pub OK_EXPECT,
Warn,
style,
"using `ok().expect()`, which gives worse error messages than \
calling `expect` directly on the Result"
}
@ -160,15 +160,15 @@ declare_lint! {
/// **Why is this bad?** Readability, this can be written more concisely as
/// `_.map_or(_, _)`.
///
/// **Known problems:** None.
/// **Known problems:** The order of the arguments is not in execution order
///
/// **Example:**
/// ```rust
/// x.map(|a| a + 1).unwrap_or(0)
/// ```
declare_lint! {
declare_clippy_lint! {
pub OPTION_MAP_UNWRAP_OR,
Allow,
pedantic,
"using `Option.map(f).unwrap_or(a)`, which is more succinctly expressed as \
`map_or(a, f)`"
}
@ -178,15 +178,15 @@ declare_lint! {
/// **Why is this bad?** Readability, this can be written more concisely as
/// `_.map_or_else(_, _)`.
///
/// **Known problems:** None.
/// **Known problems:** The order of the arguments is not in execution order.
///
/// **Example:**
/// ```rust
/// x.map(|a| a + 1).unwrap_or_else(some_function)
/// ```
declare_lint! {
declare_clippy_lint! {
pub OPTION_MAP_UNWRAP_OR_ELSE,
Allow,
pedantic,
"using `Option.map(f).unwrap_or_else(g)`, which is more succinctly expressed as \
`map_or_else(g, f)`"
}
@ -202,9 +202,9 @@ declare_lint! {
/// ```rust
/// x.map(|a| a + 1).unwrap_or_else(some_function)
/// ```
declare_lint! {
declare_clippy_lint! {
pub RESULT_MAP_UNWRAP_OR_ELSE,
Allow,
pedantic,
"using `Result.map(f).unwrap_or_else(g)`, which is more succinctly expressed as \
`.ok().map_or_else(g, f)`"
}
@ -214,15 +214,15 @@ declare_lint! {
/// **Why is this bad?** Readability, this can be written more concisely as
/// `_.and_then(_)`.
///
/// **Known problems:** None.
/// **Known problems:** The order of the arguments is not in execution order.
///
/// **Example:**
/// ```rust
/// opt.map_or(None, |a| a + 1)
/// ```
declare_lint! {
declare_clippy_lint! {
pub OPTION_MAP_OR_NONE,
Warn,
style,
"using `Option.map_or(None, f)`, which is more succinctly expressed as \
`and_then(f)`"
}
@ -238,9 +238,9 @@ declare_lint! {
/// ```rust
/// iter.filter(|x| x == 0).next()
/// ```
declare_lint! {
declare_clippy_lint! {
pub FILTER_NEXT,
Warn,
complexity,
"using `filter(p).next()`, which is more succinctly expressed as `.find(p)`"
}
@ -257,9 +257,9 @@ declare_lint! {
/// ```rust
/// iter.filter(|x| x == 0).map(|x| x * 2)
/// ```
declare_lint! {
declare_clippy_lint! {
pub FILTER_MAP,
Allow,
pedantic,
"using combinations of `filter`, `map`, `filter_map` and `flat_map` which can \
usually be written as a single method call"
}
@ -276,9 +276,9 @@ declare_lint! {
/// ```rust
/// iter.find(|x| x == 0).is_some()
/// ```
declare_lint! {
declare_clippy_lint! {
pub SEARCH_IS_SOME,
Warn,
complexity,
"using an iterator search followed by `is_some()`, which is more succinctly \
expressed as a call to `any()`"
}
@ -295,9 +295,9 @@ declare_lint! {
/// ```rust
/// name.chars().next() == Some('_')
/// ```
declare_lint! {
declare_clippy_lint! {
pub CHARS_NEXT_CMP,
Warn,
complexity,
"using `.chars().next()` to check if a string starts with a char"
}
@ -323,9 +323,9 @@ declare_lint! {
/// ```rust
/// foo.unwrap_or_default()
/// ```
declare_lint! {
declare_clippy_lint! {
pub OR_FUN_CALL,
Warn,
perf,
"using any `*or` method with a function call, which suggests `*or_else`"
}
@ -340,15 +340,15 @@ declare_lint! {
/// ```rust
/// 42u64.clone()
/// ```
declare_lint! {
declare_clippy_lint! {
pub CLONE_ON_COPY,
Warn,
complexity,
"using `clone` on a `Copy` type"
}
/// **What it does:** Checks for usage of `.clone()` on a ref-counted pointer,
/// (Rc, Arc, rc::Weak, or sync::Weak), and suggests calling Clone on
/// the corresponding trait instead.
/// (`Rc`, `Arc`, `rc::Weak`, or `sync::Weak`), and suggests calling Clone via unified
/// function syntax instead (e.g. `Rc::clone(foo)`).
///
/// **Why is this bad?**: Calling '.clone()' on an Rc, Arc, or Weak
/// can obscure the fact that only the pointer is being cloned, not the underlying
@ -358,8 +358,9 @@ declare_lint! {
/// ```rust
/// x.clone()
/// ```
declare_restriction_lint! {
declare_clippy_lint! {
pub CLONE_ON_REF_PTR,
restriction,
"using 'clone' on a ref-counted pointer"
}
@ -379,9 +380,9 @@ declare_restriction_lint! {
/// println!("{:p} {:p}",*y, z); // prints out the same pointer
/// }
/// ```
declare_lint! {
declare_clippy_lint! {
pub CLONE_DOUBLE_REF,
Warn,
correctness,
"using `clone` on `&&T`"
}
@ -399,9 +400,9 @@ declare_lint! {
/// }
/// }
/// ```
declare_lint! {
declare_clippy_lint! {
pub NEW_RET_NO_SELF,
Warn,
style,
"not returning `Self` in a `new` method"
}
@ -415,9 +416,9 @@ declare_lint! {
///
/// **Example:**
/// `_.split("x")` could be `_.split('x')
declare_lint! {
declare_clippy_lint! {
pub SINGLE_CHAR_PATTERN,
Warn,
perf,
"using a single-character str where a char could be used, e.g. \
`_.split(\"x\")`"
}
@ -444,9 +445,9 @@ declare_lint! {
/// call_some_ffi_func(c_str.as_ptr());
/// }
/// ```
declare_lint! {
declare_clippy_lint! {
pub TEMPORARY_CSTRING_AS_PTR,
Warn,
correctness,
"getting the inner pointer of a temporary `CString`"
}
@ -470,9 +471,9 @@ declare_lint! {
/// let bad_vec = some_vec.get(3);
/// let bad_slice = &some_vec[..].get(3);
/// ```
declare_lint! {
declare_clippy_lint! {
pub ITER_NTH,
Warn,
perf,
"using `.iter().nth()` on a standard library type with O(1) element access"
}
@ -494,9 +495,9 @@ declare_lint! {
/// let bad_vec = some_vec.iter().nth(3);
/// let bad_slice = &some_vec[..].iter().nth(3);
/// ```
declare_lint! {
declare_clippy_lint! {
pub ITER_SKIP_NEXT,
Warn,
style,
"using `.skip(x).next()` on an iterator"
}
@ -520,9 +521,9 @@ declare_lint! {
/// let last = some_vec[3];
/// some_vec[0] = 1;
/// ```
declare_lint! {
declare_clippy_lint! {
pub GET_UNWRAP,
Warn,
style,
"using `.get().unwrap()` or `.get_mut().unwrap()` when using `[]` would work instead"
}
@ -549,9 +550,9 @@ declare_lint! {
/// s.push_str(abc);
/// s.push_str(&def));
/// ```
declare_lint! {
declare_clippy_lint! {
pub STRING_EXTEND_CHARS,
Warn,
style,
"using `x.extend(s.chars())` where s is a `&str` or `String`"
}
@ -572,9 +573,9 @@ declare_lint! {
/// let s = [1,2,3,4,5];
/// let s2 : Vec<isize> = s.to_vec();
/// ```
declare_lint! {
declare_clippy_lint! {
pub ITER_CLONED_COLLECT,
Warn,
style,
"using `.cloned().collect()` on slice to create a `Vec`"
}
@ -590,9 +591,9 @@ declare_lint! {
/// ```rust
/// name.chars().last() == Some('_') || name.chars().next_back() == Some('-')
/// ```
declare_lint! {
declare_clippy_lint! {
pub CHARS_LAST_CMP,
Warn,
style,
"using `.chars().last()` or `.chars().next_back()` to check if a string ends with a char"
}
@ -613,9 +614,9 @@ declare_lint! {
/// let x: &[i32] = &[1,2,3,4,5];
/// do_stuff(x);
/// ```
declare_lint! {
declare_clippy_lint! {
pub USELESS_ASREF,
Warn,
complexity,
"using `as_ref` where the types before and after the call are the same"
}
@ -636,9 +637,9 @@ declare_lint! {
/// ```rust
/// let _ = (0..3).any(|x| x > 2);
/// ```
declare_lint! {
declare_clippy_lint! {
pub UNNECESSARY_FOLD,
Warn,
style,
"using `fold` when a more succinct alternative exists"
}

View File

@ -18,9 +18,9 @@ use utils::{match_def_path, opt_def_id, paths, span_lint};
/// ```
/// It will always be equal to `0`. Probably the author meant to clamp the value
/// between 0 and 100, but has erroneously swapped `min` and `max`.
declare_lint! {
declare_clippy_lint! {
pub MIN_MAX,
Warn,
correctness,
"`min(_, max(_, _))` (or vice versa) with bounds clamping the result to a constant"
}

View File

@ -31,9 +31,9 @@ use consts::{constant, Constant};
/// ```rust
/// fn foo(ref x: u8) -> bool { .. }
/// ```
declare_lint! {
declare_clippy_lint! {
pub TOPLEVEL_REF_ARG,
Warn,
style,
"an entire binding declared as `ref`, in a function argument or a `let` statement"
}
@ -48,9 +48,9 @@ declare_lint! {
/// ```rust
/// x == NAN
/// ```
declare_lint! {
declare_clippy_lint! {
pub CMP_NAN,
Deny,
correctness,
"comparisons to NAN, which will always return false, probably not intended"
}
@ -70,9 +70,9 @@ declare_lint! {
/// y == 1.23f64
/// y != x // where both are floats
/// ```
declare_lint! {
declare_clippy_lint! {
pub FLOAT_CMP,
Warn,
correctness,
"using `==` or `!=` on float values instead of comparing difference with an epsilon"
}
@ -89,9 +89,9 @@ declare_lint! {
/// ```rust
/// x.to_owned() == y
/// ```
declare_lint! {
declare_clippy_lint! {
pub CMP_OWNED,
Warn,
perf,
"creating owned instances for comparing with others, e.g. `x == \"foo\".to_string()`"
}
@ -108,9 +108,9 @@ declare_lint! {
/// ```rust
/// x % 1
/// ```
declare_lint! {
declare_clippy_lint! {
pub MODULO_ONE,
Warn,
correctness,
"taking a number modulo 1, which always returns 0"
}
@ -128,9 +128,9 @@ declare_lint! {
/// y @ _ => (), // easier written as `y`,
/// }
/// ```
declare_lint! {
declare_clippy_lint! {
pub REDUNDANT_PATTERN,
Warn,
style,
"using `name @ _` in a pattern"
}
@ -150,9 +150,9 @@ declare_lint! {
/// let y = _x + 1; // Here we are using `_x`, even though it has a leading
/// // underscore. We should rename `_x` to `x`
/// ```
declare_lint! {
declare_clippy_lint! {
pub USED_UNDERSCORE_BINDING,
Allow,
pedantic,
"using a binding which is prefixed with an underscore"
}
@ -170,9 +170,9 @@ declare_lint! {
/// ```rust
/// f() && g(); // We should write `if f() { g(); }`.
/// ```
declare_lint! {
declare_clippy_lint! {
pub SHORT_CIRCUIT_STATEMENT,
Warn,
complexity,
"using a short circuit boolean condition as a statement"
}
@ -188,9 +188,9 @@ declare_lint! {
/// ```rust
/// 0 as *const u32
/// ```
declare_lint! {
declare_clippy_lint! {
pub ZERO_PTR,
Warn,
style,
"using 0 as *{const, mut} T"
}
@ -210,8 +210,9 @@ declare_lint! {
/// const ONE == 1.00f64
/// x == ONE // where both are floats
/// ```
declare_restriction_lint! {
declare_clippy_lint! {
pub FLOAT_CMP_CONST,
restriction,
"using `==` or `!=` on float constants instead of comparing difference with an epsilon"
}

View File

@ -17,9 +17,9 @@ use utils::{constants, in_external_macro, snippet, snippet_opt, span_help_and_li
/// ```rust
/// let { a: _, b: ref b, c: _ } = ..
/// ```
declare_lint! {
declare_clippy_lint! {
pub UNNEEDED_FIELD_PATTERN,
Warn,
style,
"struct fields bound to a wildcard instead of using `..`"
}
@ -34,9 +34,9 @@ declare_lint! {
/// ```rust
/// fn foo(a: i32, _a: i32) {}
/// ```
declare_lint! {
declare_clippy_lint! {
pub DUPLICATE_UNDERSCORE_ARGUMENT,
Warn,
style,
"function arguments having names which only differ by an underscore"
}
@ -52,9 +52,9 @@ declare_lint! {
/// ```rust
/// (|| 42)()
/// ```
declare_lint! {
declare_clippy_lint! {
pub REDUNDANT_CLOSURE_CALL,
Warn,
complexity,
"throwaway closures called in the expression they are defined"
}
@ -69,9 +69,9 @@ declare_lint! {
/// ```rust
/// --x;
/// ```
declare_lint! {
declare_clippy_lint! {
pub DOUBLE_NEG,
Warn,
style,
"`--x`, which is a double negation of `x` and not a pre-decrement as in C/C++"
}
@ -86,9 +86,9 @@ declare_lint! {
/// ```rust
/// let y = 0x1a9BAcD;
/// ```
declare_lint! {
declare_clippy_lint! {
pub MIXED_CASE_HEX_LITERALS,
Warn,
style,
"hex literals whose letter digits are not consistently upper- or lowercased"
}
@ -103,9 +103,9 @@ declare_lint! {
/// ```rust
/// let y = 123832i32;
/// ```
declare_lint! {
declare_clippy_lint! {
pub UNSEPARATED_LITERAL_SUFFIX,
Allow,
pedantic,
"literals whose suffix is not separated by an underscore"
}
@ -141,9 +141,9 @@ declare_lint! {
/// ```
///
/// prints `83` (as `83 == 0o123` while `123 == 0o173`).
declare_lint! {
declare_clippy_lint! {
pub ZERO_PREFIXED_LITERAL,
Warn,
complexity,
"integer literals starting with `0`"
}
@ -162,9 +162,9 @@ declare_lint! {
/// }
/// }
/// ```
declare_lint! {
declare_clippy_lint! {
pub BUILTIN_TYPE_SHADOW,
Warn,
style,
"shadowing a builtin type"
}

View File

@ -35,9 +35,9 @@ use utils::in_macro;
/// This lint fixes that.
///
/// **Known problems:** None.
declare_lint! {
declare_clippy_lint! {
pub MISSING_DOCS_IN_PRIVATE_ITEMS,
Allow,
restriction,
"detects missing documentation for public and private members"
}

View File

@ -16,9 +16,9 @@ use utils::{higher, in_external_macro, span_lint};
/// ```rust
/// let x = &mut &mut y;
/// ```
declare_lint! {
declare_clippy_lint! {
pub MUT_MUT,
Allow,
pedantic,
"usage of double-mut refs, e.g. `&mut &mut ...`"
}

View File

@ -16,9 +16,9 @@ use utils::span_lint;
/// ```rust
/// my_vec.push(&mut value)
/// ```
declare_lint! {
declare_clippy_lint! {
pub UNNECESSARY_MUT_PASSED,
Warn,
style,
"an argument passed as a mutable reference although the callee only demands an \
immutable reference"
}

View File

@ -22,9 +22,9 @@ use utils::{match_type, paths, span_lint};
/// ```rust
/// let x = Mutex::new(&y);
/// ```
declare_lint! {
declare_clippy_lint! {
pub MUTEX_ATOMIC,
Warn,
perf,
"using a mutex where an atomic value could be used instead"
}
@ -42,9 +42,9 @@ declare_lint! {
/// ```rust
/// let x = Mutex::new(0usize);
/// ```
declare_lint! {
declare_clippy_lint! {
pub MUTEX_INTEGER,
Allow,
nursery,
"using a mutex for an integer type"
}

View File

@ -24,9 +24,9 @@ use utils::sugg::Sugg;
/// ```rust
/// if x { false } else { true }
/// ```
declare_lint! {
declare_clippy_lint! {
pub NEEDLESS_BOOL,
Warn,
complexity,
"if-statements with plain booleans in the then- and else-clause, e.g. \
`if p { true } else { false }`"
}
@ -42,9 +42,9 @@ declare_lint! {
/// ```rust
/// if x == true { } // could be `if x { }`
/// ```
declare_lint! {
declare_clippy_lint! {
pub BOOL_COMPARISON,
Warn,
complexity,
"comparing a variable to a boolean, e.g. `if x == true`"
}

View File

@ -20,9 +20,9 @@ use utils::{in_macro, snippet_opt, span_lint_and_then};
/// ```rust
/// let x: &i32 = &&&&&&5;
/// ```
declare_lint! {
declare_clippy_lint! {
pub NEEDLESS_BORROW,
Warn,
complexity,
"taking a reference that is going to be automatically dereferenced"
}

View File

@ -42,9 +42,9 @@ use utils::{in_macro, snippet, span_lint_and_then};
/// reference and
/// de-referenced.
/// As such, it could just be |a| a.is_empty()
declare_lint! {
declare_clippy_lint! {
pub NEEDLESS_BORROWED_REFERENCE,
Warn,
complexity,
"taking a needless borrowed reference"
}

View File

@ -93,9 +93,9 @@ use utils::{in_macro, snippet, snippet_block, span_help_and_lint, trim_multiline
/// // Do something useful
/// }
/// ```
declare_lint! {
declare_clippy_lint! {
pub NEEDLESS_CONTINUE,
Warn,
pedantic,
"`continue` statements that can be replaced by a rearrangement of code"
}

View File

@ -39,9 +39,9 @@ use std::borrow::Cow;
/// assert_eq!(v.len(), 42);
/// }
/// ```
declare_lint! {
declare_clippy_lint! {
pub NEEDLESS_PASS_BY_VALUE,
Warn,
style,
"functions taking arguments by value, but not consuming them in its body"
}

View File

@ -15,9 +15,9 @@ use utils::span_lint;
/// ```rust
/// Point { x: 1, y: 0, ..zero_point }
/// ```
declare_lint! {
declare_clippy_lint! {
pub NEEDLESS_UPDATE,
Warn,
complexity,
"using `Foo { ..base }` when there are no missing fields"
}

View File

@ -15,9 +15,9 @@ use utils::span_lint;
/// ```rust
/// x * -1
/// ```
declare_lint! {
declare_clippy_lint! {
pub NEG_MULTIPLY,
Warn,
style,
"multiplying integers with -1"
}

View File

@ -42,9 +42,9 @@ use utils::sugg::DiagnosticBuilderExt;
/// ```
///
/// You can also have `new()` call `Default::default()`.
declare_lint! {
declare_clippy_lint! {
pub NEW_WITHOUT_DEFAULT,
Warn,
style,
"`fn new() -> Self` method without `Default` implementation"
}
@ -72,9 +72,9 @@ declare_lint! {
/// ```
///
/// Just prepend `#[derive(Default)]` before the `struct` definition.
declare_lint! {
declare_clippy_lint! {
pub NEW_WITHOUT_DEFAULT_DERIVE,
Warn,
style,
"`fn new() -> Self` without `#[derive]`able `Default` implementation"
}

View File

@ -16,9 +16,9 @@ use std::ops::Deref;
/// ```rust
/// 0;
/// ```
declare_lint! {
declare_clippy_lint! {
pub NO_EFFECT,
Warn,
complexity,
"statements with no effect"
}
@ -34,9 +34,9 @@ declare_lint! {
/// ```rust
/// compute_array()[0];
/// ```
declare_lint! {
declare_clippy_lint! {
pub UNNECESSARY_OPERATION,
Warn,
complexity,
"outer expressions with no effect"
}

View File

@ -18,9 +18,9 @@ use utils::{in_macro, span_lint, span_lint_and_then};
/// let checked_exp = something;
/// let checked_expr = something_else;
/// ```
declare_lint! {
declare_clippy_lint! {
pub SIMILAR_NAMES,
Allow,
pedantic,
"similarly named items and bindings"
}
@ -36,9 +36,9 @@ declare_lint! {
/// ```rust
/// let (a, b, c, d, e, f, g) = (...);
/// ```
declare_lint! {
declare_clippy_lint! {
pub MANY_SINGLE_CHAR_NAMES,
Warn,
style,
"too many single character bindings"
}
@ -56,9 +56,9 @@ declare_lint! {
/// let ___1 = 1;
/// let __1___2 = 11;
/// ```
declare_lint! {
declare_clippy_lint! {
pub JUST_UNDERSCORES_AND_DIGITS,
Warn,
style,
"unclear name"
}

View File

@ -26,9 +26,9 @@ use utils::{match_type, method_chain_args, paths, snippet, span_help_and_lint};
/// }
/// }
/// ```
declare_lint! {
declare_clippy_lint! {
pub IF_LET_SOME_RESULT,
Warn,
style,
"usage of `ok()` in `if let Some(pat)` statements is unnecessary, match on `Ok(pat)` instead"
}

View File

@ -16,9 +16,9 @@ use utils::{match_type, paths, span_lint, walk_ptrs_ty};
/// ```rust
/// OpenOptions::new().read(true).truncate(true)
/// ```
declare_lint! {
declare_clippy_lint! {
pub NONSENSICAL_OPEN_OPTIONS,
Warn,
correctness,
"nonsensical combination of options for opening a file"
}

View File

@ -13,9 +13,9 @@ use utils::span_lint;
/// ```rust
/// a + b < a
/// ```
declare_lint! {
declare_clippy_lint! {
pub OVERFLOW_CHECK_CONDITIONAL,
Warn,
complexity,
"overflow checks inspired by C which are likely to panic"
}

View File

@ -17,9 +17,9 @@ use utils::{is_direct_expn_of, match_def_path, opt_def_id, paths, resolve_node,
/// ```rust
/// panic!("This `panic!` is probably missing a parameter there: {}");
/// ```
declare_lint! {
declare_clippy_lint! {
pub PANIC_PARAMS,
Warn,
style,
"missing parameters in `panic!` calls"
}

View File

@ -20,9 +20,9 @@ use utils::{is_automatically_derived, span_lint};
/// fn ne(&self, other: &Foo) -> bool { !(self == other) }
/// }
/// ```
declare_lint! {
declare_clippy_lint! {
pub PARTIALEQ_NE_IMPL,
Warn,
complexity,
"re-implementing `PartialEq::ne`"
}

View File

@ -20,9 +20,9 @@ use utils::{in_macro, snippet, span_lint_and_sugg};
/// **Example:**
/// * `1 << 2 + 3` equals 32, while `(1 << 2) + 3` equals 7
/// * `-1i32.abs()` equals -1, while `(-1i32).abs()` equals 1
declare_lint! {
declare_clippy_lint! {
pub PRECEDENCE,
Warn,
complexity,
"operations where precedence may be unclear"
}

View File

@ -8,7 +8,7 @@ use syntax_pos::Span;
use utils::{is_expn_of, match_def_path, match_path, resolve_node, span_lint, span_lint_and_sugg};
use utils::{opt_def_id, paths};
/// **What it does:** This lint warns when you using `println!("")` to
/// **What it does:** This lint warns when you use `println!("")` to
/// print a newline.
///
/// **Why is this bad?** You should use `println!()`, which is simpler.
@ -19,13 +19,13 @@ use utils::{opt_def_id, paths};
/// ```rust
/// println!("");
/// ```
declare_lint! {
declare_clippy_lint! {
pub PRINTLN_EMPTY_STRING,
Warn,
"using `print!()` with a format string that ends in a newline"
style,
"using `println!(\"\")` with an empty string"
}
/// **What it does:** This lint warns when you using `print!()` with a format
/// **What it does:** This lint warns when you use `print!()` with a format
/// string that
/// ends in a newline.
///
@ -38,9 +38,9 @@ declare_lint! {
/// ```rust
/// print!("Hello {}!\n", name);
/// ```
declare_lint! {
declare_clippy_lint! {
pub PRINT_WITH_NEWLINE,
Warn,
style,
"using `print!()` with a format string that ends in a newline"
}
@ -56,9 +56,9 @@ declare_lint! {
/// ```rust
/// println!("Hello world!");
/// ```
declare_lint! {
declare_clippy_lint! {
pub PRINT_STDOUT,
Allow,
restriction,
"printing on stdout"
}
@ -72,9 +72,9 @@ declare_lint! {
/// ```rust
/// println!("{:?}", foo);
/// ```
declare_lint! {
declare_clippy_lint! {
pub USE_DEBUG,
Allow,
restriction,
"use of `Debug`-based formatting"
}

View File

@ -42,9 +42,9 @@ use utils::ptr::get_spans;
/// ```rust
/// fn foo(&Vec<u32>) { .. }
/// ```
declare_lint! {
declare_clippy_lint! {
pub PTR_ARG,
Warn,
style,
"fn arguments of the type `&Vec<...>` or `&String`, suggesting to use `&[...]` or `&str` \
instead, respectively"
}
@ -61,9 +61,9 @@ declare_lint! {
/// ```rust
/// if x == ptr::null { .. }
/// ```
declare_lint! {
declare_clippy_lint! {
pub CMP_NULL,
Warn,
style,
"comparing a pointer to a null pointer, suggesting to use `.is_null()` instead."
}
@ -86,9 +86,9 @@ declare_lint! {
/// ```rust
/// fn foo(&Foo) -> &mut Bar { .. }
/// ```
declare_lint! {
declare_clippy_lint! {
pub MUT_FROM_REF,
Warn,
correctness,
"fns that create mutable refs from immutable ref args"
}

View File

@ -25,9 +25,9 @@ use utils::paths::*;
/// ```rust
/// option?;
/// ```
declare_lint!{
declare_clippy_lint!{
pub QUESTION_MARK,
Warn,
style,
"checks for expressions that could be replaced by the question mark operator"
}

View File

@ -18,9 +18,9 @@ use utils::sugg::Sugg;
/// ```rust
/// for x in (5..5).step_by(0) { .. }
/// ```
declare_lint! {
declare_clippy_lint! {
pub ITERATOR_STEP_BY_ZERO,
Warn,
correctness,
"using `Iterator::step_by(0)`, which produces an infinite iterator"
}
@ -35,9 +35,9 @@ declare_lint! {
/// ```rust
/// x.iter().zip(0..x.len())
/// ```
declare_lint! {
declare_clippy_lint! {
pub RANGE_ZIP_WITH_LEN,
Warn,
complexity,
"zipping iterator with a range when `enumerate()` would do"
}
@ -53,9 +53,9 @@ declare_lint! {
/// ```rust
/// for x..(y+1) { .. }
/// ```
declare_lint! {
declare_clippy_lint! {
pub RANGE_PLUS_ONE,
Allow,
nursery,
"`x..(y+1)` reads better as `x..=y`"
}
@ -71,9 +71,9 @@ declare_lint! {
/// ```rust
/// for x..=(y-1) { .. }
/// ```
declare_lint! {
declare_clippy_lint! {
pub RANGE_MINUS_ONE,
Warn,
style,
"`x..=(y-1)` reads better as `x..y`"
}

View File

@ -20,9 +20,9 @@ use utils::{in_macro, is_range_expression, match_var, span_lint_and_sugg};
///
/// let foo = Foo{ bar: bar }
/// ```
declare_lint! {
declare_clippy_lint! {
pub REDUNDANT_FIELD_NAMES,
Warn,
style,
"checks for fields in struct literals where shorthands could be used"
}

View File

@ -15,9 +15,9 @@ use utils::{snippet, span_lint_and_sugg};
/// let a = f(*&mut b);
/// let c = *&d;
/// ```
declare_lint! {
declare_clippy_lint! {
pub DEREF_ADDROF,
Warn,
complexity,
"use of `*&` or `*&mut` in an expression"
}

View File

@ -19,9 +19,9 @@ use consts::{constant, Constant};
/// ```rust
/// Regex::new("|")
/// ```
declare_lint! {
declare_clippy_lint! {
pub INVALID_REGEX,
Deny,
correctness,
"invalid regular expressions"
}
@ -38,9 +38,9 @@ declare_lint! {
/// ```rust
/// Regex::new("^foobar")
/// ```
declare_lint! {
declare_clippy_lint! {
pub TRIVIAL_REGEX,
Warn,
style,
"trivial regular expressions"
}
@ -57,9 +57,9 @@ declare_lint! {
/// ```rust
/// regex!("foo|bar")
/// ```
declare_lint! {
declare_clippy_lint! {
pub REGEX_MACRO,
Warn,
style,
"use of `regex!(_)` instead of `Regex::new(_)`"
}

View File

@ -20,9 +20,9 @@ use utils::{match_def_path, span_lint_and_sugg};
/// ```rust
/// static FOO: AtomicIsize = AtomicIsize::new(0);
/// ```
declare_lint! {
declare_clippy_lint! {
pub REPLACE_CONSTS,
Allow,
pedantic,
"Lint usages of standard library `const`s that could be replaced by `const fn`s"
}

View File

@ -17,9 +17,9 @@ use utils::{in_external_macro, in_macro, match_path_ast, snippet_opt, span_lint_
/// ```rust
/// fn foo(x: usize) { return x; }
/// ```
declare_lint! {
declare_clippy_lint! {
pub NEEDLESS_RETURN,
Warn,
style,
"using a return statement like `return expr;` where an expression would suffice"
}
@ -35,9 +35,9 @@ declare_lint! {
/// ```rust
/// { let x = ..; x }
/// ```
declare_lint! {
declare_clippy_lint! {
pub LET_AND_RETURN,
Warn,
style,
"creating a let-binding and then immediately returning it like `let x = expr; x` at \
the end of a block"
}

View File

@ -5,15 +5,15 @@ use utils::{get_trait_def_id, paths, span_lint};
/// **What it does:** Checks for mis-uses of the serde API.
///
/// **Why is this bad?** Serde is very finnicky about how its API should be
/// used, but the type system can't be used to enforce it (yet).
/// used, but the type system can't be used to enforce it (yet?).
///
/// **Known problems:** None.
///
/// **Example:** Implementing `Visitor::visit_string` but not
/// `Visitor::visit_str`.
declare_lint! {
declare_clippy_lint! {
pub SERDE_API_MISUSE,
Warn,
correctness,
"various things that will negatively affect your serde experience"
}

View File

@ -20,9 +20,9 @@ use utils::{contains_name, higher, in_external_macro, iter_input_pats, snippet,
/// ```rust
/// let x = &x;
/// ```
declare_lint! {
declare_clippy_lint! {
pub SHADOW_SAME,
Allow,
restriction,
"rebinding a name to itself, e.g. `let mut x = &mut x`"
}
@ -41,9 +41,9 @@ declare_lint! {
/// ```rust
/// let x = x + 1;
/// ```
declare_lint! {
declare_clippy_lint! {
pub SHADOW_REUSE,
Allow,
restriction,
"rebinding a name to an expression that re-uses the original value, e.g. \
`let x = x + 1`"
}
@ -64,9 +64,9 @@ declare_lint! {
/// ```rust
/// let x = y; let x = z; // shadows the earlier binding
/// ```
declare_lint! {
declare_clippy_lint! {
pub SHADOW_UNRELATED,
Allow,
restriction,
"rebinding a name without even using the original value"
}

View File

@ -8,7 +8,8 @@ use utils::{get_parent_expr, is_allowed, match_type, paths, span_lint, span_lint
/// `let`!).
///
/// **Why is this bad?** It's not really bad, but some people think that the
/// `.push_str(_)` method is more readable.
/// `.push_str(_)` method is more readable. Also creates a new heap allocation and throws
/// away the old one.
///
/// **Known problems:** None.
///
@ -18,9 +19,9 @@ use utils::{get_parent_expr, is_allowed, match_type, paths, span_lint, span_lint
/// let mut x = "Hello".to_owned();
/// x = x + ", World";
/// ```
declare_lint! {
declare_clippy_lint! {
pub STRING_ADD_ASSIGN,
Allow,
pedantic,
"using `x = x + ..` where x is a `String` instead of `push_str()`"
}
@ -46,9 +47,9 @@ declare_lint! {
/// let x = "Hello".to_owned();
/// x + ", World"
/// ```
declare_lint! {
declare_clippy_lint! {
pub STRING_ADD,
Allow,
restriction,
"using `x + ..` where x is a `String` instead of `push_str()`"
}
@ -64,9 +65,9 @@ declare_lint! {
/// ```rust
/// let bs = "a byte string".as_bytes();
/// ```
declare_lint! {
declare_clippy_lint! {
pub STRING_LIT_AS_BYTES,
Warn,
style,
"calling `as_bytes` on a string literal instead of using a byte string literal"
}

View File

@ -21,9 +21,9 @@ use utils::{get_trait_def_id, span_lint};
/// }
/// }
/// ```
declare_lint! {
declare_clippy_lint! {
pub SUSPICIOUS_ARITHMETIC_IMPL,
Warn,
correctness,
"suspicious use of operators in impl of arithmetic trait"
}
@ -42,9 +42,9 @@ declare_lint! {
/// }
/// }
/// ```
declare_lint! {
declare_clippy_lint! {
pub SUSPICIOUS_OP_ASSIGN_IMPL,
Warn,
correctness,
"suspicious use of operators in impl of OpAssign trait"
}

View File

@ -17,9 +17,9 @@ use utils::sugg::Sugg;
/// b = a;
/// a = t;
/// ```
declare_lint! {
declare_clippy_lint! {
pub MANUAL_SWAP,
Warn,
complexity,
"manual swap of two variables"
}
@ -34,9 +34,9 @@ declare_lint! {
/// a = b;
/// b = a;
/// ```
declare_lint! {
declare_clippy_lint! {
pub ALMOST_SWAPPED,
Warn,
correctness,
"`foo = bar; bar = foo` sequence"
}

View File

@ -15,9 +15,9 @@ use utils::span_lint;
/// ```rust
/// (0, 0).0 = 1
/// ```
declare_lint! {
declare_clippy_lint! {
pub TEMPORARY_ASSIGNMENT,
Warn,
complexity,
"assignments to temporaries"
}

View File

@ -19,9 +19,9 @@ use utils::{opt_def_id, sugg};
/// ```rust
/// let ptr: *const T = core::intrinsics::transmute('x')`
/// ```
declare_lint! {
declare_clippy_lint! {
pub WRONG_TRANSMUTE,
Warn,
correctness,
"transmutes that are confusing at best, undefined behaviour at worst and always useless"
}
@ -37,9 +37,9 @@ declare_lint! {
/// ```rust
/// core::intrinsics::transmute(t) // where the result type is the same as `t`'s
/// ```
declare_lint! {
declare_clippy_lint! {
pub USELESS_TRANSMUTE,
Warn,
complexity,
"transmutes that have the same to and from types or could be a cast/coercion"
}
@ -55,9 +55,9 @@ declare_lint! {
/// core::intrinsics::transmute(t)` // where the result type is the same as
/// `*t` or `&t`'s
/// ```
declare_lint! {
declare_clippy_lint! {
pub CROSSPOINTER_TRANSMUTE,
Warn,
complexity,
"transmutes that have to or from types that are a pointer to the other"
}
@ -73,9 +73,9 @@ declare_lint! {
/// // can be written:
/// let _: &T = &*p;
/// ```
declare_lint! {
declare_clippy_lint! {
pub TRANSMUTE_PTR_TO_REF,
Warn,
complexity,
"transmutes from a pointer to a reference type"
}
@ -100,9 +100,9 @@ declare_lint! {
/// // should be:
/// let _ = std::char::from_u32(x).unwrap();
/// ```
declare_lint! {
declare_clippy_lint! {
pub TRANSMUTE_INT_TO_CHAR,
Warn,
complexity,
"transmutes from an integer to a `char`"
}
@ -127,9 +127,9 @@ declare_lint! {
/// // should be:
/// let _ = std::str::from_utf8(b).unwrap();
/// ```
declare_lint! {
declare_clippy_lint! {
pub TRANSMUTE_BYTES_TO_STR,
Warn,
complexity,
"transmutes from a `&[u8]` to a `&str`"
}
@ -145,9 +145,9 @@ declare_lint! {
/// // should be:
/// let _: bool = x != 0;
/// ```
declare_lint! {
declare_clippy_lint! {
pub TRANSMUTE_INT_TO_BOOL,
Warn,
complexity,
"transmutes from an integer to a `bool`"
}
@ -163,9 +163,9 @@ declare_lint! {
/// // should be:
/// let _: f32 = f32::from_bits(x);
/// ```
declare_lint! {
declare_clippy_lint! {
pub TRANSMUTE_INT_TO_FLOAT,
Warn,
complexity,
"transmutes from an integer to a float"
}
@ -180,9 +180,9 @@ declare_lint! {
/// // u32 is 32-bit aligned; u8 is 8-bit aligned
/// let _: u32 = unsafe { std::mem::transmute([0u8; 4]) };
/// ```
declare_lint! {
declare_clippy_lint! {
pub MISALIGNED_TRANSMUTE,
Warn,
complexity,
"transmutes to a potentially less-aligned type"
}

View File

@ -44,9 +44,9 @@ pub struct TypePass;
/// values: Vec<Foo>,
/// }
/// ```
declare_lint! {
declare_clippy_lint! {
pub BOX_VEC,
Warn,
perf,
"usage of `Box<Vec<T>>`, vector elements are already on the heap"
}
@ -64,9 +64,9 @@ declare_lint! {
/// fn x() -> Option<Option<u32>> {
/// None
/// }
declare_lint! {
declare_clippy_lint! {
pub OPTION_OPTION,
Warn,
complexity,
"usage of `Option<Option<T>>`"
}
@ -99,9 +99,9 @@ declare_lint! {
/// ```rust
/// let x = LinkedList::new();
/// ```
declare_lint! {
declare_clippy_lint! {
pub LINKEDLIST,
Warn,
pedantic,
"usage of LinkedList, usually a vector is faster, or a more specialized data \
structure like a VecDeque"
}
@ -123,9 +123,9 @@ declare_lint! {
/// ```rust
/// fn foo(bar: &T) { ... }
/// ```
declare_lint! {
declare_clippy_lint! {
pub BORROWED_BOX,
Warn,
complexity,
"a borrow of a boxed type"
}
@ -353,9 +353,9 @@ pub struct LetPass;
/// ```rust
/// let x = { 1; };
/// ```
declare_lint! {
declare_clippy_lint! {
pub LET_UNIT_VALUE,
Warn,
style,
"creating a let binding to a value of unit type, which usually can't be used afterwards"
}
@ -409,9 +409,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LetPass {
/// ```rust
/// { foo(); bar(); baz(); }
/// ```
declare_lint! {
declare_clippy_lint! {
pub UNIT_CMP,
Warn,
correctness,
"comparing unit values"
}
@ -464,9 +464,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnitCmp {
/// baz(a);
/// })
/// ```
declare_lint! {
declare_clippy_lint! {
pub UNIT_ARG,
Warn,
complexity,
"passing unit to a function"
}
@ -563,9 +563,9 @@ pub struct CastPass;
/// ```rust
/// let x = u64::MAX; x as f64
/// ```
declare_lint! {
declare_clippy_lint! {
pub CAST_PRECISION_LOSS,
Allow,
pedantic,
"casts that cause loss of precision, e.g. `x as f32` where `x: u64`"
}
@ -584,9 +584,9 @@ declare_lint! {
/// let y: i8 = -1;
/// y as u128 // will return 18446744073709551615
/// ```
declare_lint! {
declare_clippy_lint! {
pub CAST_SIGN_LOSS,
Allow,
pedantic,
"casts from signed types to unsigned types, e.g. `x as u32` where `x: i32`"
}
@ -604,9 +604,9 @@ declare_lint! {
/// ```rust
/// fn as_u8(x: u64) -> u8 { x as u8 }
/// ```
declare_lint! {
declare_clippy_lint! {
pub CAST_POSSIBLE_TRUNCATION,
Allow,
pedantic,
"casts that may cause truncation of the value, e.g. `x as u8` where `x: u32`, \
or `x as i32` where `x: f32`"
}
@ -628,9 +628,9 @@ declare_lint! {
/// ```rust
/// u32::MAX as i32 // will yield a value of `-1`
/// ```
declare_lint! {
declare_clippy_lint! {
pub CAST_POSSIBLE_WRAP,
Allow,
pedantic,
"casts that may cause wrapping around the value, e.g. `x as i32` where `x: u32` \
and `x > i32::MAX`"
}
@ -657,9 +657,9 @@ declare_lint! {
/// ```rust
/// fn as_u64(x: u8) -> u64 { u64::from(x) }
/// ```
declare_lint! {
declare_clippy_lint! {
pub CAST_LOSSLESS,
Warn,
complexity,
"casts using `as` that are known to be lossless, e.g. `x as u64` where `x: u8`"
}
@ -673,9 +673,9 @@ declare_lint! {
/// ```rust
/// let _ = 2i32 as i32
/// ```
declare_lint! {
declare_clippy_lint! {
pub UNNECESSARY_CAST,
Warn,
complexity,
"cast to the same type, e.g. `x as i32` where `x: i32`"
}
@ -971,9 +971,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for CastPass {
/// ```rust
/// struct Foo { inner: Rc<Vec<Vec<Box<(u32, u32, u32, u32)>>>> }
/// ```
declare_lint! {
declare_clippy_lint! {
pub TYPE_COMPLEXITY,
Warn,
complexity,
"usage of very complex types that might be better factored into `type` definitions"
}
@ -1143,9 +1143,9 @@ impl<'tcx> Visitor<'tcx> for TypeComplexityVisitor {
/// ```rust
/// b'x'
/// ```
declare_lint! {
declare_clippy_lint! {
pub CHAR_LIT_AS_U8,
Warn,
complexity,
"casting a character literal to u8"
}
@ -1198,9 +1198,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for CharLitAsU8 {
/// vec.len() <= 0
/// 100 > std::i32::MAX
/// ```
declare_lint! {
declare_clippy_lint! {
pub ABSURD_EXTREME_COMPARISONS,
Warn,
correctness,
"a comparison with a maximum or minimum value that is always true or false"
}
@ -1374,9 +1374,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AbsurdExtremeComparisons {
/// ```rust
/// let x : u8 = ...; (x as u32) > 300
/// ```
declare_lint! {
declare_clippy_lint! {
pub INVALID_UPCAST_COMPARISONS,
Allow,
pedantic,
"a comparison involving an upcast which is always true or false"
}
@ -1599,9 +1599,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InvalidUpcastComparisons {
///
/// pub foo(map: &mut HashMap<i32, i32>) { .. }
/// ```
declare_lint! {
declare_clippy_lint! {
pub IMPLICIT_HASHER,
Warn,
style,
"missing generalization over different hashers"
}

View File

@ -14,9 +14,9 @@ use utils::{is_allowed, snippet, span_help_and_lint};
///
/// **Example:** You don't see it, but there may be a zero-width space
/// somewhere in this text.
declare_lint! {
declare_clippy_lint! {
pub ZERO_WIDTH_SPACE,
Deny,
correctness,
"using a zero-width space in a string literal, which is confusing"
}
@ -34,9 +34,9 @@ declare_lint! {
/// ```rust
/// let x = "Hä?"
/// ```
declare_lint! {
declare_clippy_lint! {
pub NON_ASCII_LITERAL,
Allow,
pedantic,
"using any literal non-ASCII chars in a string literal instead of \
using the `\\u` escape"
}
@ -52,9 +52,9 @@ declare_lint! {
///
/// **Example:** You may not see it, but “à” and “à” aren't the same string. The
/// former when escaped is actually `"a\u{300}"` while the latter is `"\u{e0}"`.
declare_lint! {
declare_clippy_lint! {
pub UNICODE_NOT_NFC,
Allow,
pedantic,
"using a unicode literal not in NFC normal form (see \
[unicode tr15](http://www.unicode.org/reports/tr15/) for further information)"
}

View File

@ -19,9 +19,9 @@ use utils::span_lint;
/// extern crate crossbeam;
/// use crossbeam::{spawn_unsafe as spawn};
/// ```
declare_lint! {
declare_clippy_lint! {
pub UNSAFE_REMOVED_FROM_NAME,
Warn,
style,
"`unsafe` removed from API names on import"
}

View File

@ -23,9 +23,9 @@ use utils::{is_try, match_qpath, match_trait_method, paths, span_lint};
/// Ok(())
/// }
/// ```
declare_lint! {
declare_clippy_lint! {
pub UNUSED_IO_AMOUNT,
Deny,
correctness,
"unused written/read amount"
}

View File

@ -21,9 +21,9 @@ use utils::{in_macro, span_lint};
/// if i > 4 { continue }
/// }
/// ```
declare_lint! {
declare_clippy_lint! {
pub UNUSED_LABEL,
Warn,
complexity,
"unused labels"
}

Some files were not shown because too many files have changed in this diff Show More