Skip to content

Commit cb321f4

Browse files
committed
Added clippy::version attribute to all lints
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 -.-
1 parent 5292bf3 commit cb321f4

File tree

234 files changed

+487
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

234 files changed

+487
-0
lines changed

clippy_lints/src/absurd_extreme_comparisons.rs

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ declare_clippy_lint! {
3636
/// if vec.len() <= 0 {}
3737
/// if 100 > i32::MAX {}
3838
/// ```
39+
#[clippy::version = "1.29.0"]
3940
pub ABSURD_EXTREME_COMPARISONS,
4041
correctness,
4142
"a comparison with a maximum or minimum value that is always true or false"

clippy_lints/src/approx_const.rs

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ declare_clippy_lint! {
3333
/// let x = std::f32::consts::PI;
3434
/// let y = std::f64::consts::FRAC_1_PI;
3535
/// ```
36+
#[clippy::version = "1.29.0"]
3637
pub APPROX_CONSTANT,
3738
correctness,
3839
"the approximate of a known float constant (in `std::fXX::consts`)"

clippy_lints/src/arithmetic.rs

+2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ declare_clippy_lint! {
2525
/// # let a = 0;
2626
/// a + 1;
2727
/// ```
28+
#[clippy::version = "1.29.0"]
2829
pub INTEGER_ARITHMETIC,
2930
restriction,
3031
"any integer arithmetic expression which could overflow or panic"
@@ -43,6 +44,7 @@ declare_clippy_lint! {
4344
/// # let a = 0.0;
4445
/// a + 1.0;
4546
/// ```
47+
#[clippy::version = "1.29.0"]
4648
pub FLOAT_ARITHMETIC,
4749
restriction,
4850
"any floating-point arithmetic statement"

clippy_lints/src/as_conversions.rs

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ declare_clippy_lint! {
3838
/// f(a.try_into().expect("Unexpected u16 overflow in f"));
3939
/// ```
4040
///
41+
#[clippy::version = "1.41.0"]
4142
pub AS_CONVERSIONS,
4243
restriction,
4344
"using a potentially dangerous silent `as` conversion"

clippy_lints/src/asm_syntax.rs

+2
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ declare_clippy_lint! {
7575
/// asm!("lea ({}), {}", in(reg) ptr, lateout(reg) _, options(att_syntax));
7676
/// # }
7777
/// ```
78+
#[clippy::version = "1.49.0"]
7879
pub INLINE_ASM_X86_INTEL_SYNTAX,
7980
restriction,
8081
"prefer AT&T x86 assembly syntax"
@@ -111,6 +112,7 @@ declare_clippy_lint! {
111112
/// asm!("lea {}, [{}]", lateout(reg) _, in(reg) ptr);
112113
/// # }
113114
/// ```
115+
#[clippy::version = "1.49.0"]
114116
pub INLINE_ASM_X86_ATT_SYNTAX,
115117
restriction,
116118
"prefer Intel x86 assembly syntax"

clippy_lints/src/assertions_on_constants.rs

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ declare_clippy_lint! {
2626
/// const B: bool = false;
2727
/// assert!(B)
2828
/// ```
29+
#[clippy::version = "1.34.0"]
2930
pub ASSERTIONS_ON_CONSTANTS,
3031
style,
3132
"`assert!(true)` / `assert!(false)` will be optimized out by the compiler, and should probably be replaced by a `panic!()` or `unreachable!()`"

clippy_lints/src/assign_ops.rs

+2
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ declare_clippy_lint! {
3434
/// // Good
3535
/// a += b;
3636
/// ```
37+
#[clippy::version = "1.29.0"]
3738
pub ASSIGN_OP_PATTERN,
3839
style,
3940
"assigning the result of an operation on a variable to that same variable"
@@ -60,6 +61,7 @@ declare_clippy_lint! {
6061
/// // ...
6162
/// a += a + b;
6263
/// ```
64+
#[clippy::version = "1.29.0"]
6365
pub MISREFACTORED_ASSIGN_OP,
6466
suspicious,
6567
"having a variable on both sides of an assign op"

clippy_lints/src/async_yields_async.rs

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ declare_clippy_lint! {
3434
/// };
3535
/// }
3636
/// ```
37+
#[clippy::version = "1.48.0"]
3738
pub ASYNC_YIELDS_ASYNC,
3839
correctness,
3940
"async blocks that return a type that can be awaited"

clippy_lints/src/attrs.rs

+7
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ declare_clippy_lint! {
6464
/// #[inline(always)]
6565
/// fn not_quite_hot_code(..) { ... }
6666
/// ```
67+
#[clippy::version = "1.29.0"]
6768
pub INLINE_ALWAYS,
6869
pedantic,
6970
"use of `#[inline(always)]`"
@@ -98,6 +99,7 @@ declare_clippy_lint! {
9899
/// #[macro_use]
99100
/// extern crate baz;
100101
/// ```
102+
#[clippy::version = "1.29.0"]
101103
pub USELESS_ATTRIBUTE,
102104
correctness,
103105
"use of lint attributes on `extern crate` items"
@@ -117,6 +119,7 @@ declare_clippy_lint! {
117119
/// #[deprecated(since = "forever")]
118120
/// fn something_else() { /* ... */ }
119121
/// ```
122+
#[clippy::version = "1.29.0"]
120123
pub DEPRECATED_SEMVER,
121124
correctness,
122125
"use of `#[deprecated(since = \"x\")]` where x is not semver"
@@ -154,6 +157,7 @@ declare_clippy_lint! {
154157
/// #[allow(dead_code)]
155158
/// fn this_is_fine_too() { }
156159
/// ```
160+
#[clippy::version = "1.29.0"]
157161
pub EMPTY_LINE_AFTER_OUTER_ATTR,
158162
nursery,
159163
"empty line after outer attribute"
@@ -177,6 +181,7 @@ declare_clippy_lint! {
177181
/// ```rust
178182
/// #![deny(clippy::as_conversions)]
179183
/// ```
184+
#[clippy::version = "1.47.0"]
180185
pub BLANKET_CLIPPY_RESTRICTION_LINTS,
181186
suspicious,
182187
"enabling the complete restriction group"
@@ -208,6 +213,7 @@ declare_clippy_lint! {
208213
/// #[rustfmt::skip]
209214
/// fn main() { }
210215
/// ```
216+
#[clippy::version = "1.32.0"]
211217
pub DEPRECATED_CFG_ATTR,
212218
complexity,
213219
"usage of `cfg_attr(rustfmt)` instead of tool attributes"
@@ -240,6 +246,7 @@ declare_clippy_lint! {
240246
/// fn conditional() { }
241247
/// ```
242248
/// Check the [Rust Reference](https://doc.rust-lang.org/reference/conditional-compilation.html#target_os) for more details.
249+
#[clippy::version = "1.45.0"]
243250
pub MISMATCHED_TARGET_OS,
244251
correctness,
245252
"usage of `cfg(operating_system)` instead of `cfg(target_os = \"operating_system\")`"

clippy_lints/src/await_holding_invalid.rs

+2
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ declare_clippy_lint! {
4747
/// bar.await;
4848
/// }
4949
/// ```
50+
#[clippy::version = "1.45.0"]
5051
pub AWAIT_HOLDING_LOCK,
5152
pedantic,
5253
"Inside an async function, holding a MutexGuard while calling await"
@@ -88,6 +89,7 @@ declare_clippy_lint! {
8889
/// bar.await;
8990
/// }
9091
/// ```
92+
#[clippy::version = "1.49.0"]
9193
pub AWAIT_HOLDING_REFCELL_REF,
9294
pedantic,
9395
"Inside an async function, holding a RefCell ref while calling await"

clippy_lints/src/bit_mask.rs

+3
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ declare_clippy_lint! {
4141
/// # let x = 1;
4242
/// if (x & 1 == 2) { }
4343
/// ```
44+
#[clippy::version = "1.29.0"]
4445
pub BAD_BIT_MASK,
4546
correctness,
4647
"expressions of the form `_ & mask == select` that will only ever return `true` or `false`"
@@ -73,6 +74,7 @@ declare_clippy_lint! {
7374
/// # let x = 1;
7475
/// if (x | 1 > 3) { }
7576
/// ```
77+
#[clippy::version = "1.29.0"]
7678
pub INEFFECTIVE_BIT_MASK,
7779
correctness,
7880
"expressions where a bit mask will be rendered useless by a comparison, e.g., `(x | 1) > 2`"
@@ -95,6 +97,7 @@ declare_clippy_lint! {
9597
/// # let x = 1;
9698
/// if x & 0b1111 == 0 { }
9799
/// ```
100+
#[clippy::version = "1.29.0"]
98101
pub VERBOSE_BIT_MASK,
99102
pedantic,
100103
"expressions where a bit mask is less readable than the corresponding method call"

clippy_lints/src/blacklisted_name.rs

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ declare_clippy_lint! {
1717
/// ```rust
1818
/// let foo = 3.14;
1919
/// ```
20+
#[clippy::version = "1.29.0"]
2021
pub BLACKLISTED_NAME,
2122
style,
2223
"usage of a blacklisted/placeholder name"

clippy_lints/src/blocks_in_if_conditions.rs

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ declare_clippy_lint! {
4141
/// let res = { let x = somefunc(); x };
4242
/// if res { /* ... */ }
4343
/// ```
44+
#[clippy::version = "1.45.0"]
4445
pub BLOCKS_IN_IF_CONDITIONS,
4546
style,
4647
"useless or complex blocks that can be eliminated in conditions"

clippy_lints/src/bool_assert_comparison.rs

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ declare_clippy_lint! {
2323
/// // Good
2424
/// assert!(!"a".is_empty());
2525
/// ```
26+
#[clippy::version = "1.53.0"]
2627
pub BOOL_ASSERT_COMPARISON,
2728
style,
2829
"Using a boolean as comparison value in an assert_* macro when there is no need"

clippy_lints/src/booleans.rs

+2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ declare_clippy_lint! {
3131
/// if a && true // should be: if a
3232
/// if !(a == b) // should be: if a != b
3333
/// ```
34+
#[clippy::version = "1.29.0"]
3435
pub NONMINIMAL_BOOL,
3536
complexity,
3637
"boolean expressions that can be written more concisely"
@@ -52,6 +53,7 @@ declare_clippy_lint! {
5253
/// if a && b || a { ... }
5354
/// ```
5455
/// The `b` is unnecessary, the expression is equivalent to `if a`.
56+
#[clippy::version = "1.29.0"]
5557
pub LOGIC_BUG,
5658
correctness,
5759
"boolean expressions that contain terminals which can be eliminated"

clippy_lints/src/bytecount.rs

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ declare_clippy_lint! {
3030
/// # let vec = vec![1_u8];
3131
/// &vec.iter().filter(|x| **x == 0u8).count(); // use bytecount::count instead
3232
/// ```
33+
#[clippy::version = "1.29.0"]
3334
pub NAIVE_BYTECOUNT,
3435
pedantic,
3536
"use of naive `<slice>.filter(|&x| x == y).count()` to count byte values"

clippy_lints/src/cargo_common_metadata.rs

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ declare_clippy_lint! {
4242
/// keywords = ["clippy", "lint", "plugin"]
4343
/// categories = ["development-tools", "development-tools::cargo-plugins"]
4444
/// ```
45+
#[clippy::version = "1.32.0"]
4546
pub CARGO_COMMON_METADATA,
4647
cargo,
4748
"common metadata is defined in `Cargo.toml`"

clippy_lints/src/case_sensitive_file_extension_comparisons.rs

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ declare_clippy_lint! {
2727
/// filename.rsplit('.').next().map(|ext| ext.eq_ignore_ascii_case("rs")) == Some(true)
2828
/// }
2929
/// ```
30+
#[clippy::version = "1.51.0"]
3031
pub CASE_SENSITIVE_FILE_EXTENSION_COMPARISONS,
3132
pedantic,
3233
"Checks for calls to ends_with with case-sensitive file extensions"

clippy_lints/src/casts/mod.rs

+13
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ declare_clippy_lint! {
4040
/// let x = u64::MAX;
4141
/// x as f64;
4242
/// ```
43+
#[clippy::version = "1.29.0"]
4344
pub CAST_PRECISION_LOSS,
4445
pedantic,
4546
"casts that cause loss of precision, e.g., `x as f32` where `x: u64`"
@@ -61,6 +62,7 @@ declare_clippy_lint! {
6162
/// let y: i8 = -1;
6263
/// y as u128; // will return 18446744073709551615
6364
/// ```
65+
#[clippy::version = "1.29.0"]
6466
pub CAST_SIGN_LOSS,
6567
pedantic,
6668
"casts from signed types to unsigned types, e.g., `x as u32` where `x: i32`"
@@ -83,6 +85,7 @@ declare_clippy_lint! {
8385
/// x as u8
8486
/// }
8587
/// ```
88+
#[clippy::version = "1.29.0"]
8689
pub CAST_POSSIBLE_TRUNCATION,
8790
pedantic,
8891
"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! {
106109
/// ```rust
107110
/// u32::MAX as i32; // will yield a value of `-1`
108111
/// ```
112+
#[clippy::version = "1.29.0"]
109113
pub CAST_POSSIBLE_WRAP,
110114
pedantic,
111115
"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! {
138142
/// u64::from(x)
139143
/// }
140144
/// ```
145+
#[clippy::version = "1.29.0"]
141146
pub CAST_LOSSLESS,
142147
pedantic,
143148
"casts using `as` that are known to be lossless, e.g., `x as u64` where `x: u8`"
@@ -163,6 +168,7 @@ declare_clippy_lint! {
163168
/// let _ = 2_i32;
164169
/// let _ = 0.5_f32;
165170
/// ```
171+
#[clippy::version = "1.29.0"]
166172
pub UNNECESSARY_CAST,
167173
complexity,
168174
"cast to the same type, e.g., `x as i32` where `x: i32`"
@@ -190,6 +196,7 @@ declare_clippy_lint! {
190196
/// (&1u8 as *const u8).cast::<u16>();
191197
/// (&mut 1u8 as *mut u8).cast::<u16>();
192198
/// ```
199+
#[clippy::version = "1.29.0"]
193200
pub CAST_PTR_ALIGNMENT,
194201
pedantic,
195202
"cast from a pointer to a more-strictly-aligned pointer"
@@ -217,6 +224,7 @@ declare_clippy_lint! {
217224
/// fn fun2() -> i32 { 1 }
218225
/// let a = fun2 as usize;
219226
/// ```
227+
#[clippy::version = "1.29.0"]
220228
pub FN_TO_NUMERIC_CAST,
221229
style,
222230
"casting a function pointer to a numeric type other than usize"
@@ -247,6 +255,7 @@ declare_clippy_lint! {
247255
/// let fn_ptr = fn2 as usize;
248256
/// let fn_ptr_truncated = fn_ptr as i32;
249257
/// ```
258+
#[clippy::version = "1.29.0"]
250259
pub FN_TO_NUMERIC_CAST_WITH_TRUNCATION,
251260
style,
252261
"casting a function pointer to a numeric type not wide enough to store the address"
@@ -283,6 +292,7 @@ declare_clippy_lint! {
283292
/// }
284293
/// let _ = fn3 as fn() -> u16;
285294
/// ```
295+
#[clippy::version = "1.57.0"]
286296
pub FN_TO_NUMERIC_CAST_ANY,
287297
restriction,
288298
"casting a function pointer to any integer type"
@@ -317,6 +327,7 @@ declare_clippy_lint! {
317327
/// }
318328
/// }
319329
/// ```
330+
#[clippy::version = "1.33.0"]
320331
pub CAST_REF_TO_MUT,
321332
correctness,
322333
"a cast of reference to a mutable pointer"
@@ -344,6 +355,7 @@ declare_clippy_lint! {
344355
/// ```rust,ignore
345356
/// b'x'
346357
/// ```
358+
#[clippy::version = "1.29.0"]
347359
pub CHAR_LIT_AS_U8,
348360
complexity,
349361
"casting a character literal to `u8` truncates"
@@ -372,6 +384,7 @@ declare_clippy_lint! {
372384
/// let _ = ptr.cast::<i32>();
373385
/// let _ = mut_ptr.cast::<i32>();
374386
/// ```
387+
#[clippy::version = "1.51.0"]
375388
pub PTR_AS_PTR,
376389
pedantic,
377390
"casting using `as` from and to raw pointers that doesn't change its mutability, where `pointer::cast` could take the place of `as`"

clippy_lints/src/checked_conversions.rs

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ declare_clippy_lint! {
3636
/// i32::try_from(foo).is_ok()
3737
/// # ;
3838
/// ```
39+
#[clippy::version = "1.37.0"]
3940
pub CHECKED_CONVERSIONS,
4041
pedantic,
4142
"`try_from` could replace manual bounds checking when casting"

clippy_lints/src/cognitive_complexity.rs

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ declare_clippy_lint! {
2727
///
2828
/// ### Example
2929
/// No. You'll see it when you get the warning.
30+
#[clippy::version = "1.35.0"]
3031
pub COGNITIVE_COMPLEXITY,
3132
nursery,
3233
"functions that should be split up into multiple functions"

clippy_lints/src/collapsible_if.rs

+2
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ declare_clippy_lint! {
4747
/// …
4848
/// }
4949
/// ```
50+
#[clippy::version = "1.29.0"]
5051
pub COLLAPSIBLE_IF,
5152
style,
5253
"nested `if`s that can be collapsed (e.g., `if x { if y { ... } }`"
@@ -82,6 +83,7 @@ declare_clippy_lint! {
8283
/// …
8384
/// }
8485
/// ```
86+
#[clippy::version = "1.51.0"]
8587
pub COLLAPSIBLE_ELSE_IF,
8688
style,
8789
"nested `else`-`if` expressions that can be collapsed (e.g., `else { if x { ... } }`)"

clippy_lints/src/collapsible_match.rs

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ declare_clippy_lint! {
4141
/// };
4242
/// }
4343
/// ```
44+
#[clippy::version = "1.50.0"]
4445
pub COLLAPSIBLE_MATCH,
4546
style,
4647
"Nested `match` or `if let` expressions where the patterns may be \"collapsed\" together."

clippy_lints/src/comparison_chain.rs

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ declare_clippy_lint! {
4949
/// }
5050
/// }
5151
/// ```
52+
#[clippy::version = "1.40.0"]
5253
pub COMPARISON_CHAIN,
5354
style,
5455
"`if`s that can be rewritten with `match` and `cmp`"

0 commit comments

Comments
 (0)