Auto merge of #7813 - xFrednet:6492-lint-version, r=flip1995
Add Clippy version to Clippy's lint list Hey, hey, the semester is finally over, and I wanted to get back into hacking on Clippy. It has also been some time since our metadata collection monster has been feed. So, this PR adds a new attribute `clippy::version` to document which version a lint was stabilized. I considered using `git blame` but that would be very hacky and probably not accurate. I'm also thinking that this attribute can be used to have a `clippy::nightly` lint group which is allow-by-default that delays setting the actual lint group until the defined version is reached. Just something to consider regarding #6623 🙃 This PR only adds the version to 4 lints to keep it reviewable. I'll do a followup PR to add the version to other lints if the implementation is accepted 🙃  Also, mobile approved xD  --- r? `@flip1995` cc: #7172 closes: #6492 changelog: [Clippy's lint list](https://rust-lang.github.io/rust-clippy/master/index.html) now displays the version a lint was added. 🎉 --- Example lint declaration after this update: ```rs declare_clippy_lint! { /// [...] /// /// ### Example /// ```rust /// // Bad /// let x = 3.14; /// // Good /// let x = std::f32::consts::PI; /// ``` #[clippy::version = "pre 1.29.0"] pub APPROX_CONSTANT, correctness, "the approximate of a known float constant (in `std::fXX::consts`)" } ```
This commit is contained in:
commit
3bfe98d372
271 changed files with 873 additions and 42 deletions
|
|
@ -12,6 +12,7 @@ opener = "0.5"
|
|||
regex = "1.5"
|
||||
shell-escape = "0.1"
|
||||
walkdir = "2.3"
|
||||
cargo_metadata = "0.14"
|
||||
|
||||
[features]
|
||||
deny-warnings = []
|
||||
|
|
|
|||
|
|
@ -132,6 +132,18 @@ fn to_camel_case(name: &str) -> String {
|
|||
.collect()
|
||||
}
|
||||
|
||||
fn get_stabilisation_version() -> String {
|
||||
let mut command = cargo_metadata::MetadataCommand::new();
|
||||
command.no_deps();
|
||||
if let Ok(metadata) = command.exec() {
|
||||
if let Some(pkg) = metadata.packages.iter().find(|pkg| pkg.name == "clippy") {
|
||||
return format!("{}.{}.0", pkg.version.minor, pkg.version.patch);
|
||||
}
|
||||
}
|
||||
|
||||
String::from("<TODO set version(see doc/adding_lints.md)>")
|
||||
}
|
||||
|
||||
fn get_test_file_contents(lint_name: &str, header_commands: Option<&str>) -> String {
|
||||
let mut contents = format!(
|
||||
indoc! {"
|
||||
|
|
@ -178,6 +190,7 @@ fn get_lint_file_contents(lint: &LintData<'_>, enable_msrv: bool) -> String {
|
|||
},
|
||||
};
|
||||
|
||||
let version = get_stabilisation_version();
|
||||
let lint_name = lint.name;
|
||||
let category = lint.category;
|
||||
let name_camel = to_camel_case(lint.name);
|
||||
|
|
@ -212,7 +225,7 @@ fn get_lint_file_contents(lint: &LintData<'_>, enable_msrv: bool) -> String {
|
|||
});
|
||||
|
||||
result.push_str(&format!(
|
||||
indoc! {"
|
||||
indoc! {r#"
|
||||
declare_clippy_lint! {{
|
||||
/// ### What it does
|
||||
///
|
||||
|
|
@ -226,11 +239,13 @@ fn get_lint_file_contents(lint: &LintData<'_>, enable_msrv: bool) -> String {
|
|||
/// ```rust
|
||||
/// // example code which does not raise clippy warning
|
||||
/// ```
|
||||
#[clippy::version = "{version}"]
|
||||
pub {name_upper},
|
||||
{category},
|
||||
\"default lint description\"
|
||||
"default lint description"
|
||||
}}
|
||||
"},
|
||||
"#},
|
||||
version = version,
|
||||
name_upper = name_upper,
|
||||
category = category,
|
||||
));
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ static DEC_CLIPPY_LINT_RE: SyncLazy<Regex> = SyncLazy::new(|| {
|
|||
r#"(?x)
|
||||
declare_clippy_lint!\s*[\{(]
|
||||
(?:\s+///.*)*
|
||||
(?:\s*\#\[clippy::version\s*=\s*"[^"]*"\])?
|
||||
\s+pub\s+(?P<name>[A-Z_][A-Z_0-9]*)\s*,\s*
|
||||
(?P<cat>[a-z_]+)\s*,\s*
|
||||
"(?P<desc>(?:[^"\\]+|\\(?s).(?-s))*)"\s*[})]
|
||||
|
|
@ -31,6 +32,7 @@ static DEC_DEPRECATED_LINT_RE: SyncLazy<Regex> = SyncLazy::new(|| {
|
|||
r#"(?x)
|
||||
declare_deprecated_lint!\s*[{(]\s*
|
||||
(?:\s+///.*)*
|
||||
(?:\s*\#\[clippy::version\s*=\s*"[^"]*"\])?
|
||||
\s+pub\s+(?P<name>[A-Z_][A-Z_0-9]*)\s*,\s*
|
||||
"(?P<desc>(?:[^"\\]+|\\(?s).(?-s))*)"\s*[})]
|
||||
"#,
|
||||
|
|
@ -495,6 +497,7 @@ fn test_parse_contents() {
|
|||
let result: Vec<Lint> = parse_contents(
|
||||
r#"
|
||||
declare_clippy_lint! {
|
||||
#[clippy::version = "Hello Clippy!"]
|
||||
pub PTR_ARG,
|
||||
style,
|
||||
"really long \
|
||||
|
|
@ -502,6 +505,7 @@ declare_clippy_lint! {
|
|||
}
|
||||
|
||||
declare_clippy_lint!{
|
||||
#[clippy::version = "Test version"]
|
||||
pub DOC_MARKDOWN,
|
||||
pedantic,
|
||||
"single line"
|
||||
|
|
@ -509,6 +513,7 @@ declare_clippy_lint!{
|
|||
|
||||
/// some doc comment
|
||||
declare_deprecated_lint! {
|
||||
#[clippy::version = "I'm a version"]
|
||||
pub SHOULD_ASSERT_EQ,
|
||||
"`assert!()` will be more flexible with RFC 2011"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ declare_clippy_lint! {
|
|||
/// if vec.len() <= 0 {}
|
||||
/// if 100 > i32::MAX {}
|
||||
/// ```
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub ABSURD_EXTREME_COMPARISONS,
|
||||
correctness,
|
||||
"a comparison with a maximum or minimum value that is always true or false"
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ declare_clippy_lint! {
|
|||
/// let x = std::f32::consts::PI;
|
||||
/// let y = std::f64::consts::FRAC_1_PI;
|
||||
/// ```
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub APPROX_CONSTANT,
|
||||
correctness,
|
||||
"the approximate of a known float constant (in `std::fXX::consts`)"
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ declare_clippy_lint! {
|
|||
/// # let a = 0;
|
||||
/// a + 1;
|
||||
/// ```
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub INTEGER_ARITHMETIC,
|
||||
restriction,
|
||||
"any integer arithmetic expression which could overflow or panic"
|
||||
|
|
@ -43,6 +44,7 @@ declare_clippy_lint! {
|
|||
/// # let a = 0.0;
|
||||
/// a + 1.0;
|
||||
/// ```
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub FLOAT_ARITHMETIC,
|
||||
restriction,
|
||||
"any floating-point arithmetic statement"
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ declare_clippy_lint! {
|
|||
/// f(a.try_into().expect("Unexpected u16 overflow in f"));
|
||||
/// ```
|
||||
///
|
||||
#[clippy::version = "1.41.0"]
|
||||
pub AS_CONVERSIONS,
|
||||
restriction,
|
||||
"using a potentially dangerous silent `as` conversion"
|
||||
|
|
|
|||
|
|
@ -75,6 +75,7 @@ declare_clippy_lint! {
|
|||
/// asm!("lea ({}), {}", in(reg) ptr, lateout(reg) _, options(att_syntax));
|
||||
/// # }
|
||||
/// ```
|
||||
#[clippy::version = "1.49.0"]
|
||||
pub INLINE_ASM_X86_INTEL_SYNTAX,
|
||||
restriction,
|
||||
"prefer AT&T x86 assembly syntax"
|
||||
|
|
@ -111,6 +112,7 @@ declare_clippy_lint! {
|
|||
/// asm!("lea {}, [{}]", lateout(reg) _, in(reg) ptr);
|
||||
/// # }
|
||||
/// ```
|
||||
#[clippy::version = "1.49.0"]
|
||||
pub INLINE_ASM_X86_ATT_SYNTAX,
|
||||
restriction,
|
||||
"prefer Intel x86 assembly syntax"
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ declare_clippy_lint! {
|
|||
/// const B: bool = false;
|
||||
/// assert!(B)
|
||||
/// ```
|
||||
#[clippy::version = "1.34.0"]
|
||||
pub ASSERTIONS_ON_CONSTANTS,
|
||||
style,
|
||||
"`assert!(true)` / `assert!(false)` will be optimized out by the compiler, and should probably be replaced by a `panic!()` or `unreachable!()`"
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ declare_clippy_lint! {
|
|||
/// // Good
|
||||
/// a += b;
|
||||
/// ```
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub ASSIGN_OP_PATTERN,
|
||||
style,
|
||||
"assigning the result of an operation on a variable to that same variable"
|
||||
|
|
@ -60,6 +61,7 @@ declare_clippy_lint! {
|
|||
/// // ...
|
||||
/// a += a + b;
|
||||
/// ```
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub MISREFACTORED_ASSIGN_OP,
|
||||
suspicious,
|
||||
"having a variable on both sides of an assign op"
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ declare_clippy_lint! {
|
|||
/// };
|
||||
/// }
|
||||
/// ```
|
||||
#[clippy::version = "1.48.0"]
|
||||
pub ASYNC_YIELDS_ASYNC,
|
||||
correctness,
|
||||
"async blocks that return a type that can be awaited"
|
||||
|
|
|
|||
|
|
@ -66,6 +66,7 @@ declare_clippy_lint! {
|
|||
/// #[inline(always)]
|
||||
/// fn not_quite_hot_code(..) { ... }
|
||||
/// ```
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub INLINE_ALWAYS,
|
||||
pedantic,
|
||||
"use of `#[inline(always)]`"
|
||||
|
|
@ -100,6 +101,7 @@ declare_clippy_lint! {
|
|||
/// #[macro_use]
|
||||
/// extern crate baz;
|
||||
/// ```
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub USELESS_ATTRIBUTE,
|
||||
correctness,
|
||||
"use of lint attributes on `extern crate` items"
|
||||
|
|
@ -119,6 +121,7 @@ declare_clippy_lint! {
|
|||
/// #[deprecated(since = "forever")]
|
||||
/// fn something_else() { /* ... */ }
|
||||
/// ```
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub DEPRECATED_SEMVER,
|
||||
correctness,
|
||||
"use of `#[deprecated(since = \"x\")]` where x is not semver"
|
||||
|
|
@ -156,6 +159,7 @@ declare_clippy_lint! {
|
|||
/// #[allow(dead_code)]
|
||||
/// fn this_is_fine_too() { }
|
||||
/// ```
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub EMPTY_LINE_AFTER_OUTER_ATTR,
|
||||
nursery,
|
||||
"empty line after outer attribute"
|
||||
|
|
@ -179,6 +183,7 @@ declare_clippy_lint! {
|
|||
/// ```rust
|
||||
/// #![deny(clippy::as_conversions)]
|
||||
/// ```
|
||||
#[clippy::version = "1.47.0"]
|
||||
pub BLANKET_CLIPPY_RESTRICTION_LINTS,
|
||||
suspicious,
|
||||
"enabling the complete restriction group"
|
||||
|
|
@ -210,6 +215,7 @@ declare_clippy_lint! {
|
|||
/// #[rustfmt::skip]
|
||||
/// fn main() { }
|
||||
/// ```
|
||||
#[clippy::version = "1.32.0"]
|
||||
pub DEPRECATED_CFG_ATTR,
|
||||
complexity,
|
||||
"usage of `cfg_attr(rustfmt)` instead of tool attributes"
|
||||
|
|
@ -242,6 +248,7 @@ declare_clippy_lint! {
|
|||
/// fn conditional() { }
|
||||
/// ```
|
||||
/// Check the [Rust Reference](https://doc.rust-lang.org/reference/conditional-compilation.html#target_os) for more details.
|
||||
#[clippy::version = "1.45.0"]
|
||||
pub MISMATCHED_TARGET_OS,
|
||||
correctness,
|
||||
"usage of `cfg(operating_system)` instead of `cfg(target_os = \"operating_system\")`"
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ declare_clippy_lint! {
|
|||
/// bar.await;
|
||||
/// }
|
||||
/// ```
|
||||
#[clippy::version = "1.45.0"]
|
||||
pub AWAIT_HOLDING_LOCK,
|
||||
pedantic,
|
||||
"Inside an async function, holding a MutexGuard while calling await"
|
||||
|
|
@ -88,6 +89,7 @@ declare_clippy_lint! {
|
|||
/// bar.await;
|
||||
/// }
|
||||
/// ```
|
||||
#[clippy::version = "1.49.0"]
|
||||
pub AWAIT_HOLDING_REFCELL_REF,
|
||||
pedantic,
|
||||
"Inside an async function, holding a RefCell ref while calling await"
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ declare_clippy_lint! {
|
|||
/// # let x = 1;
|
||||
/// if (x & 1 == 2) { }
|
||||
/// ```
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub BAD_BIT_MASK,
|
||||
correctness,
|
||||
"expressions of the form `_ & mask == select` that will only ever return `true` or `false`"
|
||||
|
|
@ -73,6 +74,7 @@ declare_clippy_lint! {
|
|||
/// # let x = 1;
|
||||
/// if (x | 1 > 3) { }
|
||||
/// ```
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub INEFFECTIVE_BIT_MASK,
|
||||
correctness,
|
||||
"expressions where a bit mask will be rendered useless by a comparison, e.g., `(x | 1) > 2`"
|
||||
|
|
@ -95,6 +97,7 @@ declare_clippy_lint! {
|
|||
/// # let x = 1;
|
||||
/// if x & 0b1111 == 0 { }
|
||||
/// ```
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub VERBOSE_BIT_MASK,
|
||||
pedantic,
|
||||
"expressions where a bit mask is less readable than the corresponding method call"
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ declare_clippy_lint! {
|
|||
/// ```rust
|
||||
/// let foo = 3.14;
|
||||
/// ```
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub BLACKLISTED_NAME,
|
||||
style,
|
||||
"usage of a blacklisted/placeholder name"
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ declare_clippy_lint! {
|
|||
/// let res = { let x = somefunc(); x };
|
||||
/// if res { /* ... */ }
|
||||
/// ```
|
||||
#[clippy::version = "1.45.0"]
|
||||
pub BLOCKS_IN_IF_CONDITIONS,
|
||||
style,
|
||||
"useless or complex blocks that can be eliminated in conditions"
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ declare_clippy_lint! {
|
|||
/// // Good
|
||||
/// assert!(!"a".is_empty());
|
||||
/// ```
|
||||
#[clippy::version = "1.53.0"]
|
||||
pub BOOL_ASSERT_COMPARISON,
|
||||
style,
|
||||
"Using a boolean as comparison value in an assert_* macro when there is no need"
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ declare_clippy_lint! {
|
|||
/// if a && true // should be: if a
|
||||
/// if !(a == b) // should be: if a != b
|
||||
/// ```
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub NONMINIMAL_BOOL,
|
||||
complexity,
|
||||
"boolean expressions that can be written more concisely"
|
||||
|
|
@ -52,6 +53,7 @@ declare_clippy_lint! {
|
|||
/// if a && b || a { ... }
|
||||
/// ```
|
||||
/// The `b` is unnecessary, the expression is equivalent to `if a`.
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub LOGIC_BUG,
|
||||
correctness,
|
||||
"boolean expressions that contain terminals which can be eliminated"
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ declare_clippy_lint! {
|
|||
/// # let vec = vec![1_u8];
|
||||
/// &vec.iter().filter(|x| **x == 0u8).count(); // use bytecount::count instead
|
||||
/// ```
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub NAIVE_BYTECOUNT,
|
||||
pedantic,
|
||||
"use of naive `<slice>.filter(|&x| x == y).count()` to count byte values"
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ declare_clippy_lint! {
|
|||
/// keywords = ["clippy", "lint", "plugin"]
|
||||
/// categories = ["development-tools", "development-tools::cargo-plugins"]
|
||||
/// ```
|
||||
#[clippy::version = "1.32.0"]
|
||||
pub CARGO_COMMON_METADATA,
|
||||
cargo,
|
||||
"common metadata is defined in `Cargo.toml`"
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ declare_clippy_lint! {
|
|||
/// filename.rsplit('.').next().map(|ext| ext.eq_ignore_ascii_case("rs")) == Some(true)
|
||||
/// }
|
||||
/// ```
|
||||
#[clippy::version = "1.51.0"]
|
||||
pub CASE_SENSITIVE_FILE_EXTENSION_COMPARISONS,
|
||||
pedantic,
|
||||
"Checks for calls to ends_with with case-sensitive file extensions"
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ declare_clippy_lint! {
|
|||
/// let x = u64::MAX;
|
||||
/// x as f64;
|
||||
/// ```
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub CAST_PRECISION_LOSS,
|
||||
pedantic,
|
||||
"casts that cause loss of precision, e.g., `x as f32` where `x: u64`"
|
||||
|
|
@ -61,6 +62,7 @@ declare_clippy_lint! {
|
|||
/// let y: i8 = -1;
|
||||
/// y as u128; // will return 18446744073709551615
|
||||
/// ```
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub CAST_SIGN_LOSS,
|
||||
pedantic,
|
||||
"casts from signed types to unsigned types, e.g., `x as u32` where `x: i32`"
|
||||
|
|
@ -83,6 +85,7 @@ declare_clippy_lint! {
|
|||
/// x as u8
|
||||
/// }
|
||||
/// ```
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub CAST_POSSIBLE_TRUNCATION,
|
||||
pedantic,
|
||||
"casts that may cause truncation of the value, e.g., `x as u8` where `x: u32`, or `x as i32` where `x: f32`"
|
||||
|
|
@ -106,6 +109,7 @@ declare_clippy_lint! {
|
|||
/// ```rust
|
||||
/// u32::MAX as i32; // will yield a value of `-1`
|
||||
/// ```
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub CAST_POSSIBLE_WRAP,
|
||||
pedantic,
|
||||
"casts that may cause wrapping around the value, e.g., `x as i32` where `x: u32` and `x > i32::MAX`"
|
||||
|
|
@ -138,6 +142,7 @@ declare_clippy_lint! {
|
|||
/// u64::from(x)
|
||||
/// }
|
||||
/// ```
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub CAST_LOSSLESS,
|
||||
pedantic,
|
||||
"casts using `as` that are known to be lossless, e.g., `x as u64` where `x: u8`"
|
||||
|
|
@ -163,6 +168,7 @@ declare_clippy_lint! {
|
|||
/// let _ = 2_i32;
|
||||
/// let _ = 0.5_f32;
|
||||
/// ```
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub UNNECESSARY_CAST,
|
||||
complexity,
|
||||
"cast to the same type, e.g., `x as i32` where `x: i32`"
|
||||
|
|
@ -190,6 +196,7 @@ declare_clippy_lint! {
|
|||
/// (&1u8 as *const u8).cast::<u16>();
|
||||
/// (&mut 1u8 as *mut u8).cast::<u16>();
|
||||
/// ```
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub CAST_PTR_ALIGNMENT,
|
||||
pedantic,
|
||||
"cast from a pointer to a more-strictly-aligned pointer"
|
||||
|
|
@ -217,6 +224,7 @@ declare_clippy_lint! {
|
|||
/// fn fun2() -> i32 { 1 }
|
||||
/// let a = fun2 as usize;
|
||||
/// ```
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub FN_TO_NUMERIC_CAST,
|
||||
style,
|
||||
"casting a function pointer to a numeric type other than usize"
|
||||
|
|
@ -247,6 +255,7 @@ declare_clippy_lint! {
|
|||
/// let fn_ptr = fn2 as usize;
|
||||
/// let fn_ptr_truncated = fn_ptr as i32;
|
||||
/// ```
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub FN_TO_NUMERIC_CAST_WITH_TRUNCATION,
|
||||
style,
|
||||
"casting a function pointer to a numeric type not wide enough to store the address"
|
||||
|
|
@ -283,6 +292,7 @@ declare_clippy_lint! {
|
|||
/// }
|
||||
/// let _ = fn3 as fn() -> u16;
|
||||
/// ```
|
||||
#[clippy::version = "1.58.0"]
|
||||
pub FN_TO_NUMERIC_CAST_ANY,
|
||||
restriction,
|
||||
"casting a function pointer to any integer type"
|
||||
|
|
@ -317,6 +327,7 @@ declare_clippy_lint! {
|
|||
/// }
|
||||
/// }
|
||||
/// ```
|
||||
#[clippy::version = "1.33.0"]
|
||||
pub CAST_REF_TO_MUT,
|
||||
correctness,
|
||||
"a cast of reference to a mutable pointer"
|
||||
|
|
@ -344,6 +355,7 @@ declare_clippy_lint! {
|
|||
/// ```rust,ignore
|
||||
/// b'x'
|
||||
/// ```
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub CHAR_LIT_AS_U8,
|
||||
complexity,
|
||||
"casting a character literal to `u8` truncates"
|
||||
|
|
@ -372,6 +384,7 @@ declare_clippy_lint! {
|
|||
/// let _ = ptr.cast::<i32>();
|
||||
/// let _ = mut_ptr.cast::<i32>();
|
||||
/// ```
|
||||
#[clippy::version = "1.51.0"]
|
||||
pub PTR_AS_PTR,
|
||||
pedantic,
|
||||
"casting using `as` from and to raw pointers that doesn't change its mutability, where `pointer::cast` could take the place of `as`"
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ declare_clippy_lint! {
|
|||
/// i32::try_from(foo).is_ok()
|
||||
/// # ;
|
||||
/// ```
|
||||
#[clippy::version = "1.37.0"]
|
||||
pub CHECKED_CONVERSIONS,
|
||||
pedantic,
|
||||
"`try_from` could replace manual bounds checking when casting"
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ declare_clippy_lint! {
|
|||
///
|
||||
/// ### Example
|
||||
/// No. You'll see it when you get the warning.
|
||||
#[clippy::version = "1.35.0"]
|
||||
pub COGNITIVE_COMPLEXITY,
|
||||
nursery,
|
||||
"functions that should be split up into multiple functions"
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ declare_clippy_lint! {
|
|||
/// …
|
||||
/// }
|
||||
/// ```
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub COLLAPSIBLE_IF,
|
||||
style,
|
||||
"nested `if`s that can be collapsed (e.g., `if x { if y { ... } }`"
|
||||
|
|
@ -82,6 +83,7 @@ declare_clippy_lint! {
|
|||
/// …
|
||||
/// }
|
||||
/// ```
|
||||
#[clippy::version = "1.51.0"]
|
||||
pub COLLAPSIBLE_ELSE_IF,
|
||||
style,
|
||||
"nested `else`-`if` expressions that can be collapsed (e.g., `else { if x { ... } }`)"
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ declare_clippy_lint! {
|
|||
/// };
|
||||
/// }
|
||||
/// ```
|
||||
#[clippy::version = "1.50.0"]
|
||||
pub COLLAPSIBLE_MATCH,
|
||||
style,
|
||||
"Nested `match` or `if let` expressions where the patterns may be \"collapsed\" together."
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@ declare_clippy_lint! {
|
|||
/// }
|
||||
/// }
|
||||
/// ```
|
||||
#[clippy::version = "1.40.0"]
|
||||
pub COMPARISON_CHAIN,
|
||||
style,
|
||||
"`if`s that can be rewritten with `match` and `cmp`"
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ declare_clippy_lint! {
|
|||
/// …
|
||||
/// }
|
||||
/// ```
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub IFS_SAME_COND,
|
||||
correctness,
|
||||
"consecutive `if`s with the same condition"
|
||||
|
|
@ -88,6 +89,7 @@ declare_clippy_lint! {
|
|||
/// }
|
||||
/// }
|
||||
/// ```
|
||||
#[clippy::version = "1.41.0"]
|
||||
pub SAME_FUNCTIONS_IN_IF_CONDITION,
|
||||
pedantic,
|
||||
"consecutive `if`s with the same function call"
|
||||
|
|
@ -109,6 +111,7 @@ declare_clippy_lint! {
|
|||
/// 42
|
||||
/// };
|
||||
/// ```
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub IF_SAME_THEN_ELSE,
|
||||
correctness,
|
||||
"`if` with the same `then` and `else` blocks"
|
||||
|
|
@ -147,6 +150,7 @@ declare_clippy_lint! {
|
|||
/// 42
|
||||
/// };
|
||||
/// ```
|
||||
#[clippy::version = "1.53.0"]
|
||||
pub BRANCHES_SHARING_CODE,
|
||||
nursery,
|
||||
"`if` statement with shared code in all blocks"
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ declare_clippy_lint! {
|
|||
/// let a: Vec<_> = my_iterator.take(1).collect();
|
||||
/// let b: Vec<_> = my_iterator.collect();
|
||||
/// ```
|
||||
#[clippy::version = "1.30.0"]
|
||||
pub COPY_ITERATOR,
|
||||
pedantic,
|
||||
"implementing `Iterator` on a `Copy` type"
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ declare_clippy_lint! {
|
|||
/// ```rust
|
||||
/// std::fs::create_dir_all("foo");
|
||||
/// ```
|
||||
#[clippy::version = "1.48.0"]
|
||||
pub CREATE_DIR,
|
||||
restriction,
|
||||
"calling `std::fs::create_dir` instead of `std::fs::create_dir_all`"
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ declare_clippy_lint! {
|
|||
/// // Good
|
||||
/// true
|
||||
/// ```
|
||||
#[clippy::version = "1.34.0"]
|
||||
pub DBG_MACRO,
|
||||
restriction,
|
||||
"`dbg!` macro is intended as a debugging tool"
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ declare_clippy_lint! {
|
|||
/// // Good
|
||||
/// let s = String::default();
|
||||
/// ```
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub DEFAULT_TRAIT_ACCESS,
|
||||
pedantic,
|
||||
"checks for literal calls to `Default::default()`"
|
||||
|
|
@ -62,6 +63,7 @@ declare_clippy_lint! {
|
|||
/// .. Default::default()
|
||||
/// };
|
||||
/// ```
|
||||
#[clippy::version = "1.49.0"]
|
||||
pub FIELD_REASSIGN_WITH_DEFAULT,
|
||||
style,
|
||||
"binding initialized with Default should have its fields set in the initializer"
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ declare_clippy_lint! {
|
|||
/// let i = 10i32;
|
||||
/// let f = 1.23f64;
|
||||
/// ```
|
||||
#[clippy::version = "1.52.0"]
|
||||
pub DEFAULT_NUMERIC_FALLBACK,
|
||||
restriction,
|
||||
"usage of unconstrained numeric literals which may cause default numeric fallback."
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ declare_deprecated_lint! {
|
|||
/// ### Deprecation reason
|
||||
/// This used to check for `assert!(a == b)` and recommend
|
||||
/// replacement with `assert_eq!(a, b)`, but this is no longer needed after RFC 2011.
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub SHOULD_ASSERT_EQ,
|
||||
"`assert!()` will be more flexible with RFC 2011"
|
||||
}
|
||||
|
|
@ -32,6 +33,7 @@ declare_deprecated_lint! {
|
|||
/// ### Deprecation reason
|
||||
/// This used to check for `Vec::extend`, which was slower than
|
||||
/// `Vec::extend_from_slice`. Thanks to specialization, this is no longer true.
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub EXTEND_FROM_SLICE,
|
||||
"`.extend_from_slice(_)` is a faster way to extend a Vec by a slice"
|
||||
}
|
||||
|
|
@ -45,6 +47,7 @@ declare_deprecated_lint! {
|
|||
/// an infinite iterator, which is better expressed by `iter::repeat`,
|
||||
/// but the method has been removed for `Iterator::step_by` which panics
|
||||
/// if given a zero
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub RANGE_STEP_BY_ZERO,
|
||||
"`iterator.step_by(0)` panics nowadays"
|
||||
}
|
||||
|
|
@ -56,6 +59,7 @@ declare_deprecated_lint! {
|
|||
/// ### Deprecation reason
|
||||
/// This used to check for `Vec::as_slice`, which was unstable with good
|
||||
/// stable alternatives. `Vec::as_slice` has now been stabilized.
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub UNSTABLE_AS_SLICE,
|
||||
"`Vec::as_slice` has been stabilized in 1.7"
|
||||
}
|
||||
|
|
@ -67,6 +71,7 @@ declare_deprecated_lint! {
|
|||
/// ### Deprecation reason
|
||||
/// This used to check for `Vec::as_mut_slice`, which was unstable with good
|
||||
/// stable alternatives. `Vec::as_mut_slice` has now been stabilized.
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub UNSTABLE_AS_MUT_SLICE,
|
||||
"`Vec::as_mut_slice` has been stabilized in 1.7"
|
||||
}
|
||||
|
|
@ -80,6 +85,7 @@ declare_deprecated_lint! {
|
|||
/// between non-pointer types of differing alignment is well-defined behavior (it's semantically
|
||||
/// equivalent to a memcpy). This lint has thus been refactored into two separate lints:
|
||||
/// cast_ptr_alignment and transmute_ptr_to_ptr.
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub MISALIGNED_TRANSMUTE,
|
||||
"this lint has been split into cast_ptr_alignment and transmute_ptr_to_ptr"
|
||||
}
|
||||
|
|
@ -92,6 +98,7 @@ declare_deprecated_lint! {
|
|||
/// This lint is too subjective, not having a good reason for being in clippy.
|
||||
/// Additionally, compound assignment operators may be overloaded separately from their non-assigning
|
||||
/// counterparts, so this lint may suggest a change in behavior or the code may not compile.
|
||||
#[clippy::version = "1.30.0"]
|
||||
pub ASSIGN_OPS,
|
||||
"using compound assignment operators (e.g., `+=`) is harmless"
|
||||
}
|
||||
|
|
@ -104,6 +111,7 @@ declare_deprecated_lint! {
|
|||
/// The original rule will only lint for `if let`. After
|
||||
/// making it support to lint `match`, naming as `if let` is not suitable for it.
|
||||
/// So, this lint is deprecated.
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub IF_LET_REDUNDANT_PATTERN_MATCHING,
|
||||
"this lint has been changed to redundant_pattern_matching"
|
||||
}
|
||||
|
|
@ -117,6 +125,7 @@ declare_deprecated_lint! {
|
|||
/// Vec::with_capacity(n); vec.set_len(n);` with `let vec = vec![0; n];`. The
|
||||
/// replacement has very different performance characteristics so the lint is
|
||||
/// deprecated.
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub UNSAFE_VECTOR_INITIALIZATION,
|
||||
"the replacement suggested by this lint had substantially different behavior"
|
||||
}
|
||||
|
|
@ -127,6 +136,7 @@ declare_deprecated_lint! {
|
|||
///
|
||||
/// ### Deprecation reason
|
||||
/// This lint has been superseded by #[must_use] in rustc.
|
||||
#[clippy::version = "1.39.0"]
|
||||
pub UNUSED_COLLECT,
|
||||
"`collect` has been marked as #[must_use] in rustc and that covers all cases of this lint"
|
||||
}
|
||||
|
|
@ -137,6 +147,7 @@ declare_deprecated_lint! {
|
|||
///
|
||||
/// ### Deprecation reason
|
||||
/// Associated-constants are now preferred.
|
||||
#[clippy::version = "1.44.0"]
|
||||
pub REPLACE_CONSTS,
|
||||
"associated-constants `MIN`/`MAX` of integers are preferred to `{min,max}_value()` and module constants"
|
||||
}
|
||||
|
|
@ -147,6 +158,7 @@ declare_deprecated_lint! {
|
|||
///
|
||||
/// ### Deprecation reason
|
||||
/// The regex! macro does not exist anymore.
|
||||
#[clippy::version = "1.47.0"]
|
||||
pub REGEX_MACRO,
|
||||
"the regex! macro has been removed from the regex crate in 2018"
|
||||
}
|
||||
|
|
@ -158,6 +170,7 @@ declare_deprecated_lint! {
|
|||
/// ### Deprecation reason
|
||||
/// This lint has been replaced by `manual_find_map`, a
|
||||
/// more specific lint.
|
||||
#[clippy::version = "1.51.0"]
|
||||
pub FIND_MAP,
|
||||
"this lint has been replaced by `manual_find_map`, a more specific lint"
|
||||
}
|
||||
|
|
@ -169,6 +182,7 @@ declare_deprecated_lint! {
|
|||
/// ### Deprecation reason
|
||||
/// This lint has been replaced by `manual_filter_map`, a
|
||||
/// more specific lint.
|
||||
#[clippy::version = "1.53.0"]
|
||||
pub FILTER_MAP,
|
||||
"this lint has been replaced by `manual_filter_map`, a more specific lint"
|
||||
}
|
||||
|
|
@ -181,6 +195,7 @@ declare_deprecated_lint! {
|
|||
/// The `avoid_breaking_exported_api` config option was added, which
|
||||
/// enables the `enum_variant_names` lint for public items.
|
||||
/// ```
|
||||
#[clippy::version = "1.54.0"]
|
||||
pub PUB_ENUM_VARIANT_NAMES,
|
||||
"set the `avoid-breaking-exported-api` config option to `false` to enable the `enum_variant_names` lint for public items"
|
||||
}
|
||||
|
|
@ -192,6 +207,7 @@ declare_deprecated_lint! {
|
|||
/// ### Deprecation reason
|
||||
/// The `avoid_breaking_exported_api` config option was added, which
|
||||
/// enables the `wrong_self_conversion` lint for public items.
|
||||
#[clippy::version = "1.54.0"]
|
||||
pub WRONG_PUB_SELF_CONVENTION,
|
||||
"set the `avoid-breaking-exported-api` config option to `false` to enable the `wrong_self_convention` lint for public items"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ declare_clippy_lint! {
|
|||
/// ```rust,ignore
|
||||
/// let _ = d.unwrap().deref();
|
||||
/// ```
|
||||
#[clippy::version = "1.44.0"]
|
||||
pub EXPLICIT_DEREF_METHODS,
|
||||
pedantic,
|
||||
"Explicit use of deref or deref_mut method while not in a method chain."
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ declare_clippy_lint! {
|
|||
/// has exactly equal bounds, and therefore this lint is disabled for types with
|
||||
/// generic parameters.
|
||||
///
|
||||
#[clippy::version = "1.57.0"]
|
||||
pub DERIVABLE_IMPLS,
|
||||
complexity,
|
||||
"manual implementation of the `Default` trait which is equal to a derive"
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ declare_clippy_lint! {
|
|||
/// ...
|
||||
/// }
|
||||
/// ```
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub DERIVE_HASH_XOR_EQ,
|
||||
correctness,
|
||||
"deriving `Hash` but implementing `PartialEq` explicitly"
|
||||
|
|
@ -88,6 +89,7 @@ declare_clippy_lint! {
|
|||
/// #[derive(Ord, PartialOrd, PartialEq, Eq)]
|
||||
/// struct Foo;
|
||||
/// ```
|
||||
#[clippy::version = "1.47.0"]
|
||||
pub DERIVE_ORD_XOR_PARTIAL_ORD,
|
||||
correctness,
|
||||
"deriving `Ord` but implementing `PartialOrd` explicitly"
|
||||
|
|
@ -114,6 +116,7 @@ declare_clippy_lint! {
|
|||
/// // ..
|
||||
/// }
|
||||
/// ```
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub EXPL_IMPL_CLONE_ON_COPY,
|
||||
pedantic,
|
||||
"implementing `Clone` explicitly on `Copy` types"
|
||||
|
|
@ -147,6 +150,7 @@ declare_clippy_lint! {
|
|||
/// }
|
||||
/// }
|
||||
/// ```
|
||||
#[clippy::version = "1.45.0"]
|
||||
pub UNSAFE_DERIVE_DESERIALIZE,
|
||||
pedantic,
|
||||
"deriving `serde::Deserialize` on a type that has methods using `unsafe`"
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ declare_clippy_lint! {
|
|||
/// let mut xs = Vec::new(); // Vec::new is _not_ disallowed in the config.
|
||||
/// xs.push(123); // Vec::push is _not_ disallowed in the config.
|
||||
/// ```
|
||||
#[clippy::version = "1.49.0"]
|
||||
pub DISALLOWED_METHOD,
|
||||
nursery,
|
||||
"use of a disallowed method call"
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ declare_clippy_lint! {
|
|||
/// let zähler = 10; // OK, it's still latin.
|
||||
/// let カウンタ = 10; // Will spawn the lint.
|
||||
/// ```
|
||||
#[clippy::version = "1.55.0"]
|
||||
pub DISALLOWED_SCRIPT_IDENTS,
|
||||
restriction,
|
||||
"usage of non-allowed Unicode scripts"
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ declare_clippy_lint! {
|
|||
/// // A similar type that is allowed by the config
|
||||
/// use std::collections::HashMap;
|
||||
/// ```
|
||||
#[clippy::version = "1.55.0"]
|
||||
pub DISALLOWED_TYPE,
|
||||
nursery,
|
||||
"use of a disallowed type"
|
||||
|
|
|
|||
|
|
@ -67,6 +67,7 @@ declare_clippy_lint! {
|
|||
/// /// [SmallVec]: SmallVec
|
||||
/// fn main() {}
|
||||
/// ```
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub DOC_MARKDOWN,
|
||||
pedantic,
|
||||
"presence of `_`, `::` or camel-case outside backticks in documentation"
|
||||
|
|
@ -101,6 +102,7 @@ declare_clippy_lint! {
|
|||
/// unimplemented!();
|
||||
/// }
|
||||
/// ```
|
||||
#[clippy::version = "1.39.0"]
|
||||
pub MISSING_SAFETY_DOC,
|
||||
style,
|
||||
"`pub unsafe fn` without `# Safety` docs"
|
||||
|
|
@ -129,6 +131,7 @@ declare_clippy_lint! {
|
|||
/// unimplemented!();
|
||||
/// }
|
||||
/// ```
|
||||
#[clippy::version = "1.41.0"]
|
||||
pub MISSING_ERRORS_DOC,
|
||||
pedantic,
|
||||
"`pub fn` returns `Result` without `# Errors` in doc comment"
|
||||
|
|
@ -159,6 +162,7 @@ declare_clippy_lint! {
|
|||
/// }
|
||||
/// }
|
||||
/// ```
|
||||
#[clippy::version = "1.52.0"]
|
||||
pub MISSING_PANICS_DOC,
|
||||
pedantic,
|
||||
"`pub fn` may panic without `# Panics` in doc comment"
|
||||
|
|
@ -187,6 +191,7 @@ declare_clippy_lint! {
|
|||
/// unimplemented!();
|
||||
/// }
|
||||
/// ``````
|
||||
#[clippy::version = "1.40.0"]
|
||||
pub NEEDLESS_DOCTEST_MAIN,
|
||||
style,
|
||||
"presence of `fn main() {` in code examples"
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ declare_clippy_lint! {
|
|||
/// # let y = 2;
|
||||
/// if x <= y {}
|
||||
/// ```
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub DOUBLE_COMPARISONS,
|
||||
complexity,
|
||||
"unnecessary double comparisons that can be simplified"
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ declare_clippy_lint! {
|
|||
/// // Good
|
||||
/// foo(0);
|
||||
/// ```
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub DOUBLE_PARENS,
|
||||
complexity,
|
||||
"Warn on unnecessary double parentheses"
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ declare_clippy_lint! {
|
|||
/// // still locked
|
||||
/// operation_that_requires_mutex_to_be_unlocked();
|
||||
/// ```
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub DROP_REF,
|
||||
correctness,
|
||||
"calls to `std::mem::drop` with a reference instead of an owned value"
|
||||
|
|
@ -46,6 +47,7 @@ declare_clippy_lint! {
|
|||
/// let x = Box::new(1);
|
||||
/// std::mem::forget(&x) // Should have been forget(x), x will still be dropped
|
||||
/// ```
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub FORGET_REF,
|
||||
correctness,
|
||||
"calls to `std::mem::forget` with a reference instead of an owned value"
|
||||
|
|
@ -67,6 +69,7 @@ declare_clippy_lint! {
|
|||
/// std::mem::drop(x) // A copy of x is passed to the function, leaving the
|
||||
/// // original unaffected
|
||||
/// ```
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub DROP_COPY,
|
||||
correctness,
|
||||
"calls to `std::mem::drop` with a value that implements Copy"
|
||||
|
|
@ -94,6 +97,7 @@ declare_clippy_lint! {
|
|||
/// std::mem::forget(x) // A copy of x is passed to the function, leaving the
|
||||
/// // original unaffected
|
||||
/// ```
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub FORGET_COPY,
|
||||
correctness,
|
||||
"calls to `std::mem::forget` with a value that implements Copy"
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ declare_clippy_lint! {
|
|||
/// let _micros = dur.subsec_micros();
|
||||
/// let _millis = dur.subsec_millis();
|
||||
/// ```
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub DURATION_SUBSEC,
|
||||
complexity,
|
||||
"checks for calculation of subsecond microseconds or milliseconds"
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ declare_clippy_lint! {
|
|||
/// // We don't care about zero.
|
||||
/// }
|
||||
/// ```
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub ELSE_IF_WITHOUT_ELSE,
|
||||
restriction,
|
||||
"`if` expression with an `else if`, but without a final `else` branch"
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ declare_clippy_lint! {
|
|||
///
|
||||
/// struct Test(!);
|
||||
/// ```
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub EMPTY_ENUM,
|
||||
pedantic,
|
||||
"enum with no variants"
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@ declare_clippy_lint! {
|
|||
/// # let v = 1;
|
||||
/// map.entry(k).or_insert(v);
|
||||
/// ```
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub MAP_ENTRY,
|
||||
perf,
|
||||
"use of `contains_key` followed by `insert` on a `HashMap` or `BTreeMap`"
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ declare_clippy_lint! {
|
|||
/// Y = 0,
|
||||
/// }
|
||||
/// ```
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub ENUM_CLIKE_UNPORTABLE_VARIANT,
|
||||
correctness,
|
||||
"C-like enums that are `repr(isize/usize)` and have values that don't fit into an `i32`"
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ declare_clippy_lint! {
|
|||
/// Battenberg,
|
||||
/// }
|
||||
/// ```
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub ENUM_VARIANT_NAMES,
|
||||
style,
|
||||
"enums where all variants share a prefix/postfix"
|
||||
|
|
@ -59,6 +60,7 @@ declare_clippy_lint! {
|
|||
/// struct BlackForest;
|
||||
/// }
|
||||
/// ```
|
||||
#[clippy::version = "1.33.0"]
|
||||
pub MODULE_NAME_REPETITIONS,
|
||||
pedantic,
|
||||
"type names prefixed/postfixed with their containing module's name"
|
||||
|
|
@ -89,6 +91,7 @@ declare_clippy_lint! {
|
|||
/// ...
|
||||
/// }
|
||||
/// ```
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub MODULE_INCEPTION,
|
||||
style,
|
||||
"modules that have the same name as their parent module"
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ declare_clippy_lint! {
|
|||
/// # let b = 4;
|
||||
/// assert_eq!(a, a);
|
||||
/// ```
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub EQ_OP,
|
||||
correctness,
|
||||
"equal operands on both sides of a comparison or bitwise combination (e.g., `x == x`)"
|
||||
|
|
@ -59,6 +60,7 @@ declare_clippy_lint! {
|
|||
/// // Good
|
||||
/// x == *y
|
||||
/// ```
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub OP_REF,
|
||||
style,
|
||||
"taking a reference to satisfy the type constraints on `==`"
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ declare_clippy_lint! {
|
|||
/// do_thing();
|
||||
/// }
|
||||
/// ```
|
||||
#[clippy::version = "1.57.0"]
|
||||
pub EQUATABLE_IF_LET,
|
||||
nursery,
|
||||
"using pattern matching instead of equality"
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ declare_clippy_lint! {
|
|||
/// 0 * x;
|
||||
/// x & 0;
|
||||
/// ```
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub ERASING_OP,
|
||||
correctness,
|
||||
"using erasing operations, e.g., `x * 0` or `y & 0`"
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ declare_clippy_lint! {
|
|||
/// foo(x);
|
||||
/// println!("{}", x);
|
||||
/// ```
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub BOXED_LOCAL,
|
||||
perf,
|
||||
"using `Box<T>` where unnecessary"
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ declare_clippy_lint! {
|
|||
/// ```
|
||||
/// where `foo(_)` is a plain function that takes the exact argument type of
|
||||
/// `x`.
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub REDUNDANT_CLOSURE,
|
||||
style,
|
||||
"redundant closures, i.e., `|a| foo(a)` (which can be written as just `foo`)"
|
||||
|
|
@ -60,6 +61,7 @@ declare_clippy_lint! {
|
|||
/// ```rust,ignore
|
||||
/// Some('a').map(char::to_uppercase);
|
||||
/// ```
|
||||
#[clippy::version = "1.35.0"]
|
||||
pub REDUNDANT_CLOSURE_FOR_METHOD_CALLS,
|
||||
pedantic,
|
||||
"redundant closures for method calls"
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ declare_clippy_lint! {
|
|||
/// };
|
||||
/// let a = tmp + x;
|
||||
/// ```
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub EVAL_ORDER_DEPENDENCE,
|
||||
suspicious,
|
||||
"whether a variable read occurs before a write depends on sub-expression evaluation order"
|
||||
|
|
@ -67,6 +68,7 @@ declare_clippy_lint! {
|
|||
/// let x = (a, b, c, panic!());
|
||||
/// // can simply be replaced by `panic!()`
|
||||
/// ```
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub DIVERGING_SUB_EXPRESSION,
|
||||
complexity,
|
||||
"whether an expression contains a diverging sub expression"
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ declare_clippy_lint! {
|
|||
/// Finished,
|
||||
/// }
|
||||
/// ```
|
||||
#[clippy::version = "1.43.0"]
|
||||
pub STRUCT_EXCESSIVE_BOOLS,
|
||||
pedantic,
|
||||
"using too many bools in a struct"
|
||||
|
|
@ -75,6 +76,7 @@ declare_clippy_lint! {
|
|||
///
|
||||
/// fn f(shape: Shape, temperature: Temperature) { ... }
|
||||
/// ```
|
||||
#[clippy::version = "1.43.0"]
|
||||
pub FN_PARAMS_EXCESSIVE_BOOLS,
|
||||
pedantic,
|
||||
"using too many bools in function parameters"
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ declare_clippy_lint! {
|
|||
/// Baz
|
||||
/// }
|
||||
/// ```
|
||||
#[clippy::version = "1.51.0"]
|
||||
pub EXHAUSTIVE_ENUMS,
|
||||
restriction,
|
||||
"detects exported enums that have not been marked #[non_exhaustive]"
|
||||
|
|
@ -60,6 +61,7 @@ declare_clippy_lint! {
|
|||
/// baz: String,
|
||||
/// }
|
||||
/// ```
|
||||
#[clippy::version = "1.51.0"]
|
||||
pub EXHAUSTIVE_STRUCTS,
|
||||
restriction,
|
||||
"detects exported structs that have not been marked #[non_exhaustive]"
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ declare_clippy_lint! {
|
|||
/// ```ignore
|
||||
/// std::process::exit(0)
|
||||
/// ```
|
||||
#[clippy::version = "1.41.0"]
|
||||
pub EXIT,
|
||||
restriction,
|
||||
"`std::process::exit` is called, terminating the program"
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ declare_clippy_lint! {
|
|||
/// // this would be clearer as `eprintln!("foo: {:?}", bar);`
|
||||
/// writeln!(&mut std::io::stderr(), "foo: {:?}", bar).unwrap();
|
||||
/// ```
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub EXPLICIT_WRITE,
|
||||
complexity,
|
||||
"using the `write!()` family of functions instead of the `print!()` family of functions, when using the latter would work"
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ declare_clippy_lint! {
|
|||
/// }
|
||||
/// }
|
||||
/// ```
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub FALLIBLE_IMPL_FROM,
|
||||
nursery,
|
||||
"Warn on impls of `From<..>` that contain `panic!()` or `unwrap()`"
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ declare_clippy_lint! {
|
|||
/// ghi = []
|
||||
/// ```
|
||||
///
|
||||
#[clippy::version = "1.57.0"]
|
||||
pub REDUNDANT_FEATURE_NAMES,
|
||||
cargo,
|
||||
"usage of a redundant feature name"
|
||||
|
|
@ -60,6 +61,7 @@ declare_clippy_lint! {
|
|||
/// def = []
|
||||
///
|
||||
/// ```
|
||||
#[clippy::version = "1.57.0"]
|
||||
pub NEGATIVE_FEATURE_NAMES,
|
||||
cargo,
|
||||
"usage of a negative feature name"
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ declare_clippy_lint! {
|
|||
/// (a - b).abs() < f32::EPSILON
|
||||
/// }
|
||||
/// ```
|
||||
#[clippy::version = "1.48.0"]
|
||||
pub FLOAT_EQUALITY_WITHOUT_ABS,
|
||||
suspicious,
|
||||
"float equality check without `.abs()`"
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ declare_clippy_lint! {
|
|||
/// let v: f64 = 0.123_456_789_9;
|
||||
/// println!("{}", v); // 0.123_456_789_9
|
||||
/// ```
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub EXCESSIVE_PRECISION,
|
||||
style,
|
||||
"excessive precision for float literal"
|
||||
|
|
@ -50,6 +51,7 @@ declare_clippy_lint! {
|
|||
/// let _: f32 = 16_777_216.0;
|
||||
/// let _: f64 = 16_777_217.0;
|
||||
/// ```
|
||||
#[clippy::version = "1.43.0"]
|
||||
pub LOSSY_FLOAT_LITERAL,
|
||||
restriction,
|
||||
"lossy whole number float literals"
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ declare_clippy_lint! {
|
|||
/// let _ = a.ln_1p();
|
||||
/// let _ = a.exp_m1();
|
||||
/// ```
|
||||
#[clippy::version = "1.43.0"]
|
||||
pub IMPRECISE_FLOPS,
|
||||
nursery,
|
||||
"usage of imprecise floating point operations"
|
||||
|
|
@ -99,6 +100,7 @@ declare_clippy_lint! {
|
|||
/// let _ = a.abs();
|
||||
/// let _ = -a.abs();
|
||||
/// ```
|
||||
#[clippy::version = "1.43.0"]
|
||||
pub SUBOPTIMAL_FLOPS,
|
||||
nursery,
|
||||
"usage of sub-optimal floating point operations"
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ declare_clippy_lint! {
|
|||
/// // Good
|
||||
/// foo.to_owned();
|
||||
/// ```
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub USELESS_FORMAT,
|
||||
complexity,
|
||||
"useless use of `format!`"
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ declare_clippy_lint! {
|
|||
/// # use std::panic::Location;
|
||||
/// println!("error: something failed at {}", Location::caller());
|
||||
/// ```
|
||||
#[clippy::version = "1.58.0"]
|
||||
pub FORMAT_IN_FORMAT_ARGS,
|
||||
perf,
|
||||
"`format!` used in a macro that does formatting"
|
||||
|
|
@ -56,6 +57,7 @@ declare_clippy_lint! {
|
|||
/// # use std::panic::Location;
|
||||
/// println!("error: something failed at {}", Location::caller());
|
||||
/// ```
|
||||
#[clippy::version = "1.58.0"]
|
||||
pub TO_STRING_IN_FORMAT_ARGS,
|
||||
perf,
|
||||
"`to_string` applied to a type that implements `Display` in format args"
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ declare_clippy_lint! {
|
|||
/// ```rust,ignore
|
||||
/// a =- 42; // confusing, should it be `a -= 42` or `a = -42`?
|
||||
/// ```
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub SUSPICIOUS_ASSIGNMENT_FORMATTING,
|
||||
suspicious,
|
||||
"suspicious formatting of `*=`, `-=` or `!=`"
|
||||
|
|
@ -43,6 +44,7 @@ declare_clippy_lint! {
|
|||
/// if foo &&! bar { // this should be `foo && !bar` but looks like a different operator
|
||||
/// }
|
||||
/// ```
|
||||
#[clippy::version = "1.40.0"]
|
||||
pub SUSPICIOUS_UNARY_OP_FORMATTING,
|
||||
suspicious,
|
||||
"suspicious formatting of unary `-` or `!` on the RHS of a BinOp"
|
||||
|
|
@ -79,6 +81,7 @@ declare_clippy_lint! {
|
|||
/// if bar { // this is the `else` block of the previous `if`, but should it be?
|
||||
/// }
|
||||
/// ```
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub SUSPICIOUS_ELSE_FORMATTING,
|
||||
suspicious,
|
||||
"suspicious formatting of `else`"
|
||||
|
|
@ -99,6 +102,7 @@ declare_clippy_lint! {
|
|||
/// -4, -5, -6
|
||||
/// ];
|
||||
/// ```
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub POSSIBLE_MISSING_COMMA,
|
||||
correctness,
|
||||
"possible missing comma in array"
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ declare_clippy_lint! {
|
|||
/// }
|
||||
/// }
|
||||
/// ```
|
||||
#[clippy::version = "1.51.0"]
|
||||
pub FROM_OVER_INTO,
|
||||
style,
|
||||
"Warns on implementations of `Into<..>` to use `From<..>`"
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ declare_clippy_lint! {
|
|||
/// let input: &str = get_input();
|
||||
/// let num: u16 = input.parse()?;
|
||||
/// ```
|
||||
#[clippy::version = "1.52.0"]
|
||||
pub FROM_STR_RADIX_10,
|
||||
style,
|
||||
"from_str_radix with radix 10"
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ declare_clippy_lint! {
|
|||
/// // ..
|
||||
/// }
|
||||
/// ```
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub TOO_MANY_ARGUMENTS,
|
||||
complexity,
|
||||
"functions with too many arguments"
|
||||
|
|
@ -49,6 +50,7 @@ declare_clippy_lint! {
|
|||
/// println!("");
|
||||
/// }
|
||||
/// ```
|
||||
#[clippy::version = "1.34.0"]
|
||||
pub TOO_MANY_LINES,
|
||||
pedantic,
|
||||
"functions with too many lines"
|
||||
|
|
@ -84,6 +86,7 @@ declare_clippy_lint! {
|
|||
/// println!("{}", unsafe { *x });
|
||||
/// }
|
||||
/// ```
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub NOT_UNSAFE_PTR_ARG_DEREF,
|
||||
correctness,
|
||||
"public functions dereferencing raw pointer arguments but not marked `unsafe`"
|
||||
|
|
@ -103,6 +106,7 @@ declare_clippy_lint! {
|
|||
/// #[must_use]
|
||||
/// fn useless() { }
|
||||
/// ```
|
||||
#[clippy::version = "1.40.0"]
|
||||
pub MUST_USE_UNIT,
|
||||
style,
|
||||
"`#[must_use]` attribute on a unit-returning function / method"
|
||||
|
|
@ -126,6 +130,7 @@ declare_clippy_lint! {
|
|||
/// unimplemented!();
|
||||
/// }
|
||||
/// ```
|
||||
#[clippy::version = "1.40.0"]
|
||||
pub DOUBLE_MUST_USE,
|
||||
style,
|
||||
"`#[must_use]` attribute on a `#[must_use]`-returning function / method"
|
||||
|
|
@ -155,6 +160,7 @@ declare_clippy_lint! {
|
|||
/// // this could be annotated with `#[must_use]`.
|
||||
/// fn id<T>(t: T) -> T { t }
|
||||
/// ```
|
||||
#[clippy::version = "1.40.0"]
|
||||
pub MUST_USE_CANDIDATE,
|
||||
pedantic,
|
||||
"function or method that could take a `#[must_use]` attribute"
|
||||
|
|
@ -204,6 +210,7 @@ declare_clippy_lint! {
|
|||
///
|
||||
/// Note that there are crates that simplify creating the error type, e.g.
|
||||
/// [`thiserror`](https://docs.rs/thiserror).
|
||||
#[clippy::version = "1.49.0"]
|
||||
pub RESULT_UNIT_ERR,
|
||||
style,
|
||||
"public function returning `Result` with an `Err` type of `()`"
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ declare_clippy_lint! {
|
|||
/// ```rust
|
||||
/// async fn is_send(bytes: std::sync::Arc<[u8]>) {}
|
||||
/// ```
|
||||
#[clippy::version = "1.44.0"]
|
||||
pub FUTURE_NOT_SEND,
|
||||
nursery,
|
||||
"public Futures must be Send"
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ declare_clippy_lint! {
|
|||
/// let x = vec![2, 3, 5];
|
||||
/// let last_element = x.last();
|
||||
/// ```
|
||||
#[clippy::version = "1.37.0"]
|
||||
pub GET_LAST_WITH_LEN,
|
||||
complexity,
|
||||
"Using `x.get(x.len() - 1)` when `x.last()` is correct and simpler"
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ declare_clippy_lint! {
|
|||
/// # let x = 1;
|
||||
/// x / 1 + 0 * 1 - 0 | 0;
|
||||
/// ```
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub IDENTITY_OP,
|
||||
complexity,
|
||||
"using identity operations, e.g., `x + 0` or `y / 1`"
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ declare_clippy_lint! {
|
|||
/// use_locked(locked);
|
||||
/// }
|
||||
/// ```
|
||||
#[clippy::version = "1.45.0"]
|
||||
pub IF_LET_MUTEX,
|
||||
correctness,
|
||||
"locking a `Mutex` in an `if let` block can cause deadlocks"
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ declare_clippy_lint! {
|
|||
/// a()
|
||||
/// }
|
||||
/// ```
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub IF_NOT_ELSE,
|
||||
pedantic,
|
||||
"`if` branches that could be swapped so no negation operation is necessary on the condition"
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ declare_clippy_lint! {
|
|||
/// 42
|
||||
/// });
|
||||
/// ```
|
||||
#[clippy::version = "1.53.0"]
|
||||
pub IF_THEN_SOME_ELSE_NONE,
|
||||
restriction,
|
||||
"Finds if-else that could be written using `bool::then`"
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@ declare_clippy_lint! {
|
|||
///
|
||||
/// pub fn foo<S: BuildHasher>(map: &mut HashMap<i32, i32, S>) { }
|
||||
/// ```
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub IMPLICIT_HASHER,
|
||||
pedantic,
|
||||
"missing generalization over different hashers"
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ declare_clippy_lint! {
|
|||
/// return x;
|
||||
/// }
|
||||
/// ```
|
||||
#[clippy::version = "1.33.0"]
|
||||
pub IMPLICIT_RETURN,
|
||||
restriction,
|
||||
"use a return statement like `return expr` instead of an expression"
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ declare_clippy_lint! {
|
|||
/// // Good
|
||||
/// i = i.saturating_sub(1);
|
||||
/// ```
|
||||
#[clippy::version = "1.44.0"]
|
||||
pub IMPLICIT_SATURATING_SUB,
|
||||
pedantic,
|
||||
"Perform saturating subtraction instead of implicitly checking lower bound of data type"
|
||||
|
|
|
|||
|
|
@ -55,6 +55,7 @@ declare_clippy_lint! {
|
|||
/// # let y = 2;
|
||||
/// Foo { x, y };
|
||||
/// ```
|
||||
#[clippy::version = "1.52.0"]
|
||||
pub INCONSISTENT_STRUCT_CONSTRUCTOR,
|
||||
pedantic,
|
||||
"the order of the field init shorthand is inconsistent with the order in the struct definition"
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ declare_clippy_lint! {
|
|||
/// x[0];
|
||||
/// x[3];
|
||||
/// ```
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub OUT_OF_BOUNDS_INDEXING,
|
||||
correctness,
|
||||
"out of bounds constant indexing"
|
||||
|
|
@ -85,6 +86,7 @@ declare_clippy_lint! {
|
|||
/// y.get(10..);
|
||||
/// y.get(..100);
|
||||
/// ```
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub INDEXING_SLICING,
|
||||
restriction,
|
||||
"indexing/slicing usage"
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ declare_clippy_lint! {
|
|||
///
|
||||
/// iter::repeat(1_u8).collect::<Vec<_>>();
|
||||
/// ```
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub INFINITE_ITER,
|
||||
correctness,
|
||||
"infinite iteration"
|
||||
|
|
@ -42,6 +43,7 @@ declare_clippy_lint! {
|
|||
/// let infinite_iter = 0..;
|
||||
/// [0..].iter().zip(infinite_iter.take_while(|x| *x > 5));
|
||||
/// ```
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub MAYBE_INFINITE_ITER,
|
||||
pedantic,
|
||||
"possible infinite iteration"
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ declare_clippy_lint! {
|
|||
/// fn other() {}
|
||||
/// }
|
||||
/// ```
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub MULTIPLE_INHERENT_IMPL,
|
||||
restriction,
|
||||
"Multiple inherent impl that could be grouped"
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ declare_clippy_lint! {
|
|||
/// }
|
||||
/// }
|
||||
/// ```
|
||||
#[clippy::version = "1.38.0"]
|
||||
pub INHERENT_TO_STRING,
|
||||
style,
|
||||
"type implements inherent method `to_string()`, but should instead implement the `Display` trait"
|
||||
|
|
@ -88,6 +89,7 @@ declare_clippy_lint! {
|
|||
/// }
|
||||
/// }
|
||||
/// ```
|
||||
#[clippy::version = "1.38.0"]
|
||||
pub INHERENT_TO_STRING_SHADOW_DISPLAY,
|
||||
correctness,
|
||||
"type implements inherent method `to_string()`, which gets shadowed by the implementation of the `Display` trait"
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ declare_clippy_lint! {
|
|||
/// fn name(&self) -> &'static str;
|
||||
/// }
|
||||
/// ```
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub INLINE_FN_WITHOUT_BODY,
|
||||
correctness,
|
||||
"use of `#[inline]` on trait methods without bodies"
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ declare_clippy_lint! {
|
|||
/// # let y = 1;
|
||||
/// if x > y {}
|
||||
/// ```
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub INT_PLUS_ONE,
|
||||
complexity,
|
||||
"instead of using `x >= y + 1`, use `x > y`"
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ declare_clippy_lint! {
|
|||
/// let x = 3f32 / 2f32;
|
||||
/// println!("{}", x);
|
||||
/// ```
|
||||
#[clippy::version = "1.37.0"]
|
||||
pub INTEGER_DIVISION,
|
||||
restriction,
|
||||
"integer division may cause loss of precision"
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ declare_clippy_lint! {
|
|||
/// let x: u8 = 1;
|
||||
/// (x as u32) > 300;
|
||||
/// ```
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub INVALID_UPCAST_COMPARISONS,
|
||||
pedantic,
|
||||
"a comparison involving an upcast which is always true or false"
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ declare_clippy_lint! {
|
|||
/// foo(); // prints "foo"
|
||||
/// }
|
||||
/// ```
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub ITEMS_AFTER_STATEMENTS,
|
||||
pedantic,
|
||||
"blocks where an item comes after a statement"
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ declare_clippy_lint! {
|
|||
/// }
|
||||
/// }
|
||||
/// ```
|
||||
#[clippy::version = "1.57.0"]
|
||||
pub ITER_NOT_RETURNING_ITERATOR,
|
||||
pedantic,
|
||||
"methods named `iter` or `iter_mut` that do not return an `Iterator`"
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ declare_clippy_lint! {
|
|||
/// // Good
|
||||
/// pub static a = [0u32; 1_000_000];
|
||||
/// ```
|
||||
#[clippy::version = "1.44.0"]
|
||||
pub LARGE_CONST_ARRAYS,
|
||||
perf,
|
||||
"large non-scalar const array may cause performance overhead"
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ declare_clippy_lint! {
|
|||
/// B(Box<[i32; 8000]>),
|
||||
/// }
|
||||
/// ```
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub LARGE_ENUM_VARIANT,
|
||||
perf,
|
||||
"large size difference between variants on an enum"
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ declare_clippy_lint! {
|
|||
/// ```rust,ignore
|
||||
/// let a = [0u32; 1_000_000];
|
||||
/// ```
|
||||
#[clippy::version = "1.41.0"]
|
||||
pub LARGE_STACK_ARRAYS,
|
||||
pedantic,
|
||||
"allocating large arrays on stack may cause stack overflow"
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ declare_clippy_lint! {
|
|||
/// ..
|
||||
/// }
|
||||
/// ```
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub LEN_ZERO,
|
||||
style,
|
||||
"checking `.len() == 0` or `.len() > 0` (or similar) when `.is_empty()` could be used instead"
|
||||
|
|
@ -71,6 +72,7 @@ declare_clippy_lint! {
|
|||
/// }
|
||||
/// }
|
||||
/// ```
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub LEN_WITHOUT_IS_EMPTY,
|
||||
style,
|
||||
"traits or impls with a public `len` method but no corresponding `is_empty` method"
|
||||
|
|
@ -108,6 +110,7 @@ declare_clippy_lint! {
|
|||
/// ..
|
||||
/// }
|
||||
/// ```
|
||||
#[clippy::version = "1.49.0"]
|
||||
pub COMPARISON_TO_EMPTY,
|
||||
style,
|
||||
"checking `x == \"\"` or `x == []` (or similar) when `.is_empty()` could be used instead"
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ declare_clippy_lint! {
|
|||
/// None
|
||||
/// };
|
||||
/// ```
|
||||
#[clippy::version = "pre 1.29.0"]
|
||||
pub USELESS_LET_IF_SEQ,
|
||||
nursery,
|
||||
"unidiomatic `let mut` declaration followed by initialization in `if`"
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ declare_clippy_lint! {
|
|||
/// // is_ok() is marked #[must_use]
|
||||
/// let _ = f().is_ok();
|
||||
/// ```
|
||||
#[clippy::version = "1.42.0"]
|
||||
pub LET_UNDERSCORE_MUST_USE,
|
||||
restriction,
|
||||
"non-binding let on a `#[must_use]` expression"
|
||||
|
|
@ -53,6 +54,7 @@ declare_clippy_lint! {
|
|||
/// ```rust,ignore
|
||||
/// let _lock = mutex.lock();
|
||||
/// ```
|
||||
#[clippy::version = "1.43.0"]
|
||||
pub LET_UNDERSCORE_LOCK,
|
||||
correctness,
|
||||
"non-binding let on a synchronization lock"
|
||||
|
|
@ -94,6 +96,7 @@ declare_clippy_lint! {
|
|||
/// // dropped at end of scope
|
||||
/// }
|
||||
/// ```
|
||||
#[clippy::version = "1.50.0"]
|
||||
pub LET_UNDERSCORE_DROP,
|
||||
pedantic,
|
||||
"non-binding let on a type that implements `Drop`"
|
||||
|
|
|
|||
|
|
@ -9,9 +9,11 @@ store.register_group(true, "clippy::internal", Some("clippy_internal"), vec![
|
|||
LintId::of(utils::internal_lints::DEFAULT_LINT),
|
||||
LintId::of(utils::internal_lints::IF_CHAIN_STYLE),
|
||||
LintId::of(utils::internal_lints::INTERNING_DEFINED_SYMBOL),
|
||||
LintId::of(utils::internal_lints::INVALID_CLIPPY_VERSION_ATTRIBUTE),
|
||||
LintId::of(utils::internal_lints::INVALID_PATHS),
|
||||
LintId::of(utils::internal_lints::LINT_WITHOUT_LINT_PASS),
|
||||
LintId::of(utils::internal_lints::MATCH_TYPE_ON_DIAGNOSTIC_ITEM),
|
||||
LintId::of(utils::internal_lints::MISSING_CLIPPY_VERSION_ATTRIBUTE),
|
||||
LintId::of(utils::internal_lints::OUTER_EXPN_EXPN_DATA),
|
||||
LintId::of(utils::internal_lints::PRODUCE_ICE),
|
||||
LintId::of(utils::internal_lints::UNNECESSARY_SYMBOL_STR),
|
||||
|
|
|
|||
|
|
@ -16,12 +16,16 @@ store.register_lints(&[
|
|||
#[cfg(feature = "internal-lints")]
|
||||
utils::internal_lints::INTERNING_DEFINED_SYMBOL,
|
||||
#[cfg(feature = "internal-lints")]
|
||||
utils::internal_lints::INVALID_CLIPPY_VERSION_ATTRIBUTE,
|
||||
#[cfg(feature = "internal-lints")]
|
||||
utils::internal_lints::INVALID_PATHS,
|
||||
#[cfg(feature = "internal-lints")]
|
||||
utils::internal_lints::LINT_WITHOUT_LINT_PASS,
|
||||
#[cfg(feature = "internal-lints")]
|
||||
utils::internal_lints::MATCH_TYPE_ON_DIAGNOSTIC_ITEM,
|
||||
#[cfg(feature = "internal-lints")]
|
||||
utils::internal_lints::MISSING_CLIPPY_VERSION_ATTRIBUTE,
|
||||
#[cfg(feature = "internal-lints")]
|
||||
utils::internal_lints::OUTER_EXPN_EXPN_DATA,
|
||||
#[cfg(feature = "internal-lints")]
|
||||
utils::internal_lints::PRODUCE_ICE,
|
||||
|
|
|
|||
|
|
@ -154,6 +154,10 @@ macro_rules! declare_clippy_lint {
|
|||
|
||||
#[cfg(feature = "metadata-collector-lint")]
|
||||
mod deprecated_lints;
|
||||
#[cfg_attr(
|
||||
any(feature = "internal-lints", feature = "metadata-collector-lint"),
|
||||
allow(clippy::missing_clippy_version_attribute)
|
||||
)]
|
||||
mod utils;
|
||||
|
||||
// begin lints modules, do not remove this comment, it’s used in `update_lints`
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue