Make lint descriptions short and to the point; always fitting the column "triggers on".
This commit is contained in:
parent
3b5ff0f813
commit
b91c1a509e
51 changed files with 340 additions and 243 deletions
|
|
@ -28,8 +28,7 @@ use utils::span_lint;
|
|||
declare_lint! {
|
||||
pub APPROX_CONSTANT,
|
||||
Warn,
|
||||
"the approximate of a known float constant (in `std::f64::consts` or `std::f32::consts`) \
|
||||
is found; suggests to use the constant"
|
||||
"the approximate of a known float constant (in `std::fXX::consts`)"
|
||||
}
|
||||
|
||||
// Tuples are of the form (constant, name, min_digits)
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ use utils::span_lint;
|
|||
/// ```
|
||||
declare_restriction_lint! {
|
||||
pub INTEGER_ARITHMETIC,
|
||||
"Any integer arithmetic statement"
|
||||
"any integer arithmetic statement"
|
||||
}
|
||||
|
||||
/// **What it does:** Checks for float arithmetic.
|
||||
|
|
@ -33,7 +33,7 @@ declare_restriction_lint! {
|
|||
/// ```
|
||||
declare_restriction_lint! {
|
||||
pub FLOAT_ARITHMETIC,
|
||||
"Any floating-point arithmetic statement"
|
||||
"any floating-point arithmetic statement"
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Default)]
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ use utils::{self, higher};
|
|||
declare_lint! {
|
||||
pub OUT_OF_BOUNDS_INDEXING,
|
||||
Deny,
|
||||
"out of bound constant indexing"
|
||||
"out of bounds constant indexing"
|
||||
}
|
||||
|
||||
/// **What it does:** Checks for usage of indexing or slicing.
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ use utils::{higher, sugg};
|
|||
/// ```
|
||||
declare_restriction_lint! {
|
||||
pub ASSIGN_OPS,
|
||||
"any assignment operation"
|
||||
"any compound assignment operation"
|
||||
}
|
||||
|
||||
/// **What it does:** Checks for `a = a op b` or `a = b commutative_op a` patterns.
|
||||
|
|
|
|||
|
|
@ -30,8 +30,9 @@ use utils::paths;
|
|||
/// fn not_quite_hot_code(..) { ... }
|
||||
/// ```
|
||||
declare_lint! {
|
||||
pub INLINE_ALWAYS, Warn,
|
||||
"`#[inline(always)]` is a bad idea in most cases"
|
||||
pub INLINE_ALWAYS,
|
||||
Warn,
|
||||
"use of `#[inline(always)]`"
|
||||
}
|
||||
|
||||
/// **What it does:** Checks for `#[deprecated]` annotations with a `since`
|
||||
|
|
@ -48,8 +49,9 @@ declare_lint! {
|
|||
/// fn something_else(..) { ... }
|
||||
/// ```
|
||||
declare_lint! {
|
||||
pub DEPRECATED_SEMVER, Warn,
|
||||
"`Warn` on `#[deprecated(since = \"x\")]` where x is not semver"
|
||||
pub DEPRECATED_SEMVER,
|
||||
Warn,
|
||||
"use of `#[deprecated(since = \"x\")]` where x is not semver"
|
||||
}
|
||||
|
||||
#[derive(Copy,Clone)]
|
||||
|
|
|
|||
|
|
@ -39,8 +39,7 @@ use utils::span_lint;
|
|||
declare_lint! {
|
||||
pub BAD_BIT_MASK,
|
||||
Warn,
|
||||
"expressions of the form `_ & mask == select` that will only ever return `true` or `false` \
|
||||
(because in the example `select` containing bits that `mask` doesn't have)"
|
||||
"expressions of the form `_ & mask == select` that will only ever return `true` or `false`"
|
||||
}
|
||||
|
||||
/// **What it does:** Checks for bit masks in comparisons which can be removed
|
||||
|
|
|
|||
|
|
@ -16,8 +16,9 @@ use utils::*;
|
|||
/// if { true } ..
|
||||
/// ```
|
||||
declare_lint! {
|
||||
pub BLOCK_IN_IF_CONDITION_EXPR, Warn,
|
||||
"braces can be eliminated in conditions that are expressions, e.g `if { true } ...`"
|
||||
pub BLOCK_IN_IF_CONDITION_EXPR,
|
||||
Warn,
|
||||
"braces that can be eliminated in conditions, e.g `if { true } ...`"
|
||||
}
|
||||
|
||||
/// **What it does:** Checks for `if` conditions that use blocks containing
|
||||
|
|
@ -34,9 +35,9 @@ declare_lint! {
|
|||
/// if somefunc(|x| { x == 47 }) ..
|
||||
/// ```
|
||||
declare_lint! {
|
||||
pub BLOCK_IN_IF_CONDITION_STMT, Warn,
|
||||
"avoid complex blocks in conditions, instead move the block higher and bind it \
|
||||
with 'let'; e.g: `if { let x = true; x } ...`"
|
||||
pub BLOCK_IN_IF_CONDITION_STMT,
|
||||
Warn,
|
||||
"complex blocks in conditions, e.g. `if { let x = true; x } ...`"
|
||||
}
|
||||
|
||||
#[derive(Copy,Clone)]
|
||||
|
|
|
|||
|
|
@ -20,8 +20,9 @@ use utils::{span_lint_and_then, in_macro, snippet_opt, SpanlessEq};
|
|||
/// if a && true // should be: if a
|
||||
/// if !(a == b) // should be: if a != b
|
||||
declare_lint! {
|
||||
pub NONMINIMAL_BOOL, Allow,
|
||||
"checks for boolean expressions that can be written more concisely"
|
||||
pub NONMINIMAL_BOOL,
|
||||
Allow,
|
||||
"boolean expressions that can be written more concisely"
|
||||
}
|
||||
|
||||
/// **What it does:** Checks for boolean expressions that contain terminals that
|
||||
|
|
@ -37,8 +38,9 @@ declare_lint! {
|
|||
/// ```
|
||||
/// The `b` is unnecessary, the expression is equivalent to `if a`.
|
||||
declare_lint! {
|
||||
pub LOGIC_BUG, Warn,
|
||||
"checks for boolean expressions that contain terminals which can be eliminated"
|
||||
pub LOGIC_BUG,
|
||||
Warn,
|
||||
"boolean expressions that contain terminals which can be eliminated"
|
||||
}
|
||||
|
||||
#[derive(Copy,Clone)]
|
||||
|
|
|
|||
|
|
@ -20,8 +20,9 @@ use utils::{in_macro, LimitStack, span_help_and_lint, paths, match_type};
|
|||
///
|
||||
/// **Example:** No. You'll see it when you get the warning.
|
||||
declare_lint! {
|
||||
pub CYCLOMATIC_COMPLEXITY, Warn,
|
||||
"finds functions that should be split up into multiple functions"
|
||||
pub CYCLOMATIC_COMPLEXITY,
|
||||
Warn,
|
||||
"functions that should be split up into multiple functions"
|
||||
}
|
||||
|
||||
pub struct CyclomaticComplexity {
|
||||
|
|
|
|||
|
|
@ -21,8 +21,9 @@ use utils::span_lint;
|
|||
/// fn doit(foo_bar) { .. }
|
||||
/// ```
|
||||
declare_lint! {
|
||||
pub DOC_MARKDOWN, Warn,
|
||||
"checks for the presence of `_`, `::` or camel-case outside ticks in documentation"
|
||||
pub DOC_MARKDOWN,
|
||||
Warn,
|
||||
"presence of `_`, `::` or camel-case outside backticks in documentation"
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
|
|
|
|||
|
|
@ -21,9 +21,9 @@ use utils::{match_def_path, paths, span_note_and_lint};
|
|||
/// operation_that_requires_mutex_to_be_unlocked();
|
||||
/// ```
|
||||
declare_lint! {
|
||||
pub DROP_REF, Warn,
|
||||
"call to `std::mem::drop` with a reference instead of an owned value, \
|
||||
which will not call the `Drop::drop` method on the underlying value"
|
||||
pub DROP_REF,
|
||||
Warn,
|
||||
"calls to `std::mem::drop` with a reference instead of an owned value"
|
||||
}
|
||||
|
||||
#[allow(missing_copy_implementations)]
|
||||
|
|
|
|||
|
|
@ -23,8 +23,9 @@ use utils::span_lint;
|
|||
/// }
|
||||
/// ```
|
||||
declare_lint! {
|
||||
pub ENUM_CLIKE_UNPORTABLE_VARIANT, Warn,
|
||||
"finds C-like enums that are `repr(isize/usize)` and have values that don't fit into an `i32`"
|
||||
pub ENUM_CLIKE_UNPORTABLE_VARIANT,
|
||||
Warn,
|
||||
"C-like enums that are `repr(isize/usize)` and have values that don't fit into an `i32`"
|
||||
}
|
||||
|
||||
pub struct UnportableVariant;
|
||||
|
|
|
|||
|
|
@ -21,8 +21,11 @@ use utils::span_lint;
|
|||
/// ```rust
|
||||
/// use std::cmp::Ordering::*;
|
||||
/// ```
|
||||
declare_lint! { pub ENUM_GLOB_USE, Allow,
|
||||
"finds use items that import all variants of an enum" }
|
||||
declare_lint! {
|
||||
pub ENUM_GLOB_USE,
|
||||
Allow,
|
||||
"use items that import all variants of an enum"
|
||||
}
|
||||
|
||||
pub struct EnumGlobUse;
|
||||
|
||||
|
|
|
|||
|
|
@ -23,8 +23,9 @@ use utils::{camel_case_from, camel_case_until, in_macro};
|
|||
/// }
|
||||
/// ```
|
||||
declare_lint! {
|
||||
pub ENUM_VARIANT_NAMES, Warn,
|
||||
"finds enums where all variants share a prefix/postfix"
|
||||
pub ENUM_VARIANT_NAMES,
|
||||
Warn,
|
||||
"enums where all variants share a prefix/postfix"
|
||||
}
|
||||
|
||||
/// **What it does:** Detects type names that are prefixed or suffixed by the
|
||||
|
|
@ -41,8 +42,9 @@ declare_lint! {
|
|||
/// }
|
||||
/// ```
|
||||
declare_lint! {
|
||||
pub STUTTER, Allow,
|
||||
"finds type names prefixed/postfixed with their containing module's name"
|
||||
pub STUTTER,
|
||||
Allow,
|
||||
"type names prefixed/postfixed with their containing module's name"
|
||||
}
|
||||
|
||||
pub struct EnumVariantNames {
|
||||
|
|
|
|||
|
|
@ -35,7 +35,9 @@ pub struct Pass {
|
|||
/// }
|
||||
/// ```
|
||||
declare_lint! {
|
||||
pub BOXED_LOCAL, Warn, "using `Box<T>` where unnecessary"
|
||||
pub BOXED_LOCAL,
|
||||
Warn,
|
||||
"using `Box<T>` where unnecessary"
|
||||
}
|
||||
|
||||
fn is_non_trait_box(ty: ty::Ty) -> bool {
|
||||
|
|
|
|||
|
|
@ -22,8 +22,9 @@ pub struct EtaPass;
|
|||
/// ```
|
||||
/// where `foo(_)` is a plain function that takes the exact argument type of `x`.
|
||||
declare_lint! {
|
||||
pub REDUNDANT_CLOSURE, Warn,
|
||||
"using redundant closures, i.e. `|a| foo(a)` (which can be written as just `foo`)"
|
||||
pub REDUNDANT_CLOSURE,
|
||||
Warn,
|
||||
"redundant closures, i.e. `|a| foo(a)` (which can be written as just `foo`)"
|
||||
}
|
||||
|
||||
impl LintPass for EtaPass {
|
||||
|
|
|
|||
|
|
@ -17,7 +17,8 @@ use rustc_const_math::ConstInt;
|
|||
/// x / 1 + 0 * 1 - 0 | 0
|
||||
/// ```
|
||||
declare_lint! {
|
||||
pub IDENTITY_OP, Warn,
|
||||
pub IDENTITY_OP,
|
||||
Warn,
|
||||
"using identity operations, e.g. `x + 0` or `y / 1`"
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,8 +31,9 @@ use utils::span_help_and_lint;
|
|||
/// }
|
||||
/// ```
|
||||
declare_lint! {
|
||||
pub IF_NOT_ELSE, Allow,
|
||||
"finds if branches that could be swapped so no negation operation is necessary on the condition"
|
||||
pub IF_NOT_ELSE,
|
||||
Allow,
|
||||
"`if` branches that could be swapped so no negation operation is necessary on the condition"
|
||||
}
|
||||
|
||||
pub struct IfNotElse;
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ use utils::{in_macro, span_lint};
|
|||
declare_lint! {
|
||||
pub ITEMS_AFTER_STATEMENTS,
|
||||
Allow,
|
||||
"finds blocks where an item comes after a statement"
|
||||
"blocks where an item comes after a statement"
|
||||
}
|
||||
|
||||
pub struct ItemsAfterStatements;
|
||||
|
|
|
|||
|
|
@ -22,7 +22,8 @@ use utils::{get_item_name, in_macro, snippet, span_lint, span_lint_and_then, wal
|
|||
/// if x.len() == 0 { .. }
|
||||
/// ```
|
||||
declare_lint! {
|
||||
pub LEN_ZERO, Warn,
|
||||
pub LEN_ZERO,
|
||||
Warn,
|
||||
"checking `.len() == 0` or `.len() > 0` (or similar) when `.is_empty()` \
|
||||
could be used instead"
|
||||
}
|
||||
|
|
@ -45,7 +46,8 @@ declare_lint! {
|
|||
/// }
|
||||
/// ```
|
||||
declare_lint! {
|
||||
pub LEN_WITHOUT_IS_EMPTY, Warn,
|
||||
pub LEN_WITHOUT_IS_EMPTY,
|
||||
Warn,
|
||||
"traits and impls that have `.len()` but not `.is_empty()`"
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ use utils::{snippet, span_lint_and_then};
|
|||
declare_lint! {
|
||||
pub USELESS_LET_IF_SEQ,
|
||||
Warn,
|
||||
"Checks for unidiomatic `let mut` declaration followed by initialization in `if`"
|
||||
"unidiomatic `let mut` declaration followed by initialization in `if`"
|
||||
}
|
||||
|
||||
#[derive(Copy,Clone)]
|
||||
|
|
|
|||
|
|
@ -145,7 +145,7 @@ declare_lint! {
|
|||
declare_lint! {
|
||||
pub WHILE_LET_LOOP,
|
||||
Warn,
|
||||
"`loop { if let { ... } else break }` can be written as a `while let` loop"
|
||||
"`loop { if let { ... } else break }`, which can be written as a `while let` loop"
|
||||
}
|
||||
|
||||
/// **What it does:** Checks for using `collect()` on an iterator without using
|
||||
|
|
@ -186,7 +186,7 @@ declare_lint! {
|
|||
declare_lint! {
|
||||
pub REVERSE_RANGE_LOOP,
|
||||
Warn,
|
||||
"Iterating over an empty range, such as `10..0` or `5..5`"
|
||||
"iteration over an empty range, such as `10..0` or `5..5`"
|
||||
}
|
||||
|
||||
/// **What it does:** Checks `for` loops over slices with an explicit counter
|
||||
|
|
@ -224,7 +224,7 @@ declare_lint! {
|
|||
declare_lint! {
|
||||
pub EMPTY_LOOP,
|
||||
Warn,
|
||||
"empty `loop {}` detected"
|
||||
"empty `loop {}`, which should block or sleep"
|
||||
}
|
||||
|
||||
/// **What it does:** Checks for `while let` expressions on iterators.
|
||||
|
|
|
|||
|
|
@ -16,9 +16,9 @@ use utils::{is_adjusted, match_path, match_trait_method, match_type, paths, snip
|
|||
/// x.map(|e| e.clone());
|
||||
/// ```
|
||||
declare_lint! {
|
||||
pub MAP_CLONE, Warn,
|
||||
"using `.map(|x| x.clone())` to clone an iterator or option's contents (recommends \
|
||||
`.cloned()` instead)"
|
||||
pub MAP_CLONE,
|
||||
Warn,
|
||||
"using `.map(|x| x.clone())` to clone an iterator or option's contents"
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
|
|
|
|||
|
|
@ -27,9 +27,10 @@ use utils::sugg::Sugg;
|
|||
/// }
|
||||
/// ```
|
||||
declare_lint! {
|
||||
pub SINGLE_MATCH, Warn,
|
||||
pub SINGLE_MATCH,
|
||||
Warn,
|
||||
"a match statement with a single nontrivial arm (i.e, where the other arm \
|
||||
is `_ => {}`) is used; recommends `if let` instead"
|
||||
is `_ => {}`) instead of `if let`"
|
||||
}
|
||||
|
||||
/// **What it does:** Checks for matches with a two arms where an `if let` will
|
||||
|
|
@ -47,9 +48,10 @@ declare_lint! {
|
|||
/// }
|
||||
/// ```
|
||||
declare_lint! {
|
||||
pub SINGLE_MATCH_ELSE, Allow,
|
||||
"a match statement with a two arms where the second arm's pattern is a wildcard; \
|
||||
recommends `if let` instead"
|
||||
pub SINGLE_MATCH_ELSE,
|
||||
Allow,
|
||||
"a match statement with a two arms where the second arm's pattern is a wildcard \
|
||||
instead of `if let`"
|
||||
}
|
||||
|
||||
/// **What it does:** Checks for matches where all arms match a reference,
|
||||
|
|
@ -70,9 +72,9 @@ declare_lint! {
|
|||
/// }
|
||||
/// ```
|
||||
declare_lint! {
|
||||
pub MATCH_REF_PATS, Warn,
|
||||
"a match or `if let` has all arms prefixed with `&`; the match expression can be \
|
||||
dereferenced instead"
|
||||
pub MATCH_REF_PATS,
|
||||
Warn,
|
||||
"a match or `if let` with all arms prefixed with `&` instead of deref-ing the match expression"
|
||||
}
|
||||
|
||||
/// **What it does:** Checks for matches where match expression is a `bool`. It
|
||||
|
|
@ -91,8 +93,9 @@ declare_lint! {
|
|||
/// }
|
||||
/// ```
|
||||
declare_lint! {
|
||||
pub MATCH_BOOL, Warn,
|
||||
"a match on boolean expression; recommends `if..else` block instead"
|
||||
pub MATCH_BOOL,
|
||||
Warn,
|
||||
"a match on a boolean expression instead of an `if..else` block"
|
||||
}
|
||||
|
||||
/// **What it does:** Checks for overlapping match arms.
|
||||
|
|
@ -112,7 +115,9 @@ declare_lint! {
|
|||
/// }
|
||||
/// ```
|
||||
declare_lint! {
|
||||
pub MATCH_OVERLAPPING_ARM, Warn, "a match has overlapping arms"
|
||||
pub MATCH_OVERLAPPING_ARM,
|
||||
Warn,
|
||||
"a match with overlapping arms"
|
||||
}
|
||||
|
||||
#[allow(missing_copy_implementations)]
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ use utils::{match_def_path, paths, span_lint};
|
|||
declare_lint! {
|
||||
pub MEM_FORGET,
|
||||
Allow,
|
||||
"`mem::forget` usage on `Drop` types is likely to cause memory leaks"
|
||||
"`mem::forget` usage on `Drop` types, likely to cause memory leaks"
|
||||
}
|
||||
|
||||
pub struct MemForget;
|
||||
|
|
|
|||
|
|
@ -34,7 +34,8 @@ pub struct Pass;
|
|||
/// x.unwrap()
|
||||
/// ```
|
||||
declare_lint! {
|
||||
pub OPTION_UNWRAP_USED, Allow,
|
||||
pub OPTION_UNWRAP_USED,
|
||||
Allow,
|
||||
"using `Option.unwrap()`, which should at least get a better message using `expect()`"
|
||||
}
|
||||
|
||||
|
|
@ -55,7 +56,8 @@ declare_lint! {
|
|||
/// x.unwrap()
|
||||
/// ```
|
||||
declare_lint! {
|
||||
pub RESULT_UNWRAP_USED, Allow,
|
||||
pub RESULT_UNWRAP_USED,
|
||||
Allow,
|
||||
"using `Result.unwrap()`, which might be better handled"
|
||||
}
|
||||
|
||||
|
|
@ -79,7 +81,8 @@ declare_lint! {
|
|||
/// }
|
||||
/// ```
|
||||
declare_lint! {
|
||||
pub SHOULD_IMPLEMENT_TRAIT, Warn,
|
||||
pub SHOULD_IMPLEMENT_TRAIT,
|
||||
Warn,
|
||||
"defining a method that should be implementing a std trait"
|
||||
}
|
||||
|
||||
|
|
@ -107,7 +110,8 @@ declare_lint! {
|
|||
/// }
|
||||
/// ```
|
||||
declare_lint! {
|
||||
pub WRONG_SELF_CONVENTION, Warn,
|
||||
pub WRONG_SELF_CONVENTION,
|
||||
Warn,
|
||||
"defining a method named with an established prefix (like \"into_\") that takes \
|
||||
`self` with the wrong convention"
|
||||
}
|
||||
|
|
@ -128,7 +132,8 @@ declare_lint! {
|
|||
/// }
|
||||
/// ```
|
||||
declare_lint! {
|
||||
pub WRONG_PUB_SELF_CONVENTION, Allow,
|
||||
pub WRONG_PUB_SELF_CONVENTION,
|
||||
Allow,
|
||||
"defining a public method named with an established prefix (like \"into_\") that takes \
|
||||
`self` with the wrong convention"
|
||||
}
|
||||
|
|
@ -145,7 +150,8 @@ declare_lint! {
|
|||
/// x.ok().expect("why did I do this again?")
|
||||
/// ```
|
||||
declare_lint! {
|
||||
pub OK_EXPECT, Warn,
|
||||
pub OK_EXPECT,
|
||||
Warn,
|
||||
"using `ok().expect()`, which gives worse error messages than \
|
||||
calling `expect` directly on the Result"
|
||||
}
|
||||
|
|
@ -162,7 +168,8 @@ declare_lint! {
|
|||
/// x.map(|a| a + 1).unwrap_or(0)
|
||||
/// ```
|
||||
declare_lint! {
|
||||
pub OPTION_MAP_UNWRAP_OR, Warn,
|
||||
pub OPTION_MAP_UNWRAP_OR,
|
||||
Warn,
|
||||
"using `Option.map(f).unwrap_or(a)`, which is more succinctly expressed as \
|
||||
`map_or(a, f)`"
|
||||
}
|
||||
|
|
@ -179,7 +186,8 @@ declare_lint! {
|
|||
/// x.map(|a| a + 1).unwrap_or_else(some_function)
|
||||
/// ```
|
||||
declare_lint! {
|
||||
pub OPTION_MAP_UNWRAP_OR_ELSE, Warn,
|
||||
pub OPTION_MAP_UNWRAP_OR_ELSE,
|
||||
Warn,
|
||||
"using `Option.map(f).unwrap_or_else(g)`, which is more succinctly expressed as \
|
||||
`map_or_else(g, f)`"
|
||||
}
|
||||
|
|
@ -196,7 +204,8 @@ declare_lint! {
|
|||
/// iter.filter(|x| x == 0).next()
|
||||
/// ```
|
||||
declare_lint! {
|
||||
pub FILTER_NEXT, Warn,
|
||||
pub FILTER_NEXT,
|
||||
Warn,
|
||||
"using `filter(p).next()`, which is more succinctly expressed as `.find(p)`"
|
||||
}
|
||||
|
||||
|
|
@ -214,8 +223,10 @@ declare_lint! {
|
|||
/// iter.filter(|x| x == 0).map(|x| x * 2)
|
||||
/// ```
|
||||
declare_lint! {
|
||||
pub FILTER_MAP, Allow,
|
||||
"using combinations of `filter`, `map`, `filter_map` and `flat_map` which can usually be written as a single method call"
|
||||
pub FILTER_MAP,
|
||||
Allow,
|
||||
"using combinations of `filter`, `map`, `filter_map` and `flat_map` which can \
|
||||
usually be written as a single method call"
|
||||
}
|
||||
|
||||
/// **What it does:** Checks for an iterator search (such as `find()`,
|
||||
|
|
@ -231,7 +242,8 @@ declare_lint! {
|
|||
/// iter.find(|x| x == 0).is_some()
|
||||
/// ```
|
||||
declare_lint! {
|
||||
pub SEARCH_IS_SOME, Warn,
|
||||
pub SEARCH_IS_SOME,
|
||||
Warn,
|
||||
"using an iterator search followed by `is_some()`, which is more succinctly \
|
||||
expressed as a call to `any()`"
|
||||
}
|
||||
|
|
@ -249,7 +261,8 @@ declare_lint! {
|
|||
/// name.chars().next() == Some('_')
|
||||
/// ```
|
||||
declare_lint! {
|
||||
pub CHARS_NEXT_CMP, Warn,
|
||||
pub CHARS_NEXT_CMP,
|
||||
Warn,
|
||||
"using `.chars().next()` to check if a string starts with a char"
|
||||
}
|
||||
|
||||
|
|
@ -276,8 +289,9 @@ declare_lint! {
|
|||
/// foo.unwrap_or_default()
|
||||
/// ```
|
||||
declare_lint! {
|
||||
pub OR_FUN_CALL, Warn,
|
||||
"using any `*or` method when the `*or_else` would do"
|
||||
pub OR_FUN_CALL,
|
||||
Warn,
|
||||
"using any `*or` method with a function call, which suggests `*or_else`"
|
||||
}
|
||||
|
||||
/// **What it does:** Checks for usage of `.extend(s)` on a `Vec` to extend the
|
||||
|
|
@ -293,7 +307,8 @@ declare_lint! {
|
|||
/// my_vec.extend(&xs)
|
||||
/// ```
|
||||
declare_lint! {
|
||||
pub EXTEND_FROM_SLICE, Warn,
|
||||
pub EXTEND_FROM_SLICE,
|
||||
Warn,
|
||||
"`.extend_from_slice(_)` is a faster way to extend a Vec by a slice"
|
||||
}
|
||||
|
||||
|
|
@ -309,7 +324,9 @@ declare_lint! {
|
|||
/// 42u64.clone()
|
||||
/// ```
|
||||
declare_lint! {
|
||||
pub CLONE_ON_COPY, Warn, "using `clone` on a `Copy` type"
|
||||
pub CLONE_ON_COPY,
|
||||
Warn,
|
||||
"using `clone` on a `Copy` type"
|
||||
}
|
||||
|
||||
/// **What it does:** Checks for usage of `.clone()` on an `&&T`.
|
||||
|
|
@ -329,7 +346,9 @@ declare_lint! {
|
|||
/// }
|
||||
/// ```
|
||||
declare_lint! {
|
||||
pub CLONE_DOUBLE_REF, Warn, "using `clone` on `&&T`"
|
||||
pub CLONE_DOUBLE_REF,
|
||||
Warn,
|
||||
"using `clone` on `&&T`"
|
||||
}
|
||||
|
||||
/// **What it does:** Checks for `new` not returning `Self`.
|
||||
|
|
@ -347,7 +366,9 @@ declare_lint! {
|
|||
/// }
|
||||
/// ```
|
||||
declare_lint! {
|
||||
pub NEW_RET_NO_SELF, Warn, "not returning `Self` in a `new` method"
|
||||
pub NEW_RET_NO_SELF,
|
||||
Warn,
|
||||
"not returning `Self` in a `new` method"
|
||||
}
|
||||
|
||||
/// **What it does:** Checks for string methods that receive a single-character
|
||||
|
|
|
|||
|
|
@ -20,7 +20,8 @@ use utils::{match_def_path, 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! {
|
||||
pub MIN_MAX, Warn,
|
||||
pub MIN_MAX,
|
||||
Warn,
|
||||
"`min(_, max(_, _))` (or vice versa) with bounds clamping the result to a constant"
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,10 +35,9 @@ use utils::sugg::Sugg;
|
|||
/// fn foo(ref x: u8) -> bool { .. }
|
||||
/// ```
|
||||
declare_lint! {
|
||||
pub TOPLEVEL_REF_ARG, Warn,
|
||||
"An entire binding was declared as `ref`, in a function argument (`fn foo(ref x: Bar)`), \
|
||||
or a `let` statement (`let ref x = foo()`). In such cases, it is preferred to take \
|
||||
references with `&`."
|
||||
pub TOPLEVEL_REF_ARG,
|
||||
Warn,
|
||||
"an entire binding declared as `ref`, in a function argument or a `let` statement"
|
||||
}
|
||||
|
||||
#[allow(missing_copy_implementations)]
|
||||
|
|
@ -111,8 +110,11 @@ impl LateLintPass for TopLevelRefPass {
|
|||
/// ```rust
|
||||
/// x == NAN
|
||||
/// ```
|
||||
declare_lint!(pub CMP_NAN, Deny,
|
||||
"comparisons to NAN (which will always return false, which is probably not intended)");
|
||||
declare_lint! {
|
||||
pub CMP_NAN,
|
||||
Deny,
|
||||
"comparisons to NAN, which will always return false, probably not intended"
|
||||
}
|
||||
|
||||
#[derive(Copy,Clone)]
|
||||
pub struct CmpNan;
|
||||
|
|
@ -165,10 +167,11 @@ fn check_nan(cx: &LateContext, path: &Path, span: Span) {
|
|||
/// y == 1.23f64
|
||||
/// y != x // where both are floats
|
||||
/// ```
|
||||
declare_lint!(pub FLOAT_CMP, Warn,
|
||||
"using `==` or `!=` on float values (as floating-point operations \
|
||||
usually involve rounding errors, it is always better to check for approximate \
|
||||
equality within small bounds)");
|
||||
declare_lint! {
|
||||
pub FLOAT_CMP,
|
||||
Warn,
|
||||
"using `==` or `!=` on float values instead of comparing difference with an epsilon"
|
||||
}
|
||||
|
||||
#[derive(Copy,Clone)]
|
||||
pub struct FloatCmp;
|
||||
|
|
@ -257,8 +260,11 @@ fn is_float(cx: &LateContext, expr: &Expr) -> bool {
|
|||
/// ```rust
|
||||
/// x.to_owned() == y
|
||||
/// ```
|
||||
declare_lint!(pub CMP_OWNED, Warn,
|
||||
"creating owned instances for comparing with others, e.g. `x == \"foo\".to_string()`");
|
||||
declare_lint! {
|
||||
pub CMP_OWNED,
|
||||
Warn,
|
||||
"creating owned instances for comparing with others, e.g. `x == \"foo\".to_string()`"
|
||||
}
|
||||
|
||||
#[derive(Copy,Clone)]
|
||||
pub struct CmpOwned;
|
||||
|
|
@ -353,7 +359,11 @@ fn is_str_arg(cx: &LateContext, args: &[P<Expr>]) -> bool {
|
|||
/// ```rust
|
||||
/// x % 1
|
||||
/// ```
|
||||
declare_lint!(pub MODULO_ONE, Warn, "taking a number modulo 1, which always returns 0");
|
||||
declare_lint! {
|
||||
pub MODULO_ONE,
|
||||
Warn,
|
||||
"taking a number modulo 1, which always returns 0"
|
||||
}
|
||||
|
||||
#[derive(Copy,Clone)]
|
||||
pub struct ModuloOne;
|
||||
|
|
@ -389,7 +399,11 @@ impl LateLintPass for ModuloOne {
|
|||
/// y @ _ => (), // easier written as `y`,
|
||||
/// }
|
||||
/// ```
|
||||
declare_lint!(pub REDUNDANT_PATTERN, Warn, "using `name @ _` in a pattern");
|
||||
declare_lint! {
|
||||
pub REDUNDANT_PATTERN,
|
||||
Warn,
|
||||
"using `name @ _` in a pattern"
|
||||
}
|
||||
|
||||
#[derive(Copy,Clone)]
|
||||
pub struct PatternPass;
|
||||
|
|
@ -431,8 +445,11 @@ impl LateLintPass for PatternPass {
|
|||
/// let y = _x + 1; // Here we are using `_x`, even though it has a leading underscore.
|
||||
/// // We should rename `_x` to `x`
|
||||
/// ```
|
||||
declare_lint!(pub USED_UNDERSCORE_BINDING, Allow,
|
||||
"using a binding which is prefixed with an underscore");
|
||||
declare_lint! {
|
||||
pub USED_UNDERSCORE_BINDING,
|
||||
Allow,
|
||||
"using a binding which is prefixed with an underscore"
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct UsedUnderscoreBinding;
|
||||
|
|
|
|||
|
|
@ -18,8 +18,9 @@ use utils::{span_lint, span_help_and_lint, snippet, snippet_opt, span_lint_and_t
|
|||
/// let { a: _, b: ref b, c: _ } = ..
|
||||
/// ```
|
||||
declare_lint! {
|
||||
pub UNNEEDED_FIELD_PATTERN, Warn,
|
||||
"Struct fields are bound to a wildcard instead of using `..`"
|
||||
pub UNNEEDED_FIELD_PATTERN,
|
||||
Warn,
|
||||
"struct fields bound to a wildcard instead of using `..`"
|
||||
}
|
||||
|
||||
/// **What it does:** Checks for function arguments having the similar names
|
||||
|
|
@ -34,8 +35,9 @@ declare_lint! {
|
|||
/// fn foo(a: i32, _a: i32) {}
|
||||
/// ```
|
||||
declare_lint! {
|
||||
pub DUPLICATE_UNDERSCORE_ARGUMENT, Warn,
|
||||
"Function arguments having names which only differ by an underscore"
|
||||
pub DUPLICATE_UNDERSCORE_ARGUMENT,
|
||||
Warn,
|
||||
"function arguments having names which only differ by an underscore"
|
||||
}
|
||||
|
||||
/// **What it does:** Detects closures called in the same expression where they are defined.
|
||||
|
|
@ -49,8 +51,9 @@ declare_lint! {
|
|||
/// (|| 42)()
|
||||
/// ```
|
||||
declare_lint! {
|
||||
pub REDUNDANT_CLOSURE_CALL, Warn,
|
||||
"Closures should not be called in the expression they are defined"
|
||||
pub REDUNDANT_CLOSURE_CALL,
|
||||
Warn,
|
||||
"throwaway closures called in the expression they are defined"
|
||||
}
|
||||
|
||||
/// **What it does:** Detects expressions of the form `--x`.
|
||||
|
|
@ -65,8 +68,9 @@ declare_lint! {
|
|||
/// --x;
|
||||
/// ```
|
||||
declare_lint! {
|
||||
pub DOUBLE_NEG, Warn,
|
||||
"`--x` is a double negation of `x` and not a pre-decrement as in C or C++"
|
||||
pub DOUBLE_NEG,
|
||||
Warn,
|
||||
"`--x`, which is a double negation of `x` and not a pre-decrement as in C/C++"
|
||||
}
|
||||
|
||||
/// **What it does:** Warns on hexadecimal literals with mixed-case letter digits.
|
||||
|
|
@ -80,8 +84,9 @@ declare_lint! {
|
|||
/// let y = 0x1a9BAcD;
|
||||
/// ```
|
||||
declare_lint! {
|
||||
pub MIXED_CASE_HEX_LITERALS, Warn,
|
||||
"letter digits in hex literals should be either completely upper- or lowercased"
|
||||
pub MIXED_CASE_HEX_LITERALS,
|
||||
Warn,
|
||||
"hex literals whose letter digits are not consistently upper- or lowercased"
|
||||
}
|
||||
|
||||
/// **What it does:** Warns if literal suffixes are not separated by an underscore.
|
||||
|
|
@ -95,8 +100,9 @@ declare_lint! {
|
|||
/// let y = 123832i32;
|
||||
/// ```
|
||||
declare_lint! {
|
||||
pub UNSEPARATED_LITERAL_SUFFIX, Allow,
|
||||
"literal suffixes should be separated with an underscore"
|
||||
pub UNSEPARATED_LITERAL_SUFFIX,
|
||||
Allow,
|
||||
"literals whose suffix is not separated by an underscore"
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ use utils::span_lint;
|
|||
declare_lint! {
|
||||
pub UNNECESSARY_MUT_PASSED,
|
||||
Warn,
|
||||
"an argument is passed as a mutable reference although the function/method only demands an \
|
||||
"an argument passed as a mutable reference although the callee only demands an \
|
||||
immutable reference"
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -44,8 +44,7 @@ declare_lint! {
|
|||
declare_lint! {
|
||||
pub BOOL_COMPARISON,
|
||||
Warn,
|
||||
"comparing a variable to a boolean, e.g. \
|
||||
`if x == true`"
|
||||
"comparing a variable to a boolean, e.g. `if x == true`"
|
||||
}
|
||||
|
||||
#[derive(Copy,Clone)]
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ use utils::span_lint;
|
|||
declare_lint! {
|
||||
pub NEG_MULTIPLY,
|
||||
Warn,
|
||||
"Warns on multiplying integers with -1"
|
||||
"multiplying integers with -1"
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
|
|
|
|||
|
|
@ -14,8 +14,11 @@ use utils::span_lint;
|
|||
/// a + b < a
|
||||
/// ```
|
||||
|
||||
declare_lint!(pub OVERFLOW_CHECK_CONDITIONAL, Warn,
|
||||
"Using overflow checks which are likely to panic");
|
||||
declare_lint! {
|
||||
pub OVERFLOW_CHECK_CONDITIONAL,
|
||||
Warn,
|
||||
"overflow checks inspired by C which are likely to panic"
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct OverflowCheckConditional;
|
||||
|
|
|
|||
|
|
@ -18,7 +18,9 @@ use utils::{is_direct_expn_of, match_path, paths, span_lint};
|
|||
/// panic!("This `panic!` is probably missing a parameter there: {}");
|
||||
/// ```
|
||||
declare_lint! {
|
||||
pub PANIC_PARAMS, Warn, "missing parameters in `panic!`"
|
||||
pub PANIC_PARAMS,
|
||||
Warn,
|
||||
"missing parameters in `panic!` calls"
|
||||
}
|
||||
|
||||
#[allow(missing_copy_implementations)]
|
||||
|
|
|
|||
|
|
@ -19,8 +19,9 @@ use utils::{span_lint, snippet};
|
|||
/// * `1 << 2 + 3` equals 32, while `(1 << 2) + 3` equals 7
|
||||
/// * `-1i32.abs()` equals -1, while `(-1i32).abs()` equals 1
|
||||
declare_lint! {
|
||||
pub PRECEDENCE, Warn,
|
||||
"catches operations where precedence may be unclear"
|
||||
pub PRECEDENCE,
|
||||
Warn,
|
||||
"operations where precedence may be unclear"
|
||||
}
|
||||
|
||||
#[derive(Copy,Clone)]
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ declare_lint! {
|
|||
declare_lint! {
|
||||
pub USE_DEBUG,
|
||||
Allow,
|
||||
"use `Debug`-based formatting"
|
||||
"use of `Debug`-based formatting"
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
|
|
|
|||
|
|
@ -23,8 +23,7 @@ use utils::{match_type, paths, span_lint};
|
|||
declare_lint! {
|
||||
pub PTR_ARG,
|
||||
Warn,
|
||||
"fn arguments of the type `&Vec<...>` or `&String`, suggesting to use `&[...]` or `&str` \
|
||||
instead, respectively"
|
||||
"arguments of the type `&Vec<...>` (instead of `&[...]`) or `&String` (instead of `&str`)"
|
||||
}
|
||||
|
||||
#[derive(Copy,Clone)]
|
||||
|
|
|
|||
|
|
@ -17,8 +17,9 @@ use utils::higher;
|
|||
/// for x in (5..5).step_by(0) { .. }
|
||||
/// ```
|
||||
declare_lint! {
|
||||
pub RANGE_STEP_BY_ZERO, Warn,
|
||||
"using Range::step_by(0), which produces an infinite iterator"
|
||||
pub RANGE_STEP_BY_ZERO,
|
||||
Warn,
|
||||
"using `Range::step_by(0)`, which produces an infinite iterator"
|
||||
}
|
||||
/// **What it does:** Checks for zipping a collection with the range of `0.._.len()`.
|
||||
///
|
||||
|
|
@ -31,8 +32,9 @@ declare_lint! {
|
|||
/// x.iter().zip(0..x.len())
|
||||
/// ```
|
||||
declare_lint! {
|
||||
pub RANGE_ZIP_WITH_LEN, Warn,
|
||||
"zipping iterator with a range when enumerate() would do"
|
||||
pub RANGE_ZIP_WITH_LEN,
|
||||
Warn,
|
||||
"zipping iterator with a range when `enumerate()` would do"
|
||||
}
|
||||
|
||||
#[derive(Copy,Clone)]
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ use utils::{is_expn_of, match_def_path, match_type, paths, span_lint, span_help_
|
|||
declare_lint! {
|
||||
pub INVALID_REGEX,
|
||||
Deny,
|
||||
"finds invalid regular expressions"
|
||||
"invalid regular expressions"
|
||||
}
|
||||
|
||||
/// **What it does:** Checks for trivial [regex] creation (with `Regex::new`,
|
||||
|
|
@ -48,7 +48,7 @@ declare_lint! {
|
|||
declare_lint! {
|
||||
pub TRIVIAL_REGEX,
|
||||
Warn,
|
||||
"finds trivial regular expressions"
|
||||
"trivial regular expressions"
|
||||
}
|
||||
|
||||
/// **What it does:** Checks for usage of `regex!(_)` which (as of now) is
|
||||
|
|
@ -67,7 +67,7 @@ declare_lint! {
|
|||
declare_lint! {
|
||||
pub REGEX_MACRO,
|
||||
Warn,
|
||||
"finds use of `regex!(_)`, suggests `Regex::new(_)` instead"
|
||||
"use of `regex!(_)` instead of `Regex::new(_)`"
|
||||
}
|
||||
|
||||
#[derive(Clone, Default)]
|
||||
|
|
|
|||
|
|
@ -20,7 +20,8 @@ use utils::{span_note_and_lint, span_lint_and_then, snippet_opt, match_path_ast,
|
|||
/// fn foo(x: usize) { return x; }
|
||||
/// ```
|
||||
declare_lint! {
|
||||
pub NEEDLESS_RETURN, Warn,
|
||||
pub NEEDLESS_RETURN,
|
||||
Warn,
|
||||
"using a return statement like `return expr;` where an expression would suffice"
|
||||
}
|
||||
|
||||
|
|
@ -39,7 +40,8 @@ declare_lint! {
|
|||
/// { let x = ..; x }
|
||||
/// ```
|
||||
declare_lint! {
|
||||
pub LET_AND_RETURN, Warn,
|
||||
pub LET_AND_RETURN,
|
||||
Warn,
|
||||
"creating a let-binding and then immediately returning it like `let x = expr; x` at \
|
||||
the end of a block"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,8 +11,9 @@ use utils::{span_lint, get_trait_def_id, paths};
|
|||
///
|
||||
/// **Example:** Implementing `Visitor::visit_string` but not `Visitor::visit_str`.
|
||||
declare_lint! {
|
||||
pub SERDE_API_MISUSE, Warn,
|
||||
"Various things that will negatively affect your serde experience"
|
||||
pub SERDE_API_MISUSE,
|
||||
Warn,
|
||||
"various things that will negatively affect your serde experience"
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,8 @@ use utils::{higher, in_external_macro, snippet, span_lint_and_then};
|
|||
/// let x = &x;
|
||||
/// ```
|
||||
declare_lint! {
|
||||
pub SHADOW_SAME, Allow,
|
||||
pub SHADOW_SAME,
|
||||
Allow,
|
||||
"rebinding a name to itself, e.g. `let mut x = &mut x`"
|
||||
}
|
||||
|
||||
|
|
@ -42,9 +43,10 @@ declare_lint! {
|
|||
/// let x = x + 1;
|
||||
/// ```
|
||||
declare_lint! {
|
||||
pub SHADOW_REUSE, Allow,
|
||||
pub SHADOW_REUSE,
|
||||
Allow,
|
||||
"rebinding a name to an expression that re-uses the original value, e.g. \
|
||||
`let x = x + 1`"
|
||||
`let x = x + 1`"
|
||||
}
|
||||
|
||||
/// **What it does:** Checks for bindings that shadow other bindings already in
|
||||
|
|
@ -64,8 +66,9 @@ declare_lint! {
|
|||
/// let x = y; let x = z; // shadows the earlier binding
|
||||
/// ```
|
||||
declare_lint! {
|
||||
pub SHADOW_UNRELATED, Allow,
|
||||
"The name is re-bound without even using the original value"
|
||||
pub SHADOW_UNRELATED,
|
||||
Allow,
|
||||
"rebinding a name without even using the original value"
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ use utils::{match_type, paths, span_lint, span_lint_and_then, walk_ptrs_ty, get_
|
|||
declare_lint! {
|
||||
pub STRING_ADD_ASSIGN,
|
||||
Allow,
|
||||
"using `x = x + ..` where x is a `String`; suggests using `push_str()` instead"
|
||||
"using `x = x + ..` where x is a `String` instead of `push_str()`"
|
||||
}
|
||||
|
||||
/// **What it does:** Checks for all instances of `x + _` where `x` is of type
|
||||
|
|
@ -49,7 +49,7 @@ declare_lint! {
|
|||
declare_lint! {
|
||||
pub STRING_ADD,
|
||||
Allow,
|
||||
"using `x + ..` where x is a `String`; suggests using `push_str()` instead"
|
||||
"using `x + ..` where x is a `String` instead of `push_str()`"
|
||||
}
|
||||
|
||||
/// **What it does:** Checks for the `as_bytes` method called on string literals
|
||||
|
|
@ -67,7 +67,7 @@ declare_lint! {
|
|||
declare_lint! {
|
||||
pub STRING_LIT_AS_BYTES,
|
||||
Warn,
|
||||
"calling `as_bytes` on a string literal; suggests using a byte string literal instead"
|
||||
"calling `as_bytes` on a string literal instead of using a byte string literal"
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ use utils::sugg::Sugg;
|
|||
declare_lint! {
|
||||
pub MANUAL_SWAP,
|
||||
Warn,
|
||||
"manual swap"
|
||||
"manual swap of two variables"
|
||||
}
|
||||
|
||||
/// **What it does:** Checks for `foo = bar; bar = foo` sequences.
|
||||
|
|
|
|||
|
|
@ -29,7 +29,8 @@ pub struct TypePass;
|
|||
/// }
|
||||
/// ```
|
||||
declare_lint! {
|
||||
pub BOX_VEC, Warn,
|
||||
pub BOX_VEC,
|
||||
Warn,
|
||||
"usage of `Box<Vec<T>>`, vector elements are already on the heap"
|
||||
}
|
||||
|
||||
|
|
@ -56,7 +57,8 @@ declare_lint! {
|
|||
/// let x = LinkedList::new();
|
||||
/// ```
|
||||
declare_lint! {
|
||||
pub LINKEDLIST, Warn,
|
||||
pub LINKEDLIST,
|
||||
Warn,
|
||||
"usage of LinkedList, usually a vector is faster, or a more specialized data \
|
||||
structure like a VecDeque"
|
||||
}
|
||||
|
|
@ -117,7 +119,8 @@ pub struct LetPass;
|
|||
/// let x = { 1; };
|
||||
/// ```
|
||||
declare_lint! {
|
||||
pub LET_UNIT_VALUE, Warn,
|
||||
pub LET_UNIT_VALUE,
|
||||
Warn,
|
||||
"creating a let binding to a value of unit type, which usually can't be used afterwards"
|
||||
}
|
||||
|
||||
|
|
@ -169,8 +172,9 @@ impl LateLintPass for LetPass {
|
|||
/// { foo(); bar(); baz(); }
|
||||
/// ```
|
||||
declare_lint! {
|
||||
pub UNIT_CMP, Warn,
|
||||
"comparing unit values (which is always `true` or `false`, respectively)"
|
||||
pub UNIT_CMP,
|
||||
Warn,
|
||||
"comparing unit values"
|
||||
}
|
||||
|
||||
#[allow(missing_copy_implementations)]
|
||||
|
|
@ -227,7 +231,8 @@ pub struct CastPass;
|
|||
/// let x = u64::MAX; x as f64
|
||||
/// ```
|
||||
declare_lint! {
|
||||
pub CAST_PRECISION_LOSS, Allow,
|
||||
pub CAST_PRECISION_LOSS,
|
||||
Allow,
|
||||
"casts that cause loss of precision, e.g `x as f32` where `x: u64`"
|
||||
}
|
||||
|
||||
|
|
@ -247,7 +252,8 @@ declare_lint! {
|
|||
/// y as u64 // will return 18446744073709551615
|
||||
/// ```
|
||||
declare_lint! {
|
||||
pub CAST_SIGN_LOSS, Allow,
|
||||
pub CAST_SIGN_LOSS,
|
||||
Allow,
|
||||
"casts from signed types to unsigned types, e.g `x as u32` where `x: i32`"
|
||||
}
|
||||
|
||||
|
|
@ -266,8 +272,10 @@ declare_lint! {
|
|||
/// fn as_u8(x: u64) -> u8 { x as u8 }
|
||||
/// ```
|
||||
declare_lint! {
|
||||
pub CAST_POSSIBLE_TRUNCATION, Allow,
|
||||
"casts that may cause truncation of the value, e.g `x as u8` where `x: u32`, or `x as i32` where `x: f32`"
|
||||
pub CAST_POSSIBLE_TRUNCATION,
|
||||
Allow,
|
||||
"casts that may cause truncation of the value, e.g `x as u8` where `x: u32`, \
|
||||
or `x as i32` where `x: f32`"
|
||||
}
|
||||
|
||||
/// **What it does:** Checks for casts from an unsigned type to a signed type of
|
||||
|
|
@ -288,8 +296,10 @@ declare_lint! {
|
|||
/// u32::MAX as i32 // will yield a value of `-1`
|
||||
/// ```
|
||||
declare_lint! {
|
||||
pub CAST_POSSIBLE_WRAP, Allow,
|
||||
"casts that may cause wrapping around the value, e.g `x as i32` where `x: u32` and `x > i32::MAX`"
|
||||
pub CAST_POSSIBLE_WRAP,
|
||||
Allow,
|
||||
"casts that may cause wrapping around the value, e.g `x as i32` where `x: u32` \
|
||||
and `x > i32::MAX`"
|
||||
}
|
||||
|
||||
/// Returns the size in bits of an integral type.
|
||||
|
|
@ -494,8 +504,9 @@ impl LateLintPass for CastPass {
|
|||
/// struct Foo { inner: Rc<Vec<Vec<Box<(u32, u32, u32, u32)>>>> }
|
||||
/// ```
|
||||
declare_lint! {
|
||||
pub TYPE_COMPLEXITY, Warn,
|
||||
"usage of very complex types; recommends factoring out parts into `type` definitions"
|
||||
pub TYPE_COMPLEXITY,
|
||||
Warn,
|
||||
"usage of very complex types that might be better factored into `type` definitions"
|
||||
}
|
||||
|
||||
#[allow(missing_copy_implementations)]
|
||||
|
|
@ -644,8 +655,9 @@ impl<'v> Visitor<'v> for TypeComplexityVisitor {
|
|||
/// 'x' as u8
|
||||
/// ```
|
||||
declare_lint! {
|
||||
pub CHAR_LIT_AS_U8, Warn,
|
||||
"Casting a character literal to u8"
|
||||
pub CHAR_LIT_AS_U8,
|
||||
Warn,
|
||||
"casting a character literal to u8"
|
||||
}
|
||||
|
||||
pub struct CharLitAsU8;
|
||||
|
|
@ -695,9 +707,9 @@ impl LateLintPass for CharLitAsU8 {
|
|||
/// 100 > std::i32::MAX
|
||||
/// ```
|
||||
declare_lint! {
|
||||
pub ABSURD_EXTREME_COMPARISONS, Warn,
|
||||
"a comparison involving a maximum or minimum value involves a case that is always \
|
||||
true or always false"
|
||||
pub ABSURD_EXTREME_COMPARISONS,
|
||||
Warn,
|
||||
"a comparison with a maximum or minimum value that is always true or false"
|
||||
}
|
||||
|
||||
pub struct AbsurdExtremeComparisons;
|
||||
|
|
@ -872,7 +884,8 @@ impl LateLintPass for AbsurdExtremeComparisons {
|
|||
/// let x : u8 = ...; (x as u32) > 300
|
||||
/// ```
|
||||
declare_lint! {
|
||||
pub INVALID_UPCAST_COMPARISONS, Allow,
|
||||
pub INVALID_UPCAST_COMPARISONS,
|
||||
Allow,
|
||||
"a comparison involving an upcast which is always true or false"
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,8 @@ use utils::{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! {
|
||||
pub ZERO_WIDTH_SPACE, Deny,
|
||||
pub ZERO_WIDTH_SPACE,
|
||||
Deny,
|
||||
"using a zero-width space in a string literal, which is confusing"
|
||||
}
|
||||
|
||||
|
|
@ -33,9 +34,10 @@ declare_lint! {
|
|||
/// let x = "Hä?"
|
||||
/// ```
|
||||
declare_lint! {
|
||||
pub NON_ASCII_LITERAL, Allow,
|
||||
"using any literal non-ASCII chars in a string literal; suggests \
|
||||
using the `\\u` escape instead"
|
||||
pub NON_ASCII_LITERAL,
|
||||
Allow,
|
||||
"using any literal non-ASCII chars in a string literal instead of \
|
||||
using the `\\u` escape"
|
||||
}
|
||||
|
||||
/// **What it does:** Checks for string literals that contain Unicode in a form
|
||||
|
|
@ -50,7 +52,8 @@ 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! {
|
||||
pub UNICODE_NOT_NFC, Allow,
|
||||
pub UNICODE_NOT_NFC,
|
||||
Allow,
|
||||
"using a unicode literal not in NFC normal form (see \
|
||||
[unicode tr15](http://www.unicode.org/reports/tr15/) for further information)"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ use utils::span_lint;
|
|||
declare_lint! {
|
||||
pub UNSAFE_REMOVED_FROM_NAME,
|
||||
Warn,
|
||||
"unsafe removed from name"
|
||||
"`unsafe` removed from API names on import"
|
||||
}
|
||||
|
||||
pub struct UnsafeNameRemoval;
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ use utils::{in_macro, span_lint};
|
|||
declare_lint! {
|
||||
pub UNUSED_LABEL,
|
||||
Warn,
|
||||
"unused label"
|
||||
"unused labels"
|
||||
}
|
||||
|
||||
pub struct UnusedLabel;
|
||||
|
|
|
|||
|
|
@ -11,8 +11,9 @@ use syntax::ast::*;
|
|||
///
|
||||
/// **Example:** Wrong ordering of the util::paths constants.
|
||||
declare_lint! {
|
||||
pub CLIPPY_LINTS_INTERNAL, Allow,
|
||||
"Various things that will negatively affect your clippy experience"
|
||||
pub CLIPPY_LINTS_INTERNAL,
|
||||
Allow,
|
||||
"various things that will negatively affect your clippy experience"
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue