Skip to content

Commit

Permalink
Added clippy::version attribute to all lints
Browse files Browse the repository at this point in the history
So, some context for this, well, more a story. I'm not used to scripting, I've never really scripted anything, even if it's a valuable skill. I just never really needed it. Now, `@flip1995` correctly suggested using a script for this in `rust-clippy#7813`...

And I decided to write a script using nushell because why not? This was a mistake... I spend way more time on this than I would like to admit. It has definitely been more than 4 hours. It shouldn't take that long, but me being new to scripting and nushell just wasn't a good mixture... Anyway, here is the script that creates another script which adds the versions. Fun...

Just execute this on the `gh-pages` branch and the resulting `replacer.sh` in `clippy_lints` and it should all work.

```nu
mv beta rust-1.56.0
mv master rust-1.57.0;

let paths = (open ./rust-1.57.0/lints.json | select id id_span | flatten | select id path);
let versions = (
    ls | where name =~ "rust-" | select name | format {name}/lints.json |
    each { open $it | select id | insert version $it | str substring "5,11" version} |
    group-by id | rotate counter-clockwise id version |
    update version {get version | first 1} | flatten | select id version);
$paths | each { |row|
    let version = ($versions | where id == ($row.id) | format {version})
    let idu = ($row.id | str upcase)
    $"sed -i '0,/($idu)/{s/pub ($idu),/#[clippy::version = "($version)"]\n    pub ($idu),/}' ($row.path)"
} | str collect ";" | save "replacer.sh";
```

And this still has some problems, but at this point I just want to be done -.-
  • Loading branch information
xFrednet committed Oct 19, 2021
1 parent 9f44c77 commit 3c032ae
Show file tree
Hide file tree
Showing 234 changed files with 487 additions and 0 deletions.
1 change: 1 addition & 0 deletions clippy_lints/src/absurd_extreme_comparisons.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ declare_clippy_lint! {
/// if vec.len() <= 0 {}
/// if 100 > i32::MAX {}
/// ```
#[clippy::version = "1.29.0"]
pub ABSURD_EXTREME_COMPARISONS,
correctness,
"a comparison with a maximum or minimum value that is always true or false"
Expand Down
1 change: 1 addition & 0 deletions clippy_lints/src/approx_const.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ declare_clippy_lint! {
/// let x = std::f32::consts::PI;
/// let y = std::f64::consts::FRAC_1_PI;
/// ```
#[clippy::version = "1.29.0"]
pub APPROX_CONSTANT,
correctness,
"the approximate of a known float constant (in `std::fXX::consts`)"
Expand Down
2 changes: 2 additions & 0 deletions clippy_lints/src/arithmetic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ declare_clippy_lint! {
/// # let a = 0;
/// a + 1;
/// ```
#[clippy::version = "1.29.0"]
pub INTEGER_ARITHMETIC,
restriction,
"any integer arithmetic expression which could overflow or panic"
Expand All @@ -43,6 +44,7 @@ declare_clippy_lint! {
/// # let a = 0.0;
/// a + 1.0;
/// ```
#[clippy::version = "1.29.0"]
pub FLOAT_ARITHMETIC,
restriction,
"any floating-point arithmetic statement"
Expand Down
1 change: 1 addition & 0 deletions clippy_lints/src/as_conversions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions clippy_lints/src/asm_syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions clippy_lints/src/assertions_on_constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!()`"
Expand Down
2 changes: 2 additions & 0 deletions clippy_lints/src/assign_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ declare_clippy_lint! {
/// // Good
/// a += b;
/// ```
#[clippy::version = "1.29.0"]
pub ASSIGN_OP_PATTERN,
style,
"assigning the result of an operation on a variable to that same variable"
Expand All @@ -60,6 +61,7 @@ declare_clippy_lint! {
/// // ...
/// a += a + b;
/// ```
#[clippy::version = "1.29.0"]
pub MISREFACTORED_ASSIGN_OP,
suspicious,
"having a variable on both sides of an assign op"
Expand Down
1 change: 1 addition & 0 deletions clippy_lints/src/async_yields_async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
7 changes: 7 additions & 0 deletions clippy_lints/src/attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ declare_clippy_lint! {
/// #[inline(always)]
/// fn not_quite_hot_code(..) { ... }
/// ```
#[clippy::version = "1.29.0"]
pub INLINE_ALWAYS,
pedantic,
"use of `#[inline(always)]`"
Expand Down Expand Up @@ -98,6 +99,7 @@ declare_clippy_lint! {
/// #[macro_use]
/// extern crate baz;
/// ```
#[clippy::version = "1.29.0"]
pub USELESS_ATTRIBUTE,
correctness,
"use of lint attributes on `extern crate` items"
Expand All @@ -117,6 +119,7 @@ declare_clippy_lint! {
/// #[deprecated(since = "forever")]
/// fn something_else() { /* ... */ }
/// ```
#[clippy::version = "1.29.0"]
pub DEPRECATED_SEMVER,
correctness,
"use of `#[deprecated(since = \"x\")]` where x is not semver"
Expand Down Expand Up @@ -154,6 +157,7 @@ declare_clippy_lint! {
/// #[allow(dead_code)]
/// fn this_is_fine_too() { }
/// ```
#[clippy::version = "1.29.0"]
pub EMPTY_LINE_AFTER_OUTER_ATTR,
nursery,
"empty line after outer attribute"
Expand All @@ -177,6 +181,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"
Expand Down Expand Up @@ -208,6 +213,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"
Expand Down Expand Up @@ -240,6 +246,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\")`"
Expand Down
2 changes: 2 additions & 0 deletions clippy_lints/src/await_holding_invalid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
3 changes: 3 additions & 0 deletions clippy_lints/src/bit_mask.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ declare_clippy_lint! {
/// # let x = 1;
/// if (x & 1 == 2) { }
/// ```
#[clippy::version = "1.29.0"]
pub BAD_BIT_MASK,
correctness,
"expressions of the form `_ & mask == select` that will only ever return `true` or `false`"
Expand Down Expand Up @@ -73,6 +74,7 @@ declare_clippy_lint! {
/// # let x = 1;
/// if (x | 1 > 3) { }
/// ```
#[clippy::version = "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`"
Expand All @@ -95,6 +97,7 @@ declare_clippy_lint! {
/// # let x = 1;
/// if x & 0b1111 == 0 { }
/// ```
#[clippy::version = "1.29.0"]
pub VERBOSE_BIT_MASK,
pedantic,
"expressions where a bit mask is less readable than the corresponding method call"
Expand Down
1 change: 1 addition & 0 deletions clippy_lints/src/blacklisted_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ declare_clippy_lint! {
/// ```rust
/// let foo = 3.14;
/// ```
#[clippy::version = "1.29.0"]
pub BLACKLISTED_NAME,
style,
"usage of a blacklisted/placeholder name"
Expand Down
1 change: 1 addition & 0 deletions clippy_lints/src/blocks_in_if_conditions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions clippy_lints/src/bool_assert_comparison.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions clippy_lints/src/booleans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ declare_clippy_lint! {
/// if a && true // should be: if a
/// if !(a == b) // should be: if a != b
/// ```
#[clippy::version = "1.29.0"]
pub NONMINIMAL_BOOL,
complexity,
"boolean expressions that can be written more concisely"
Expand All @@ -52,6 +53,7 @@ declare_clippy_lint! {
/// if a && b || a { ... }
/// ```
/// The `b` is unnecessary, the expression is equivalent to `if a`.
#[clippy::version = "1.29.0"]
pub LOGIC_BUG,
correctness,
"boolean expressions that contain terminals which can be eliminated"
Expand Down
1 change: 1 addition & 0 deletions clippy_lints/src/bytecount.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "1.29.0"]
pub NAIVE_BYTECOUNT,
pedantic,
"use of naive `<slice>.filter(|&x| x == y).count()` to count byte values"
Expand Down
1 change: 1 addition & 0 deletions clippy_lints/src/cargo_common_metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
13 changes: 13 additions & 0 deletions clippy_lints/src/casts/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ declare_clippy_lint! {
/// let x = u64::MAX;
/// x as f64;
/// ```
#[clippy::version = "1.29.0"]
pub CAST_PRECISION_LOSS,
pedantic,
"casts that cause loss of precision, e.g., `x as f32` where `x: u64`"
Expand All @@ -61,6 +62,7 @@ declare_clippy_lint! {
/// let y: i8 = -1;
/// y as u128; // will return 18446744073709551615
/// ```
#[clippy::version = "1.29.0"]
pub CAST_SIGN_LOSS,
pedantic,
"casts from signed types to unsigned types, e.g., `x as u32` where `x: i32`"
Expand All @@ -83,6 +85,7 @@ declare_clippy_lint! {
/// x as u8
/// }
/// ```
#[clippy::version = "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`"
Expand All @@ -106,6 +109,7 @@ declare_clippy_lint! {
/// ```rust
/// u32::MAX as i32; // will yield a value of `-1`
/// ```
#[clippy::version = "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`"
Expand Down Expand Up @@ -138,6 +142,7 @@ declare_clippy_lint! {
/// u64::from(x)
/// }
/// ```
#[clippy::version = "1.29.0"]
pub CAST_LOSSLESS,
pedantic,
"casts using `as` that are known to be lossless, e.g., `x as u64` where `x: u8`"
Expand All @@ -163,6 +168,7 @@ declare_clippy_lint! {
/// let _ = 2_i32;
/// let _ = 0.5_f32;
/// ```
#[clippy::version = "1.29.0"]
pub UNNECESSARY_CAST,
complexity,
"cast to the same type, e.g., `x as i32` where `x: i32`"
Expand Down Expand Up @@ -190,6 +196,7 @@ declare_clippy_lint! {
/// (&1u8 as *const u8).cast::<u16>();
/// (&mut 1u8 as *mut u8).cast::<u16>();
/// ```
#[clippy::version = "1.29.0"]
pub CAST_PTR_ALIGNMENT,
pedantic,
"cast from a pointer to a more-strictly-aligned pointer"
Expand Down Expand Up @@ -217,6 +224,7 @@ declare_clippy_lint! {
/// fn fun2() -> i32 { 1 }
/// let a = fun2 as usize;
/// ```
#[clippy::version = "1.29.0"]
pub FN_TO_NUMERIC_CAST,
style,
"casting a function pointer to a numeric type other than usize"
Expand Down Expand Up @@ -247,6 +255,7 @@ declare_clippy_lint! {
/// let fn_ptr = fn2 as usize;
/// let fn_ptr_truncated = fn_ptr as i32;
/// ```
#[clippy::version = "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"
Expand Down Expand Up @@ -283,6 +292,7 @@ declare_clippy_lint! {
/// }
/// let _ = fn3 as fn() -> u16;
/// ```
#[clippy::version = "1.57.0"]
pub FN_TO_NUMERIC_CAST_ANY,
restriction,
"casting a function pointer to any integer type"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -344,6 +355,7 @@ declare_clippy_lint! {
/// ```rust,ignore
/// b'x'
/// ```
#[clippy::version = "1.29.0"]
pub CHAR_LIT_AS_U8,
complexity,
"casting a character literal to `u8` truncates"
Expand Down Expand Up @@ -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`"
Expand Down
1 change: 1 addition & 0 deletions clippy_lints/src/checked_conversions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions clippy_lints/src/cognitive_complexity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions clippy_lints/src/collapsible_if.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ declare_clippy_lint! {
/// …
/// }
/// ```
#[clippy::version = "1.29.0"]
pub COLLAPSIBLE_IF,
style,
"nested `if`s that can be collapsed (e.g., `if x { if y { ... } }`"
Expand Down Expand Up @@ -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 { ... } }`)"
Expand Down
1 change: 1 addition & 0 deletions clippy_lints/src/collapsible_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down
1 change: 1 addition & 0 deletions clippy_lints/src/comparison_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`"
Expand Down

0 comments on commit 3c032ae

Please sign in to comment.