mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-16 01:38:09 +00:00
Auto merge of #9688 - Alexendoo:msrv-tests, r=Manishearth
Move MSRV tests into the lint specific test files There are currently two ways MSRV tests are done in the ui test suite, adding a case to the `#![clippy::msrv = "1.0"]` `tests/ui/min_rust_version_attr.rs` or adding the two `msrv_1_xx` functions to the test file of the lint in question This updates the clippy book to suggest the `msrv_1_xx` style, and replaces the tests in `tests/ui/min_rust_version_attr.rs` with ones of that style Almost the entire diff is just moving stuff around as a result, I made sure to check the line numbers the lints are emitted at correspond with the right `msrv` case, so feel free to only skim that part changelog: none
This commit is contained in:
commit
28cd1ec9b7
69 changed files with 1292 additions and 634 deletions
|
@ -478,8 +478,27 @@ impl<'tcx> LateLintPass<'tcx> for ManualStrip {
|
|||
```
|
||||
|
||||
Once the `msrv` is added to the lint, a relevant test case should be added to
|
||||
`tests/ui/min_rust_version_attr.rs` which verifies that the lint isn't emitted
|
||||
if the project's MSRV is lower.
|
||||
the lint's test file, `tests/ui/manual_strip.rs` in this example. It should
|
||||
have a case for the version below the MSRV and one with the same contents but
|
||||
for the MSRV version itself.
|
||||
|
||||
```rust
|
||||
#![feature(custom_inner_attributes)]
|
||||
|
||||
...
|
||||
|
||||
fn msrv_1_44() {
|
||||
#![clippy::msrv = "1.44"]
|
||||
|
||||
/* something that would trigger the lint */
|
||||
}
|
||||
|
||||
fn msrv_1_45() {
|
||||
#![clippy::msrv = "1.45"]
|
||||
|
||||
/* something that would trigger the lint */
|
||||
}
|
||||
```
|
||||
|
||||
As a last step, the lint should be added to the lint documentation. This is done
|
||||
in `clippy_lints/src/utils/conf.rs`:
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
// run-rustfix
|
||||
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![warn(clippy::cast_abs_to_unsigned)]
|
||||
#![allow(clippy::uninlined_format_args)]
|
||||
#![allow(clippy::uninlined_format_args, unused)]
|
||||
|
||||
fn main() {
|
||||
let x: i32 = -42;
|
||||
|
@ -30,3 +32,17 @@ fn main() {
|
|||
|
||||
let _ = (x as i64 - y as i64).unsigned_abs() as u32;
|
||||
}
|
||||
|
||||
fn msrv_1_50() {
|
||||
#![clippy::msrv = "1.50"]
|
||||
|
||||
let x: i32 = 10;
|
||||
assert_eq!(10u32, x.abs() as u32);
|
||||
}
|
||||
|
||||
fn msrv_1_51() {
|
||||
#![clippy::msrv = "1.51"]
|
||||
|
||||
let x: i32 = 10;
|
||||
assert_eq!(10u32, x.unsigned_abs());
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
// run-rustfix
|
||||
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![warn(clippy::cast_abs_to_unsigned)]
|
||||
#![allow(clippy::uninlined_format_args)]
|
||||
#![allow(clippy::uninlined_format_args, unused)]
|
||||
|
||||
fn main() {
|
||||
let x: i32 = -42;
|
||||
|
@ -30,3 +32,17 @@ fn main() {
|
|||
|
||||
let _ = (x as i64 - y as i64).abs() as u32;
|
||||
}
|
||||
|
||||
fn msrv_1_50() {
|
||||
#![clippy::msrv = "1.50"]
|
||||
|
||||
let x: i32 = 10;
|
||||
assert_eq!(10u32, x.abs() as u32);
|
||||
}
|
||||
|
||||
fn msrv_1_51() {
|
||||
#![clippy::msrv = "1.51"]
|
||||
|
||||
let x: i32 = 10;
|
||||
assert_eq!(10u32, x.abs() as u32);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error: casting the result of `i32::abs()` to u32
|
||||
--> $DIR/cast_abs_to_unsigned.rs:7:18
|
||||
--> $DIR/cast_abs_to_unsigned.rs:9:18
|
||||
|
|
||||
LL | let y: u32 = x.abs() as u32;
|
||||
| ^^^^^^^^^^^^^^ help: replace with: `x.unsigned_abs()`
|
||||
|
@ -7,100 +7,106 @@ LL | let y: u32 = x.abs() as u32;
|
|||
= note: `-D clippy::cast-abs-to-unsigned` implied by `-D warnings`
|
||||
|
||||
error: casting the result of `i32::abs()` to usize
|
||||
--> $DIR/cast_abs_to_unsigned.rs:11:20
|
||||
--> $DIR/cast_abs_to_unsigned.rs:13:20
|
||||
|
|
||||
LL | let _: usize = a.abs() as usize;
|
||||
| ^^^^^^^ help: replace with: `a.unsigned_abs()`
|
||||
|
||||
error: casting the result of `i32::abs()` to usize
|
||||
--> $DIR/cast_abs_to_unsigned.rs:12:20
|
||||
--> $DIR/cast_abs_to_unsigned.rs:14:20
|
||||
|
|
||||
LL | let _: usize = a.abs() as _;
|
||||
| ^^^^^^^ help: replace with: `a.unsigned_abs()`
|
||||
|
||||
error: casting the result of `i32::abs()` to usize
|
||||
--> $DIR/cast_abs_to_unsigned.rs:13:13
|
||||
--> $DIR/cast_abs_to_unsigned.rs:15:13
|
||||
|
|
||||
LL | let _ = a.abs() as usize;
|
||||
| ^^^^^^^ help: replace with: `a.unsigned_abs()`
|
||||
|
||||
error: casting the result of `i64::abs()` to usize
|
||||
--> $DIR/cast_abs_to_unsigned.rs:16:13
|
||||
--> $DIR/cast_abs_to_unsigned.rs:18:13
|
||||
|
|
||||
LL | let _ = a.abs() as usize;
|
||||
| ^^^^^^^ help: replace with: `a.unsigned_abs()`
|
||||
|
||||
error: casting the result of `i64::abs()` to u8
|
||||
--> $DIR/cast_abs_to_unsigned.rs:17:13
|
||||
--> $DIR/cast_abs_to_unsigned.rs:19:13
|
||||
|
|
||||
LL | let _ = a.abs() as u8;
|
||||
| ^^^^^^^ help: replace with: `a.unsigned_abs()`
|
||||
|
||||
error: casting the result of `i64::abs()` to u16
|
||||
--> $DIR/cast_abs_to_unsigned.rs:18:13
|
||||
--> $DIR/cast_abs_to_unsigned.rs:20:13
|
||||
|
|
||||
LL | let _ = a.abs() as u16;
|
||||
| ^^^^^^^ help: replace with: `a.unsigned_abs()`
|
||||
|
||||
error: casting the result of `i64::abs()` to u32
|
||||
--> $DIR/cast_abs_to_unsigned.rs:19:13
|
||||
--> $DIR/cast_abs_to_unsigned.rs:21:13
|
||||
|
|
||||
LL | let _ = a.abs() as u32;
|
||||
| ^^^^^^^ help: replace with: `a.unsigned_abs()`
|
||||
|
||||
error: casting the result of `i64::abs()` to u64
|
||||
--> $DIR/cast_abs_to_unsigned.rs:20:13
|
||||
--> $DIR/cast_abs_to_unsigned.rs:22:13
|
||||
|
|
||||
LL | let _ = a.abs() as u64;
|
||||
| ^^^^^^^^^^^^^^ help: replace with: `a.unsigned_abs()`
|
||||
|
||||
error: casting the result of `i64::abs()` to u128
|
||||
--> $DIR/cast_abs_to_unsigned.rs:21:13
|
||||
--> $DIR/cast_abs_to_unsigned.rs:23:13
|
||||
|
|
||||
LL | let _ = a.abs() as u128;
|
||||
| ^^^^^^^ help: replace with: `a.unsigned_abs()`
|
||||
|
||||
error: casting the result of `isize::abs()` to usize
|
||||
--> $DIR/cast_abs_to_unsigned.rs:24:13
|
||||
--> $DIR/cast_abs_to_unsigned.rs:26:13
|
||||
|
|
||||
LL | let _ = a.abs() as usize;
|
||||
| ^^^^^^^^^^^^^^^^ help: replace with: `a.unsigned_abs()`
|
||||
|
||||
error: casting the result of `isize::abs()` to u8
|
||||
--> $DIR/cast_abs_to_unsigned.rs:25:13
|
||||
--> $DIR/cast_abs_to_unsigned.rs:27:13
|
||||
|
|
||||
LL | let _ = a.abs() as u8;
|
||||
| ^^^^^^^ help: replace with: `a.unsigned_abs()`
|
||||
|
||||
error: casting the result of `isize::abs()` to u16
|
||||
--> $DIR/cast_abs_to_unsigned.rs:26:13
|
||||
--> $DIR/cast_abs_to_unsigned.rs:28:13
|
||||
|
|
||||
LL | let _ = a.abs() as u16;
|
||||
| ^^^^^^^ help: replace with: `a.unsigned_abs()`
|
||||
|
||||
error: casting the result of `isize::abs()` to u32
|
||||
--> $DIR/cast_abs_to_unsigned.rs:27:13
|
||||
--> $DIR/cast_abs_to_unsigned.rs:29:13
|
||||
|
|
||||
LL | let _ = a.abs() as u32;
|
||||
| ^^^^^^^ help: replace with: `a.unsigned_abs()`
|
||||
|
||||
error: casting the result of `isize::abs()` to u64
|
||||
--> $DIR/cast_abs_to_unsigned.rs:28:13
|
||||
--> $DIR/cast_abs_to_unsigned.rs:30:13
|
||||
|
|
||||
LL | let _ = a.abs() as u64;
|
||||
| ^^^^^^^ help: replace with: `a.unsigned_abs()`
|
||||
|
||||
error: casting the result of `isize::abs()` to u128
|
||||
--> $DIR/cast_abs_to_unsigned.rs:29:13
|
||||
--> $DIR/cast_abs_to_unsigned.rs:31:13
|
||||
|
|
||||
LL | let _ = a.abs() as u128;
|
||||
| ^^^^^^^ help: replace with: `a.unsigned_abs()`
|
||||
|
||||
error: casting the result of `i64::abs()` to u32
|
||||
--> $DIR/cast_abs_to_unsigned.rs:31:13
|
||||
--> $DIR/cast_abs_to_unsigned.rs:33:13
|
||||
|
|
||||
LL | let _ = (x as i64 - y as i64).abs() as u32;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `(x as i64 - y as i64).unsigned_abs()`
|
||||
|
||||
error: aborting due to 17 previous errors
|
||||
error: casting the result of `i32::abs()` to u32
|
||||
--> $DIR/cast_abs_to_unsigned.rs:47:23
|
||||
|
|
||||
LL | assert_eq!(10u32, x.abs() as u32);
|
||||
| ^^^^^^^^^^^^^^ help: replace with: `x.unsigned_abs()`
|
||||
|
||||
error: aborting due to 18 previous errors
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// run-rustfix
|
||||
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![allow(dead_code)]
|
||||
#![warn(clippy::cast_lossless)]
|
||||
|
||||
|
@ -40,3 +41,15 @@ mod cast_lossless_in_impl {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn msrv_1_27() {
|
||||
#![clippy::msrv = "1.27"]
|
||||
|
||||
let _ = true as u8;
|
||||
}
|
||||
|
||||
fn msrv_1_28() {
|
||||
#![clippy::msrv = "1.28"]
|
||||
|
||||
let _ = u8::from(true);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// run-rustfix
|
||||
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![allow(dead_code)]
|
||||
#![warn(clippy::cast_lossless)]
|
||||
|
||||
|
@ -40,3 +41,15 @@ mod cast_lossless_in_impl {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn msrv_1_27() {
|
||||
#![clippy::msrv = "1.27"]
|
||||
|
||||
let _ = true as u8;
|
||||
}
|
||||
|
||||
fn msrv_1_28() {
|
||||
#![clippy::msrv = "1.28"]
|
||||
|
||||
let _ = true as u8;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error: casting `bool` to `u8` is more cleanly stated with `u8::from(_)`
|
||||
--> $DIR/cast_lossless_bool.rs:8:13
|
||||
--> $DIR/cast_lossless_bool.rs:9:13
|
||||
|
|
||||
LL | let _ = true as u8;
|
||||
| ^^^^^^^^^^ help: try: `u8::from(true)`
|
||||
|
@ -7,76 +7,82 @@ LL | let _ = true as u8;
|
|||
= note: `-D clippy::cast-lossless` implied by `-D warnings`
|
||||
|
||||
error: casting `bool` to `u16` is more cleanly stated with `u16::from(_)`
|
||||
--> $DIR/cast_lossless_bool.rs:9:13
|
||||
--> $DIR/cast_lossless_bool.rs:10:13
|
||||
|
|
||||
LL | let _ = true as u16;
|
||||
| ^^^^^^^^^^^ help: try: `u16::from(true)`
|
||||
|
||||
error: casting `bool` to `u32` is more cleanly stated with `u32::from(_)`
|
||||
--> $DIR/cast_lossless_bool.rs:10:13
|
||||
--> $DIR/cast_lossless_bool.rs:11:13
|
||||
|
|
||||
LL | let _ = true as u32;
|
||||
| ^^^^^^^^^^^ help: try: `u32::from(true)`
|
||||
|
||||
error: casting `bool` to `u64` is more cleanly stated with `u64::from(_)`
|
||||
--> $DIR/cast_lossless_bool.rs:11:13
|
||||
--> $DIR/cast_lossless_bool.rs:12:13
|
||||
|
|
||||
LL | let _ = true as u64;
|
||||
| ^^^^^^^^^^^ help: try: `u64::from(true)`
|
||||
|
||||
error: casting `bool` to `u128` is more cleanly stated with `u128::from(_)`
|
||||
--> $DIR/cast_lossless_bool.rs:12:13
|
||||
--> $DIR/cast_lossless_bool.rs:13:13
|
||||
|
|
||||
LL | let _ = true as u128;
|
||||
| ^^^^^^^^^^^^ help: try: `u128::from(true)`
|
||||
|
||||
error: casting `bool` to `usize` is more cleanly stated with `usize::from(_)`
|
||||
--> $DIR/cast_lossless_bool.rs:13:13
|
||||
--> $DIR/cast_lossless_bool.rs:14:13
|
||||
|
|
||||
LL | let _ = true as usize;
|
||||
| ^^^^^^^^^^^^^ help: try: `usize::from(true)`
|
||||
|
||||
error: casting `bool` to `i8` is more cleanly stated with `i8::from(_)`
|
||||
--> $DIR/cast_lossless_bool.rs:15:13
|
||||
--> $DIR/cast_lossless_bool.rs:16:13
|
||||
|
|
||||
LL | let _ = true as i8;
|
||||
| ^^^^^^^^^^ help: try: `i8::from(true)`
|
||||
|
||||
error: casting `bool` to `i16` is more cleanly stated with `i16::from(_)`
|
||||
--> $DIR/cast_lossless_bool.rs:16:13
|
||||
--> $DIR/cast_lossless_bool.rs:17:13
|
||||
|
|
||||
LL | let _ = true as i16;
|
||||
| ^^^^^^^^^^^ help: try: `i16::from(true)`
|
||||
|
||||
error: casting `bool` to `i32` is more cleanly stated with `i32::from(_)`
|
||||
--> $DIR/cast_lossless_bool.rs:17:13
|
||||
--> $DIR/cast_lossless_bool.rs:18:13
|
||||
|
|
||||
LL | let _ = true as i32;
|
||||
| ^^^^^^^^^^^ help: try: `i32::from(true)`
|
||||
|
||||
error: casting `bool` to `i64` is more cleanly stated with `i64::from(_)`
|
||||
--> $DIR/cast_lossless_bool.rs:18:13
|
||||
--> $DIR/cast_lossless_bool.rs:19:13
|
||||
|
|
||||
LL | let _ = true as i64;
|
||||
| ^^^^^^^^^^^ help: try: `i64::from(true)`
|
||||
|
||||
error: casting `bool` to `i128` is more cleanly stated with `i128::from(_)`
|
||||
--> $DIR/cast_lossless_bool.rs:19:13
|
||||
--> $DIR/cast_lossless_bool.rs:20:13
|
||||
|
|
||||
LL | let _ = true as i128;
|
||||
| ^^^^^^^^^^^^ help: try: `i128::from(true)`
|
||||
|
||||
error: casting `bool` to `isize` is more cleanly stated with `isize::from(_)`
|
||||
--> $DIR/cast_lossless_bool.rs:20:13
|
||||
--> $DIR/cast_lossless_bool.rs:21:13
|
||||
|
|
||||
LL | let _ = true as isize;
|
||||
| ^^^^^^^^^^^^^ help: try: `isize::from(true)`
|
||||
|
||||
error: casting `bool` to `u16` is more cleanly stated with `u16::from(_)`
|
||||
--> $DIR/cast_lossless_bool.rs:23:13
|
||||
--> $DIR/cast_lossless_bool.rs:24:13
|
||||
|
|
||||
LL | let _ = (true | false) as u16;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ help: try: `u16::from(true | false)`
|
||||
|
||||
error: aborting due to 13 previous errors
|
||||
error: casting `bool` to `u8` is more cleanly stated with `u8::from(_)`
|
||||
--> $DIR/cast_lossless_bool.rs:54:13
|
||||
|
|
||||
LL | let _ = true as u8;
|
||||
| ^^^^^^^^^^ help: try: `u8::from(true)`
|
||||
|
||||
error: aborting due to 14 previous errors
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// run-rustfix
|
||||
#![feature(stmt_expr_attributes)]
|
||||
#![feature(stmt_expr_attributes, custom_inner_attributes)]
|
||||
|
||||
#![allow(unused, clippy::no_effect, clippy::unnecessary_operation)]
|
||||
#![warn(clippy::deprecated_cfg_attr)]
|
||||
|
@ -29,3 +29,17 @@ mod foo {
|
|||
|
||||
pub fn f() {}
|
||||
}
|
||||
|
||||
fn msrv_1_29() {
|
||||
#![clippy::msrv = "1.29"]
|
||||
|
||||
#[cfg_attr(rustfmt, rustfmt::skip)]
|
||||
1+29;
|
||||
}
|
||||
|
||||
fn msrv_1_30() {
|
||||
#![clippy::msrv = "1.30"]
|
||||
|
||||
#[rustfmt::skip]
|
||||
1+30;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// run-rustfix
|
||||
#![feature(stmt_expr_attributes)]
|
||||
#![feature(stmt_expr_attributes, custom_inner_attributes)]
|
||||
|
||||
#![allow(unused, clippy::no_effect, clippy::unnecessary_operation)]
|
||||
#![warn(clippy::deprecated_cfg_attr)]
|
||||
|
@ -29,3 +29,17 @@ mod foo {
|
|||
|
||||
pub fn f() {}
|
||||
}
|
||||
|
||||
fn msrv_1_29() {
|
||||
#![clippy::msrv = "1.29"]
|
||||
|
||||
#[cfg_attr(rustfmt, rustfmt::skip)]
|
||||
1+29;
|
||||
}
|
||||
|
||||
fn msrv_1_30() {
|
||||
#![clippy::msrv = "1.30"]
|
||||
|
||||
#[cfg_attr(rustfmt, rustfmt::skip)]
|
||||
1+30;
|
||||
}
|
||||
|
|
|
@ -12,5 +12,11 @@ error: `cfg_attr` is deprecated for rustfmt and got replaced by tool attributes
|
|||
LL | #[cfg_attr(rustfmt, rustfmt_skip)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `#[rustfmt::skip]`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
error: `cfg_attr` is deprecated for rustfmt and got replaced by tool attributes
|
||||
--> $DIR/cfg_attr_rustfmt.rs:43:5
|
||||
|
|
||||
LL | #[cfg_attr(rustfmt, rustfmt::skip)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `#[rustfmt::skip]`
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
// run-rustfix
|
||||
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![allow(
|
||||
clippy::cast_lossless,
|
||||
unused,
|
||||
// Int::max_value will be deprecated in the future
|
||||
deprecated,
|
||||
)]
|
||||
|
@ -76,4 +78,18 @@ pub const fn issue_8898(i: u32) -> bool {
|
|||
i <= i32::MAX as u32
|
||||
}
|
||||
|
||||
fn msrv_1_33() {
|
||||
#![clippy::msrv = "1.33"]
|
||||
|
||||
let value: i64 = 33;
|
||||
let _ = value <= (u32::MAX as i64) && value >= 0;
|
||||
}
|
||||
|
||||
fn msrv_1_34() {
|
||||
#![clippy::msrv = "1.34"]
|
||||
|
||||
let value: i64 = 34;
|
||||
let _ = u32::try_from(value).is_ok();
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
// run-rustfix
|
||||
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![allow(
|
||||
clippy::cast_lossless,
|
||||
unused,
|
||||
// Int::max_value will be deprecated in the future
|
||||
deprecated,
|
||||
)]
|
||||
|
@ -76,4 +78,18 @@ pub const fn issue_8898(i: u32) -> bool {
|
|||
i <= i32::MAX as u32
|
||||
}
|
||||
|
||||
fn msrv_1_33() {
|
||||
#![clippy::msrv = "1.33"]
|
||||
|
||||
let value: i64 = 33;
|
||||
let _ = value <= (u32::MAX as i64) && value >= 0;
|
||||
}
|
||||
|
||||
fn msrv_1_34() {
|
||||
#![clippy::msrv = "1.34"]
|
||||
|
||||
let value: i64 = 34;
|
||||
let _ = value <= (u32::MAX as i64) && value >= 0;
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error: checked cast can be simplified
|
||||
--> $DIR/checked_conversions.rs:15:13
|
||||
--> $DIR/checked_conversions.rs:17:13
|
||||
|
|
||||
LL | let _ = value <= (u32::max_value() as i64) && value >= 0;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `u32::try_from(value).is_ok()`
|
||||
|
@ -7,94 +7,100 @@ LL | let _ = value <= (u32::max_value() as i64) && value >= 0;
|
|||
= note: `-D clippy::checked-conversions` implied by `-D warnings`
|
||||
|
||||
error: checked cast can be simplified
|
||||
--> $DIR/checked_conversions.rs:16:13
|
||||
--> $DIR/checked_conversions.rs:18:13
|
||||
|
|
||||
LL | let _ = value <= (u32::MAX as i64) && value >= 0;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `u32::try_from(value).is_ok()`
|
||||
|
||||
error: checked cast can be simplified
|
||||
--> $DIR/checked_conversions.rs:20:13
|
||||
--> $DIR/checked_conversions.rs:22:13
|
||||
|
|
||||
LL | let _ = value <= i64::from(u16::max_value()) && value >= 0;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `u16::try_from(value).is_ok()`
|
||||
|
||||
error: checked cast can be simplified
|
||||
--> $DIR/checked_conversions.rs:21:13
|
||||
--> $DIR/checked_conversions.rs:23:13
|
||||
|
|
||||
LL | let _ = value <= i64::from(u16::MAX) && value >= 0;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `u16::try_from(value).is_ok()`
|
||||
|
||||
error: checked cast can be simplified
|
||||
--> $DIR/checked_conversions.rs:25:13
|
||||
--> $DIR/checked_conversions.rs:27:13
|
||||
|
|
||||
LL | let _ = value <= (u8::max_value() as isize) && value >= 0;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `u8::try_from(value).is_ok()`
|
||||
|
||||
error: checked cast can be simplified
|
||||
--> $DIR/checked_conversions.rs:26:13
|
||||
--> $DIR/checked_conversions.rs:28:13
|
||||
|
|
||||
LL | let _ = value <= (u8::MAX as isize) && value >= 0;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `u8::try_from(value).is_ok()`
|
||||
|
||||
error: checked cast can be simplified
|
||||
--> $DIR/checked_conversions.rs:32:13
|
||||
--> $DIR/checked_conversions.rs:34:13
|
||||
|
|
||||
LL | let _ = value <= (i32::max_value() as i64) && value >= (i32::min_value() as i64);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `i32::try_from(value).is_ok()`
|
||||
|
||||
error: checked cast can be simplified
|
||||
--> $DIR/checked_conversions.rs:33:13
|
||||
--> $DIR/checked_conversions.rs:35:13
|
||||
|
|
||||
LL | let _ = value <= (i32::MAX as i64) && value >= (i32::MIN as i64);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `i32::try_from(value).is_ok()`
|
||||
|
||||
error: checked cast can be simplified
|
||||
--> $DIR/checked_conversions.rs:37:13
|
||||
--> $DIR/checked_conversions.rs:39:13
|
||||
|
|
||||
LL | let _ = value <= i64::from(i16::max_value()) && value >= i64::from(i16::min_value());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `i16::try_from(value).is_ok()`
|
||||
|
||||
error: checked cast can be simplified
|
||||
--> $DIR/checked_conversions.rs:38:13
|
||||
--> $DIR/checked_conversions.rs:40:13
|
||||
|
|
||||
LL | let _ = value <= i64::from(i16::MAX) && value >= i64::from(i16::MIN);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `i16::try_from(value).is_ok()`
|
||||
|
||||
error: checked cast can be simplified
|
||||
--> $DIR/checked_conversions.rs:44:13
|
||||
--> $DIR/checked_conversions.rs:46:13
|
||||
|
|
||||
LL | let _ = value <= i32::max_value() as u32;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `i32::try_from(value).is_ok()`
|
||||
|
||||
error: checked cast can be simplified
|
||||
--> $DIR/checked_conversions.rs:45:13
|
||||
--> $DIR/checked_conversions.rs:47:13
|
||||
|
|
||||
LL | let _ = value <= i32::MAX as u32;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `i32::try_from(value).is_ok()`
|
||||
|
||||
error: checked cast can be simplified
|
||||
--> $DIR/checked_conversions.rs:49:13
|
||||
--> $DIR/checked_conversions.rs:51:13
|
||||
|
|
||||
LL | let _ = value <= isize::max_value() as usize && value as i32 == 5;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `isize::try_from(value).is_ok()`
|
||||
|
||||
error: checked cast can be simplified
|
||||
--> $DIR/checked_conversions.rs:50:13
|
||||
--> $DIR/checked_conversions.rs:52:13
|
||||
|
|
||||
LL | let _ = value <= isize::MAX as usize && value as i32 == 5;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `isize::try_from(value).is_ok()`
|
||||
|
||||
error: checked cast can be simplified
|
||||
--> $DIR/checked_conversions.rs:54:13
|
||||
--> $DIR/checked_conversions.rs:56:13
|
||||
|
|
||||
LL | let _ = value <= u16::max_value() as u32 && value as i32 == 5;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `u16::try_from(value).is_ok()`
|
||||
|
||||
error: checked cast can be simplified
|
||||
--> $DIR/checked_conversions.rs:55:13
|
||||
--> $DIR/checked_conversions.rs:57:13
|
||||
|
|
||||
LL | let _ = value <= u16::MAX as u32 && value as i32 == 5;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `u16::try_from(value).is_ok()`
|
||||
|
||||
error: aborting due to 16 previous errors
|
||||
error: checked cast can be simplified
|
||||
--> $DIR/checked_conversions.rs:92:13
|
||||
|
|
||||
LL | let _ = value <= (u32::MAX as i64) && value >= 0;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `u32::try_from(value).is_ok()`
|
||||
|
||||
error: aborting due to 17 previous errors
|
||||
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
// run-rustfix
|
||||
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![warn(clippy::cloned_instead_of_copied)]
|
||||
#![allow(unused)]
|
||||
|
||||
fn main() {
|
||||
// yay
|
||||
|
@ -13,3 +16,24 @@ fn main() {
|
|||
let _ = [String::new()].iter().cloned();
|
||||
let _ = Some(&String::new()).cloned();
|
||||
}
|
||||
|
||||
fn msrv_1_34() {
|
||||
#![clippy::msrv = "1.34"]
|
||||
|
||||
let _ = [1].iter().cloned();
|
||||
let _ = Some(&1).cloned();
|
||||
}
|
||||
|
||||
fn msrv_1_35() {
|
||||
#![clippy::msrv = "1.35"]
|
||||
|
||||
let _ = [1].iter().cloned();
|
||||
let _ = Some(&1).copied(); // Option::copied needs 1.35
|
||||
}
|
||||
|
||||
fn msrv_1_36() {
|
||||
#![clippy::msrv = "1.36"]
|
||||
|
||||
let _ = [1].iter().copied(); // Iterator::copied needs 1.36
|
||||
let _ = Some(&1).copied();
|
||||
}
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
// run-rustfix
|
||||
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![warn(clippy::cloned_instead_of_copied)]
|
||||
#![allow(unused)]
|
||||
|
||||
fn main() {
|
||||
// yay
|
||||
|
@ -13,3 +16,24 @@ fn main() {
|
|||
let _ = [String::new()].iter().cloned();
|
||||
let _ = Some(&String::new()).cloned();
|
||||
}
|
||||
|
||||
fn msrv_1_34() {
|
||||
#![clippy::msrv = "1.34"]
|
||||
|
||||
let _ = [1].iter().cloned();
|
||||
let _ = Some(&1).cloned();
|
||||
}
|
||||
|
||||
fn msrv_1_35() {
|
||||
#![clippy::msrv = "1.35"]
|
||||
|
||||
let _ = [1].iter().cloned();
|
||||
let _ = Some(&1).cloned(); // Option::copied needs 1.35
|
||||
}
|
||||
|
||||
fn msrv_1_36() {
|
||||
#![clippy::msrv = "1.36"]
|
||||
|
||||
let _ = [1].iter().cloned(); // Iterator::copied needs 1.36
|
||||
let _ = Some(&1).cloned();
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error: used `cloned` where `copied` could be used instead
|
||||
--> $DIR/cloned_instead_of_copied.rs:6:24
|
||||
--> $DIR/cloned_instead_of_copied.rs:9:24
|
||||
|
|
||||
LL | let _ = [1].iter().cloned();
|
||||
| ^^^^^^ help: try: `copied`
|
||||
|
@ -7,28 +7,46 @@ LL | let _ = [1].iter().cloned();
|
|||
= note: `-D clippy::cloned-instead-of-copied` implied by `-D warnings`
|
||||
|
||||
error: used `cloned` where `copied` could be used instead
|
||||
--> $DIR/cloned_instead_of_copied.rs:7:31
|
||||
--> $DIR/cloned_instead_of_copied.rs:10:31
|
||||
|
|
||||
LL | let _ = vec!["hi"].iter().cloned();
|
||||
| ^^^^^^ help: try: `copied`
|
||||
|
||||
error: used `cloned` where `copied` could be used instead
|
||||
--> $DIR/cloned_instead_of_copied.rs:8:22
|
||||
--> $DIR/cloned_instead_of_copied.rs:11:22
|
||||
|
|
||||
LL | let _ = Some(&1).cloned();
|
||||
| ^^^^^^ help: try: `copied`
|
||||
|
||||
error: used `cloned` where `copied` could be used instead
|
||||
--> $DIR/cloned_instead_of_copied.rs:9:34
|
||||
--> $DIR/cloned_instead_of_copied.rs:12:34
|
||||
|
|
||||
LL | let _ = Box::new([1].iter()).cloned();
|
||||
| ^^^^^^ help: try: `copied`
|
||||
|
||||
error: used `cloned` where `copied` could be used instead
|
||||
--> $DIR/cloned_instead_of_copied.rs:10:32
|
||||
--> $DIR/cloned_instead_of_copied.rs:13:32
|
||||
|
|
||||
LL | let _ = Box::new(Some(&1)).cloned();
|
||||
| ^^^^^^ help: try: `copied`
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
error: used `cloned` where `copied` could be used instead
|
||||
--> $DIR/cloned_instead_of_copied.rs:31:22
|
||||
|
|
||||
LL | let _ = Some(&1).cloned(); // Option::copied needs 1.35
|
||||
| ^^^^^^ help: try: `copied`
|
||||
|
||||
error: used `cloned` where `copied` could be used instead
|
||||
--> $DIR/cloned_instead_of_copied.rs:37:24
|
||||
|
|
||||
LL | let _ = [1].iter().cloned(); // Iterator::copied needs 1.36
|
||||
| ^^^^^^ help: try: `copied`
|
||||
|
||||
error: used `cloned` where `copied` could be used instead
|
||||
--> $DIR/cloned_instead_of_copied.rs:38:22
|
||||
|
|
||||
LL | let _ = Some(&1).cloned();
|
||||
| ^^^^^^ help: try: `copied`
|
||||
|
||||
error: aborting due to 8 previous errors
|
||||
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
// run-rustfix
|
||||
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![allow(unused)]
|
||||
|
||||
struct MyTypeNonDebug;
|
||||
|
||||
#[derive(Debug)]
|
||||
|
@ -12,3 +15,17 @@ fn main() {
|
|||
let test_non_debug: Result<MyTypeNonDebug, u32> = Ok(MyTypeNonDebug);
|
||||
test_non_debug.err().expect("Testing non debug type");
|
||||
}
|
||||
|
||||
fn msrv_1_16() {
|
||||
#![clippy::msrv = "1.16"]
|
||||
|
||||
let x: Result<u32, &str> = Ok(16);
|
||||
x.err().expect("16");
|
||||
}
|
||||
|
||||
fn msrv_1_17() {
|
||||
#![clippy::msrv = "1.17"]
|
||||
|
||||
let x: Result<u32, &str> = Ok(17);
|
||||
x.expect_err("17");
|
||||
}
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
// run-rustfix
|
||||
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![allow(unused)]
|
||||
|
||||
struct MyTypeNonDebug;
|
||||
|
||||
#[derive(Debug)]
|
||||
|
@ -12,3 +15,17 @@ fn main() {
|
|||
let test_non_debug: Result<MyTypeNonDebug, u32> = Ok(MyTypeNonDebug);
|
||||
test_non_debug.err().expect("Testing non debug type");
|
||||
}
|
||||
|
||||
fn msrv_1_16() {
|
||||
#![clippy::msrv = "1.16"]
|
||||
|
||||
let x: Result<u32, &str> = Ok(16);
|
||||
x.err().expect("16");
|
||||
}
|
||||
|
||||
fn msrv_1_17() {
|
||||
#![clippy::msrv = "1.17"]
|
||||
|
||||
let x: Result<u32, &str> = Ok(17);
|
||||
x.err().expect("17");
|
||||
}
|
||||
|
|
|
@ -1,10 +1,16 @@
|
|||
error: called `.err().expect()` on a `Result` value
|
||||
--> $DIR/err_expect.rs:10:16
|
||||
--> $DIR/err_expect.rs:13:16
|
||||
|
|
||||
LL | test_debug.err().expect("Testing debug type");
|
||||
| ^^^^^^^^^^^^ help: try: `expect_err`
|
||||
|
|
||||
= note: `-D clippy::err-expect` implied by `-D warnings`
|
||||
|
||||
error: aborting due to previous error
|
||||
error: called `.err().expect()` on a `Result` value
|
||||
--> $DIR/err_expect.rs:30:7
|
||||
|
|
||||
LL | x.err().expect("17");
|
||||
| ^^^^^^^^^^^^ help: try: `expect_err`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
// run-rustfix
|
||||
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![warn(clippy::all, clippy::pedantic)]
|
||||
#![allow(unused)]
|
||||
|
||||
fn main() {
|
||||
let a = ["1", "lol", "3", "NaN", "5"];
|
||||
|
@ -8,3 +10,17 @@ fn main() {
|
|||
let element: Option<i32> = a.iter().find_map(|s| s.parse().ok());
|
||||
assert_eq!(element, Some(1));
|
||||
}
|
||||
|
||||
fn msrv_1_29() {
|
||||
#![clippy::msrv = "1.29"]
|
||||
|
||||
let a = ["1", "lol", "3", "NaN", "5"];
|
||||
let _: Option<i32> = a.iter().filter_map(|s| s.parse().ok()).next();
|
||||
}
|
||||
|
||||
fn msrv_1_30() {
|
||||
#![clippy::msrv = "1.30"]
|
||||
|
||||
let a = ["1", "lol", "3", "NaN", "5"];
|
||||
let _: Option<i32> = a.iter().find_map(|s| s.parse().ok());
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
// run-rustfix
|
||||
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![warn(clippy::all, clippy::pedantic)]
|
||||
#![allow(unused)]
|
||||
|
||||
fn main() {
|
||||
let a = ["1", "lol", "3", "NaN", "5"];
|
||||
|
@ -8,3 +10,17 @@ fn main() {
|
|||
let element: Option<i32> = a.iter().filter_map(|s| s.parse().ok()).next();
|
||||
assert_eq!(element, Some(1));
|
||||
}
|
||||
|
||||
fn msrv_1_29() {
|
||||
#![clippy::msrv = "1.29"]
|
||||
|
||||
let a = ["1", "lol", "3", "NaN", "5"];
|
||||
let _: Option<i32> = a.iter().filter_map(|s| s.parse().ok()).next();
|
||||
}
|
||||
|
||||
fn msrv_1_30() {
|
||||
#![clippy::msrv = "1.30"]
|
||||
|
||||
let a = ["1", "lol", "3", "NaN", "5"];
|
||||
let _: Option<i32> = a.iter().filter_map(|s| s.parse().ok()).next();
|
||||
}
|
||||
|
|
|
@ -1,10 +1,16 @@
|
|||
error: called `filter_map(..).next()` on an `Iterator`. This is more succinctly expressed by calling `.find_map(..)` instead
|
||||
--> $DIR/filter_map_next_fixable.rs:8:32
|
||||
--> $DIR/filter_map_next_fixable.rs:10:32
|
||||
|
|
||||
LL | let element: Option<i32> = a.iter().filter_map(|s| s.parse().ok()).next();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `a.iter().find_map(|s| s.parse().ok())`
|
||||
|
|
||||
= note: `-D clippy::filter-map-next` implied by `-D warnings`
|
||||
|
||||
error: aborting due to previous error
|
||||
error: called `filter_map(..).next()` on an `Iterator`. This is more succinctly expressed by calling `.find_map(..)` instead
|
||||
--> $DIR/filter_map_next_fixable.rs:25:26
|
||||
|
|
||||
LL | let _: Option<i32> = a.iter().filter_map(|s| s.parse().ok()).next();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `a.iter().find_map(|s| s.parse().ok())`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// run-rustfix
|
||||
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![warn(clippy::from_over_into)]
|
||||
#![allow(unused)]
|
||||
|
||||
|
@ -59,4 +60,28 @@ impl From<String> for A {
|
|||
}
|
||||
}
|
||||
|
||||
fn msrv_1_40() {
|
||||
#![clippy::msrv = "1.40"]
|
||||
|
||||
struct FromOverInto<T>(Vec<T>);
|
||||
|
||||
impl<T> Into<FromOverInto<T>> for Vec<T> {
|
||||
fn into(self) -> FromOverInto<T> {
|
||||
FromOverInto(self)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn msrv_1_41() {
|
||||
#![clippy::msrv = "1.41"]
|
||||
|
||||
struct FromOverInto<T>(Vec<T>);
|
||||
|
||||
impl<T> From<Vec<T>> for FromOverInto<T> {
|
||||
fn from(val: Vec<T>) -> Self {
|
||||
FromOverInto(val)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// run-rustfix
|
||||
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![warn(clippy::from_over_into)]
|
||||
#![allow(unused)]
|
||||
|
||||
|
@ -59,4 +60,28 @@ impl From<String> for A {
|
|||
}
|
||||
}
|
||||
|
||||
fn msrv_1_40() {
|
||||
#![clippy::msrv = "1.40"]
|
||||
|
||||
struct FromOverInto<T>(Vec<T>);
|
||||
|
||||
impl<T> Into<FromOverInto<T>> for Vec<T> {
|
||||
fn into(self) -> FromOverInto<T> {
|
||||
FromOverInto(self)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn msrv_1_41() {
|
||||
#![clippy::msrv = "1.41"]
|
||||
|
||||
struct FromOverInto<T>(Vec<T>);
|
||||
|
||||
impl<T> Into<FromOverInto<T>> for Vec<T> {
|
||||
fn into(self) -> FromOverInto<T> {
|
||||
FromOverInto(self)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error: an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true
|
||||
--> $DIR/from_over_into.rs:9:1
|
||||
--> $DIR/from_over_into.rs:10:1
|
||||
|
|
||||
LL | impl Into<StringWrapper> for String {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -13,7 +13,7 @@ LL ~ StringWrapper(val)
|
|||
|
|
||||
|
||||
error: an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true
|
||||
--> $DIR/from_over_into.rs:17:1
|
||||
--> $DIR/from_over_into.rs:18:1
|
||||
|
|
||||
LL | impl Into<SelfType> for String {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -26,7 +26,7 @@ LL ~ SelfType(String::new())
|
|||
|
|
||||
|
||||
error: an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true
|
||||
--> $DIR/from_over_into.rs:32:1
|
||||
--> $DIR/from_over_into.rs:33:1
|
||||
|
|
||||
LL | impl Into<SelfKeywords> for X {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -41,7 +41,7 @@ LL ~ let _: X = val;
|
|||
|
|
||||
|
||||
error: an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true
|
||||
--> $DIR/from_over_into.rs:44:1
|
||||
--> $DIR/from_over_into.rs:45:1
|
||||
|
|
||||
LL | impl core::convert::Into<bool> for crate::ExplicitPaths {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -58,5 +58,18 @@ LL ~ val.0 = false;
|
|||
LL ~ val.0
|
||||
|
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
error: an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true
|
||||
--> $DIR/from_over_into.rs:80:5
|
||||
|
|
||||
LL | impl<T> Into<FromOverInto<T>> for Vec<T> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
help: replace the `Into` implentation with `From<std::vec::Vec<T>>`
|
||||
|
|
||||
LL ~ impl<T> From<Vec<T>> for FromOverInto<T> {
|
||||
LL ~ fn from(val: Vec<T>) -> Self {
|
||||
LL ~ FromOverInto(val)
|
||||
|
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#![feature(custom_inner_attributes)]
|
||||
#![warn(clippy::manual_clamp)]
|
||||
#![allow(
|
||||
unused,
|
||||
|
@ -302,3 +303,29 @@ fn dont_tell_me_what_to_do() {
|
|||
fn cmp_min_max(input: i32) -> i32 {
|
||||
input * 3
|
||||
}
|
||||
|
||||
fn msrv_1_49() {
|
||||
#![clippy::msrv = "1.49"]
|
||||
|
||||
let (input, min, max) = (0, -1, 2);
|
||||
let _ = if input < min {
|
||||
min
|
||||
} else if input > max {
|
||||
max
|
||||
} else {
|
||||
input
|
||||
};
|
||||
}
|
||||
|
||||
fn msrv_1_50() {
|
||||
#![clippy::msrv = "1.50"]
|
||||
|
||||
let (input, min, max) = (0, -1, 2);
|
||||
let _ = if input < min {
|
||||
min
|
||||
} else if input > max {
|
||||
max
|
||||
} else {
|
||||
input
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error: clamp-like pattern without using clamp function
|
||||
--> $DIR/manual_clamp.rs:76:5
|
||||
--> $DIR/manual_clamp.rs:77:5
|
||||
|
|
||||
LL | / if x9 < min {
|
||||
LL | | x9 = min;
|
||||
|
@ -13,7 +13,7 @@ LL | | }
|
|||
= note: `-D clippy::manual-clamp` implied by `-D warnings`
|
||||
|
||||
error: clamp-like pattern without using clamp function
|
||||
--> $DIR/manual_clamp.rs:91:5
|
||||
--> $DIR/manual_clamp.rs:92:5
|
||||
|
|
||||
LL | / if x11 > max {
|
||||
LL | | x11 = max;
|
||||
|
@ -26,7 +26,7 @@ LL | | }
|
|||
= note: clamp will panic if max < min
|
||||
|
||||
error: clamp-like pattern without using clamp function
|
||||
--> $DIR/manual_clamp.rs:99:5
|
||||
--> $DIR/manual_clamp.rs:100:5
|
||||
|
|
||||
LL | / if min > x12 {
|
||||
LL | | x12 = min;
|
||||
|
@ -39,7 +39,7 @@ LL | | }
|
|||
= note: clamp will panic if max < min
|
||||
|
||||
error: clamp-like pattern without using clamp function
|
||||
--> $DIR/manual_clamp.rs:107:5
|
||||
--> $DIR/manual_clamp.rs:108:5
|
||||
|
|
||||
LL | / if max < x13 {
|
||||
LL | | x13 = max;
|
||||
|
@ -52,7 +52,7 @@ LL | | }
|
|||
= note: clamp will panic if max < min
|
||||
|
||||
error: clamp-like pattern without using clamp function
|
||||
--> $DIR/manual_clamp.rs:161:5
|
||||
--> $DIR/manual_clamp.rs:162:5
|
||||
|
|
||||
LL | / if max < x33 {
|
||||
LL | | x33 = max;
|
||||
|
@ -65,7 +65,7 @@ LL | | }
|
|||
= note: clamp will panic if max < min
|
||||
|
||||
error: clamp-like pattern without using clamp function
|
||||
--> $DIR/manual_clamp.rs:21:14
|
||||
--> $DIR/manual_clamp.rs:22:14
|
||||
|
|
||||
LL | let x0 = if max < input {
|
||||
| ______________^
|
||||
|
@ -80,7 +80,7 @@ LL | | };
|
|||
= note: clamp will panic if max < min
|
||||
|
||||
error: clamp-like pattern without using clamp function
|
||||
--> $DIR/manual_clamp.rs:29:14
|
||||
--> $DIR/manual_clamp.rs:30:14
|
||||
|
|
||||
LL | let x1 = if input > max {
|
||||
| ______________^
|
||||
|
@ -95,7 +95,7 @@ LL | | };
|
|||
= note: clamp will panic if max < min
|
||||
|
||||
error: clamp-like pattern without using clamp function
|
||||
--> $DIR/manual_clamp.rs:37:14
|
||||
--> $DIR/manual_clamp.rs:38:14
|
||||
|
|
||||
LL | let x2 = if input < min {
|
||||
| ______________^
|
||||
|
@ -110,7 +110,7 @@ LL | | };
|
|||
= note: clamp will panic if max < min
|
||||
|
||||
error: clamp-like pattern without using clamp function
|
||||
--> $DIR/manual_clamp.rs:45:14
|
||||
--> $DIR/manual_clamp.rs:46:14
|
||||
|
|
||||
LL | let x3 = if min > input {
|
||||
| ______________^
|
||||
|
@ -125,7 +125,7 @@ LL | | };
|
|||
= note: clamp will panic if max < min
|
||||
|
||||
error: clamp-like pattern without using clamp function
|
||||
--> $DIR/manual_clamp.rs:53:14
|
||||
--> $DIR/manual_clamp.rs:54:14
|
||||
|
|
||||
LL | let x4 = input.max(min).min(max);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(min, max)`
|
||||
|
@ -133,7 +133,7 @@ LL | let x4 = input.max(min).min(max);
|
|||
= note: clamp will panic if max < min
|
||||
|
||||
error: clamp-like pattern without using clamp function
|
||||
--> $DIR/manual_clamp.rs:55:14
|
||||
--> $DIR/manual_clamp.rs:56:14
|
||||
|
|
||||
LL | let x5 = input.min(max).max(min);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(min, max)`
|
||||
|
@ -141,7 +141,7 @@ LL | let x5 = input.min(max).max(min);
|
|||
= note: clamp will panic if max < min
|
||||
|
||||
error: clamp-like pattern without using clamp function
|
||||
--> $DIR/manual_clamp.rs:57:14
|
||||
--> $DIR/manual_clamp.rs:58:14
|
||||
|
|
||||
LL | let x6 = match input {
|
||||
| ______________^
|
||||
|
@ -154,7 +154,7 @@ LL | | };
|
|||
= note: clamp will panic if max < min
|
||||
|
||||
error: clamp-like pattern without using clamp function
|
||||
--> $DIR/manual_clamp.rs:63:14
|
||||
--> $DIR/manual_clamp.rs:64:14
|
||||
|
|
||||
LL | let x7 = match input {
|
||||
| ______________^
|
||||
|
@ -167,7 +167,7 @@ LL | | };
|
|||
= note: clamp will panic if max < min
|
||||
|
||||
error: clamp-like pattern without using clamp function
|
||||
--> $DIR/manual_clamp.rs:69:14
|
||||
--> $DIR/manual_clamp.rs:70:14
|
||||
|
|
||||
LL | let x8 = match input {
|
||||
| ______________^
|
||||
|
@ -180,7 +180,7 @@ LL | | };
|
|||
= note: clamp will panic if max < min
|
||||
|
||||
error: clamp-like pattern without using clamp function
|
||||
--> $DIR/manual_clamp.rs:83:15
|
||||
--> $DIR/manual_clamp.rs:84:15
|
||||
|
|
||||
LL | let x10 = match input {
|
||||
| _______________^
|
||||
|
@ -193,7 +193,7 @@ LL | | };
|
|||
= note: clamp will panic if max < min
|
||||
|
||||
error: clamp-like pattern without using clamp function
|
||||
--> $DIR/manual_clamp.rs:114:15
|
||||
--> $DIR/manual_clamp.rs:115:15
|
||||
|
|
||||
LL | let x14 = if input > CONST_MAX {
|
||||
| _______________^
|
||||
|
@ -208,7 +208,7 @@ LL | | };
|
|||
= note: clamp will panic if max < min
|
||||
|
||||
error: clamp-like pattern without using clamp function
|
||||
--> $DIR/manual_clamp.rs:123:19
|
||||
--> $DIR/manual_clamp.rs:124:19
|
||||
|
|
||||
LL | let x15 = if input > max {
|
||||
| ___________________^
|
||||
|
@ -224,7 +224,7 @@ LL | | };
|
|||
= note: clamp returns NaN if the input is NaN
|
||||
|
||||
error: clamp-like pattern without using clamp function
|
||||
--> $DIR/manual_clamp.rs:134:19
|
||||
--> $DIR/manual_clamp.rs:135:19
|
||||
|
|
||||
LL | let x16 = cmp_max(cmp_min(input, CONST_MAX), CONST_MIN);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_MIN, CONST_MAX)`
|
||||
|
@ -232,7 +232,7 @@ LL | let x16 = cmp_max(cmp_min(input, CONST_MAX), CONST_MIN);
|
|||
= note: clamp will panic if max < min
|
||||
|
||||
error: clamp-like pattern without using clamp function
|
||||
--> $DIR/manual_clamp.rs:135:19
|
||||
--> $DIR/manual_clamp.rs:136:19
|
||||
|
|
||||
LL | let x17 = cmp_min(cmp_max(input, CONST_MIN), CONST_MAX);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_MIN, CONST_MAX)`
|
||||
|
@ -240,7 +240,7 @@ LL | let x17 = cmp_min(cmp_max(input, CONST_MIN), CONST_MAX);
|
|||
= note: clamp will panic if max < min
|
||||
|
||||
error: clamp-like pattern without using clamp function
|
||||
--> $DIR/manual_clamp.rs:136:19
|
||||
--> $DIR/manual_clamp.rs:137:19
|
||||
|
|
||||
LL | let x18 = cmp_max(CONST_MIN, cmp_min(input, CONST_MAX));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_MIN, CONST_MAX)`
|
||||
|
@ -248,7 +248,7 @@ LL | let x18 = cmp_max(CONST_MIN, cmp_min(input, CONST_MAX));
|
|||
= note: clamp will panic if max < min
|
||||
|
||||
error: clamp-like pattern without using clamp function
|
||||
--> $DIR/manual_clamp.rs:137:19
|
||||
--> $DIR/manual_clamp.rs:138:19
|
||||
|
|
||||
LL | let x19 = cmp_min(CONST_MAX, cmp_max(input, CONST_MIN));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_MIN, CONST_MAX)`
|
||||
|
@ -256,7 +256,7 @@ LL | let x19 = cmp_min(CONST_MAX, cmp_max(input, CONST_MIN));
|
|||
= note: clamp will panic if max < min
|
||||
|
||||
error: clamp-like pattern without using clamp function
|
||||
--> $DIR/manual_clamp.rs:138:19
|
||||
--> $DIR/manual_clamp.rs:139:19
|
||||
|
|
||||
LL | let x20 = cmp_max(cmp_min(CONST_MAX, input), CONST_MIN);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_MIN, CONST_MAX)`
|
||||
|
@ -264,7 +264,7 @@ LL | let x20 = cmp_max(cmp_min(CONST_MAX, input), CONST_MIN);
|
|||
= note: clamp will panic if max < min
|
||||
|
||||
error: clamp-like pattern without using clamp function
|
||||
--> $DIR/manual_clamp.rs:139:19
|
||||
--> $DIR/manual_clamp.rs:140:19
|
||||
|
|
||||
LL | let x21 = cmp_min(cmp_max(CONST_MIN, input), CONST_MAX);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_MIN, CONST_MAX)`
|
||||
|
@ -272,7 +272,7 @@ LL | let x21 = cmp_min(cmp_max(CONST_MIN, input), CONST_MAX);
|
|||
= note: clamp will panic if max < min
|
||||
|
||||
error: clamp-like pattern without using clamp function
|
||||
--> $DIR/manual_clamp.rs:140:19
|
||||
--> $DIR/manual_clamp.rs:141:19
|
||||
|
|
||||
LL | let x22 = cmp_max(CONST_MIN, cmp_min(CONST_MAX, input));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_MIN, CONST_MAX)`
|
||||
|
@ -280,7 +280,7 @@ LL | let x22 = cmp_max(CONST_MIN, cmp_min(CONST_MAX, input));
|
|||
= note: clamp will panic if max < min
|
||||
|
||||
error: clamp-like pattern without using clamp function
|
||||
--> $DIR/manual_clamp.rs:141:19
|
||||
--> $DIR/manual_clamp.rs:142:19
|
||||
|
|
||||
LL | let x23 = cmp_min(CONST_MAX, cmp_max(CONST_MIN, input));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_MIN, CONST_MAX)`
|
||||
|
@ -288,7 +288,7 @@ LL | let x23 = cmp_min(CONST_MAX, cmp_max(CONST_MIN, input));
|
|||
= note: clamp will panic if max < min
|
||||
|
||||
error: clamp-like pattern without using clamp function
|
||||
--> $DIR/manual_clamp.rs:143:19
|
||||
--> $DIR/manual_clamp.rs:144:19
|
||||
|
|
||||
LL | let x24 = f64::max(f64::min(input, CONST_F64_MAX), CONST_F64_MIN);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_F64_MIN, CONST_F64_MAX)`
|
||||
|
@ -297,7 +297,7 @@ LL | let x24 = f64::max(f64::min(input, CONST_F64_MAX), CONST_F64_MIN);
|
|||
= note: clamp returns NaN if the input is NaN
|
||||
|
||||
error: clamp-like pattern without using clamp function
|
||||
--> $DIR/manual_clamp.rs:144:19
|
||||
--> $DIR/manual_clamp.rs:145:19
|
||||
|
|
||||
LL | let x25 = f64::min(f64::max(input, CONST_F64_MIN), CONST_F64_MAX);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_F64_MIN, CONST_F64_MAX)`
|
||||
|
@ -306,7 +306,7 @@ LL | let x25 = f64::min(f64::max(input, CONST_F64_MIN), CONST_F64_MAX);
|
|||
= note: clamp returns NaN if the input is NaN
|
||||
|
||||
error: clamp-like pattern without using clamp function
|
||||
--> $DIR/manual_clamp.rs:145:19
|
||||
--> $DIR/manual_clamp.rs:146:19
|
||||
|
|
||||
LL | let x26 = f64::max(CONST_F64_MIN, f64::min(input, CONST_F64_MAX));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_F64_MIN, CONST_F64_MAX)`
|
||||
|
@ -315,7 +315,7 @@ LL | let x26 = f64::max(CONST_F64_MIN, f64::min(input, CONST_F64_MAX));
|
|||
= note: clamp returns NaN if the input is NaN
|
||||
|
||||
error: clamp-like pattern without using clamp function
|
||||
--> $DIR/manual_clamp.rs:146:19
|
||||
--> $DIR/manual_clamp.rs:147:19
|
||||
|
|
||||
LL | let x27 = f64::min(CONST_F64_MAX, f64::max(input, CONST_F64_MIN));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_F64_MIN, CONST_F64_MAX)`
|
||||
|
@ -324,7 +324,7 @@ LL | let x27 = f64::min(CONST_F64_MAX, f64::max(input, CONST_F64_MIN));
|
|||
= note: clamp returns NaN if the input is NaN
|
||||
|
||||
error: clamp-like pattern without using clamp function
|
||||
--> $DIR/manual_clamp.rs:147:19
|
||||
--> $DIR/manual_clamp.rs:148:19
|
||||
|
|
||||
LL | let x28 = f64::max(f64::min(CONST_F64_MAX, input), CONST_F64_MIN);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_F64_MIN, CONST_F64_MAX)`
|
||||
|
@ -333,7 +333,7 @@ LL | let x28 = f64::max(f64::min(CONST_F64_MAX, input), CONST_F64_MIN);
|
|||
= note: clamp returns NaN if the input is NaN
|
||||
|
||||
error: clamp-like pattern without using clamp function
|
||||
--> $DIR/manual_clamp.rs:148:19
|
||||
--> $DIR/manual_clamp.rs:149:19
|
||||
|
|
||||
LL | let x29 = f64::min(f64::max(CONST_F64_MIN, input), CONST_F64_MAX);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_F64_MIN, CONST_F64_MAX)`
|
||||
|
@ -342,7 +342,7 @@ LL | let x29 = f64::min(f64::max(CONST_F64_MIN, input), CONST_F64_MAX);
|
|||
= note: clamp returns NaN if the input is NaN
|
||||
|
||||
error: clamp-like pattern without using clamp function
|
||||
--> $DIR/manual_clamp.rs:149:19
|
||||
--> $DIR/manual_clamp.rs:150:19
|
||||
|
|
||||
LL | let x30 = f64::max(CONST_F64_MIN, f64::min(CONST_F64_MAX, input));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_F64_MIN, CONST_F64_MAX)`
|
||||
|
@ -351,7 +351,7 @@ LL | let x30 = f64::max(CONST_F64_MIN, f64::min(CONST_F64_MAX, input));
|
|||
= note: clamp returns NaN if the input is NaN
|
||||
|
||||
error: clamp-like pattern without using clamp function
|
||||
--> $DIR/manual_clamp.rs:150:19
|
||||
--> $DIR/manual_clamp.rs:151:19
|
||||
|
|
||||
LL | let x31 = f64::min(CONST_F64_MAX, f64::max(CONST_F64_MIN, input));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_F64_MIN, CONST_F64_MAX)`
|
||||
|
@ -360,7 +360,7 @@ LL | let x31 = f64::min(CONST_F64_MAX, f64::max(CONST_F64_MIN, input));
|
|||
= note: clamp returns NaN if the input is NaN
|
||||
|
||||
error: clamp-like pattern without using clamp function
|
||||
--> $DIR/manual_clamp.rs:153:5
|
||||
--> $DIR/manual_clamp.rs:154:5
|
||||
|
|
||||
LL | / if x32 < min {
|
||||
LL | | x32 = min;
|
||||
|
@ -371,5 +371,20 @@ LL | | }
|
|||
|
|
||||
= note: clamp will panic if max < min
|
||||
|
||||
error: aborting due to 34 previous errors
|
||||
error: clamp-like pattern without using clamp function
|
||||
--> $DIR/manual_clamp.rs:324:13
|
||||
|
|
||||
LL | let _ = if input < min {
|
||||
| _____________^
|
||||
LL | | min
|
||||
LL | | } else if input > max {
|
||||
LL | | max
|
||||
LL | | } else {
|
||||
LL | | input
|
||||
LL | | };
|
||||
| |_____^ help: replace with clamp: `input.clamp(min, max)`
|
||||
|
|
||||
= note: clamp will panic if max < min
|
||||
|
||||
error: aborting due to 35 previous errors
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
// run-rustfix
|
||||
// aux-build:macro_rules.rs
|
||||
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![warn(clippy::manual_rem_euclid)]
|
||||
|
||||
#[macro_use]
|
||||
|
@ -53,3 +54,32 @@ pub fn rem_euclid_4(num: i32) -> i32 {
|
|||
pub const fn const_rem_euclid_4(num: i32) -> i32 {
|
||||
num.rem_euclid(4)
|
||||
}
|
||||
|
||||
pub fn msrv_1_37() {
|
||||
#![clippy::msrv = "1.37"]
|
||||
|
||||
let x: i32 = 10;
|
||||
let _: i32 = ((x % 4) + 4) % 4;
|
||||
}
|
||||
|
||||
pub fn msrv_1_38() {
|
||||
#![clippy::msrv = "1.38"]
|
||||
|
||||
let x: i32 = 10;
|
||||
let _: i32 = x.rem_euclid(4);
|
||||
}
|
||||
|
||||
// For const fns:
|
||||
pub const fn msrv_1_51() {
|
||||
#![clippy::msrv = "1.51"]
|
||||
|
||||
let x: i32 = 10;
|
||||
let _: i32 = ((x % 4) + 4) % 4;
|
||||
}
|
||||
|
||||
pub const fn msrv_1_52() {
|
||||
#![clippy::msrv = "1.52"]
|
||||
|
||||
let x: i32 = 10;
|
||||
let _: i32 = x.rem_euclid(4);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
// run-rustfix
|
||||
// aux-build:macro_rules.rs
|
||||
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![warn(clippy::manual_rem_euclid)]
|
||||
|
||||
#[macro_use]
|
||||
|
@ -53,3 +54,32 @@ pub fn rem_euclid_4(num: i32) -> i32 {
|
|||
pub const fn const_rem_euclid_4(num: i32) -> i32 {
|
||||
((num % 4) + 4) % 4
|
||||
}
|
||||
|
||||
pub fn msrv_1_37() {
|
||||
#![clippy::msrv = "1.37"]
|
||||
|
||||
let x: i32 = 10;
|
||||
let _: i32 = ((x % 4) + 4) % 4;
|
||||
}
|
||||
|
||||
pub fn msrv_1_38() {
|
||||
#![clippy::msrv = "1.38"]
|
||||
|
||||
let x: i32 = 10;
|
||||
let _: i32 = ((x % 4) + 4) % 4;
|
||||
}
|
||||
|
||||
// For const fns:
|
||||
pub const fn msrv_1_51() {
|
||||
#![clippy::msrv = "1.51"]
|
||||
|
||||
let x: i32 = 10;
|
||||
let _: i32 = ((x % 4) + 4) % 4;
|
||||
}
|
||||
|
||||
pub const fn msrv_1_52() {
|
||||
#![clippy::msrv = "1.52"]
|
||||
|
||||
let x: i32 = 10;
|
||||
let _: i32 = ((x % 4) + 4) % 4;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error: manual `rem_euclid` implementation
|
||||
--> $DIR/manual_rem_euclid.rs:19:18
|
||||
--> $DIR/manual_rem_euclid.rs:20:18
|
||||
|
|
||||
LL | let _: i32 = ((value % 4) + 4) % 4;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ help: consider using: `value.rem_euclid(4)`
|
||||
|
@ -7,31 +7,31 @@ LL | let _: i32 = ((value % 4) + 4) % 4;
|
|||
= note: `-D clippy::manual-rem-euclid` implied by `-D warnings`
|
||||
|
||||
error: manual `rem_euclid` implementation
|
||||
--> $DIR/manual_rem_euclid.rs:20:18
|
||||
--> $DIR/manual_rem_euclid.rs:21:18
|
||||
|
|
||||
LL | let _: i32 = (4 + (value % 4)) % 4;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ help: consider using: `value.rem_euclid(4)`
|
||||
|
||||
error: manual `rem_euclid` implementation
|
||||
--> $DIR/manual_rem_euclid.rs:21:18
|
||||
--> $DIR/manual_rem_euclid.rs:22:18
|
||||
|
|
||||
LL | let _: i32 = (value % 4 + 4) % 4;
|
||||
| ^^^^^^^^^^^^^^^^^^^ help: consider using: `value.rem_euclid(4)`
|
||||
|
||||
error: manual `rem_euclid` implementation
|
||||
--> $DIR/manual_rem_euclid.rs:22:18
|
||||
--> $DIR/manual_rem_euclid.rs:23:18
|
||||
|
|
||||
LL | let _: i32 = (4 + value % 4) % 4;
|
||||
| ^^^^^^^^^^^^^^^^^^^ help: consider using: `value.rem_euclid(4)`
|
||||
|
||||
error: manual `rem_euclid` implementation
|
||||
--> $DIR/manual_rem_euclid.rs:23:22
|
||||
--> $DIR/manual_rem_euclid.rs:24:22
|
||||
|
|
||||
LL | let _: i32 = 1 + (4 + value % 4) % 4;
|
||||
| ^^^^^^^^^^^^^^^^^^^ help: consider using: `value.rem_euclid(4)`
|
||||
|
||||
error: manual `rem_euclid` implementation
|
||||
--> $DIR/manual_rem_euclid.rs:12:22
|
||||
--> $DIR/manual_rem_euclid.rs:13:22
|
||||
|
|
||||
LL | let _: i32 = ((value % 4) + 4) % 4;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ help: consider using: `value.rem_euclid(4)`
|
||||
|
@ -42,16 +42,28 @@ LL | internal_rem_euclid!();
|
|||
= note: this error originates in the macro `internal_rem_euclid` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: manual `rem_euclid` implementation
|
||||
--> $DIR/manual_rem_euclid.rs:49:5
|
||||
--> $DIR/manual_rem_euclid.rs:50:5
|
||||
|
|
||||
LL | ((num % 4) + 4) % 4
|
||||
| ^^^^^^^^^^^^^^^^^^^ help: consider using: `num.rem_euclid(4)`
|
||||
|
||||
error: manual `rem_euclid` implementation
|
||||
--> $DIR/manual_rem_euclid.rs:54:5
|
||||
--> $DIR/manual_rem_euclid.rs:55:5
|
||||
|
|
||||
LL | ((num % 4) + 4) % 4
|
||||
| ^^^^^^^^^^^^^^^^^^^ help: consider using: `num.rem_euclid(4)`
|
||||
|
||||
error: aborting due to 8 previous errors
|
||||
error: manual `rem_euclid` implementation
|
||||
--> $DIR/manual_rem_euclid.rs:69:18
|
||||
|
|
||||
LL | let _: i32 = ((x % 4) + 4) % 4;
|
||||
| ^^^^^^^^^^^^^^^^^ help: consider using: `x.rem_euclid(4)`
|
||||
|
||||
error: manual `rem_euclid` implementation
|
||||
--> $DIR/manual_rem_euclid.rs:84:18
|
||||
|
|
||||
LL | let _: i32 = ((x % 4) + 4) % 4;
|
||||
| ^^^^^^^^^^^^^^^^^ help: consider using: `x.rem_euclid(4)`
|
||||
|
||||
error: aborting due to 10 previous errors
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#![feature(custom_inner_attributes)]
|
||||
#![warn(clippy::manual_strip)]
|
||||
|
||||
fn main() {
|
||||
|
@ -64,3 +65,21 @@ fn main() {
|
|||
s4[2..].to_string();
|
||||
}
|
||||
}
|
||||
|
||||
fn msrv_1_44() {
|
||||
#![clippy::msrv = "1.44"]
|
||||
|
||||
let s = "abc";
|
||||
if s.starts_with('a') {
|
||||
s[1..].to_string();
|
||||
}
|
||||
}
|
||||
|
||||
fn msrv_1_45() {
|
||||
#![clippy::msrv = "1.45"]
|
||||
|
||||
let s = "abc";
|
||||
if s.starts_with('a') {
|
||||
s[1..].to_string();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
error: stripping a prefix manually
|
||||
--> $DIR/manual_strip.rs:7:24
|
||||
--> $DIR/manual_strip.rs:8:24
|
||||
|
|
||||
LL | str::to_string(&s["ab".len()..]);
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: the prefix was tested here
|
||||
--> $DIR/manual_strip.rs:6:5
|
||||
--> $DIR/manual_strip.rs:7:5
|
||||
|
|
||||
LL | if s.starts_with("ab") {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -21,13 +21,13 @@ LL ~ <stripped>.to_string();
|
|||
|
|
||||
|
||||
error: stripping a suffix manually
|
||||
--> $DIR/manual_strip.rs:15:24
|
||||
--> $DIR/manual_strip.rs:16:24
|
||||
|
|
||||
LL | str::to_string(&s[..s.len() - "bc".len()]);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: the suffix was tested here
|
||||
--> $DIR/manual_strip.rs:14:5
|
||||
--> $DIR/manual_strip.rs:15:5
|
||||
|
|
||||
LL | if s.ends_with("bc") {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -42,13 +42,13 @@ LL ~ <stripped>.to_string();
|
|||
|
|
||||
|
||||
error: stripping a prefix manually
|
||||
--> $DIR/manual_strip.rs:24:24
|
||||
--> $DIR/manual_strip.rs:25:24
|
||||
|
|
||||
LL | str::to_string(&s[1..]);
|
||||
| ^^^^^^^
|
||||
|
|
||||
note: the prefix was tested here
|
||||
--> $DIR/manual_strip.rs:23:5
|
||||
--> $DIR/manual_strip.rs:24:5
|
||||
|
|
||||
LL | if s.starts_with('a') {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -60,13 +60,13 @@ LL ~ <stripped>.to_string();
|
|||
|
|
||||
|
||||
error: stripping a prefix manually
|
||||
--> $DIR/manual_strip.rs:31:24
|
||||
--> $DIR/manual_strip.rs:32:24
|
||||
|
|
||||
LL | str::to_string(&s[prefix.len()..]);
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: the prefix was tested here
|
||||
--> $DIR/manual_strip.rs:30:5
|
||||
--> $DIR/manual_strip.rs:31:5
|
||||
|
|
||||
LL | if s.starts_with(prefix) {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -77,13 +77,13 @@ LL ~ str::to_string(<stripped>);
|
|||
|
|
||||
|
||||
error: stripping a prefix manually
|
||||
--> $DIR/manual_strip.rs:37:24
|
||||
--> $DIR/manual_strip.rs:38:24
|
||||
|
|
||||
LL | str::to_string(&s[PREFIX.len()..]);
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: the prefix was tested here
|
||||
--> $DIR/manual_strip.rs:36:5
|
||||
--> $DIR/manual_strip.rs:37:5
|
||||
|
|
||||
LL | if s.starts_with(PREFIX) {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -95,13 +95,13 @@ LL ~ str::to_string(<stripped>);
|
|||
|
|
||||
|
||||
error: stripping a prefix manually
|
||||
--> $DIR/manual_strip.rs:44:24
|
||||
--> $DIR/manual_strip.rs:45:24
|
||||
|
|
||||
LL | str::to_string(&TARGET[prefix.len()..]);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: the prefix was tested here
|
||||
--> $DIR/manual_strip.rs:43:5
|
||||
--> $DIR/manual_strip.rs:44:5
|
||||
|
|
||||
LL | if TARGET.starts_with(prefix) {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -112,13 +112,13 @@ LL ~ str::to_string(<stripped>);
|
|||
|
|
||||
|
||||
error: stripping a prefix manually
|
||||
--> $DIR/manual_strip.rs:50:9
|
||||
--> $DIR/manual_strip.rs:51:9
|
||||
|
|
||||
LL | s1[2..].to_uppercase();
|
||||
| ^^^^^^^
|
||||
|
|
||||
note: the prefix was tested here
|
||||
--> $DIR/manual_strip.rs:49:5
|
||||
--> $DIR/manual_strip.rs:50:5
|
||||
|
|
||||
LL | if s1.starts_with("ab") {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -128,5 +128,22 @@ LL ~ if let Some(<stripped>) = s1.strip_prefix("ab") {
|
|||
LL ~ <stripped>.to_uppercase();
|
||||
|
|
||||
|
||||
error: aborting due to 7 previous errors
|
||||
error: stripping a prefix manually
|
||||
--> $DIR/manual_strip.rs:83:9
|
||||
|
|
||||
LL | s[1..].to_string();
|
||||
| ^^^^^^
|
||||
|
|
||||
note: the prefix was tested here
|
||||
--> $DIR/manual_strip.rs:82:5
|
||||
|
|
||||
LL | if s.starts_with('a') {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
help: try using the `strip_prefix` method
|
||||
|
|
||||
LL ~ if let Some(<stripped>) = s.strip_prefix('a') {
|
||||
LL ~ <stripped>.to_string();
|
||||
|
|
||||
|
||||
error: aborting due to 8 previous errors
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
// aux-build:option_helpers.rs
|
||||
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![warn(clippy::map_unwrap_or)]
|
||||
#![allow(clippy::uninlined_format_args)]
|
||||
#![allow(clippy::uninlined_format_args, clippy::unnecessary_lazy_evaluations)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate option_helpers;
|
||||
|
@ -79,3 +81,19 @@ fn main() {
|
|||
option_methods();
|
||||
result_methods();
|
||||
}
|
||||
|
||||
fn msrv_1_40() {
|
||||
#![clippy::msrv = "1.40"]
|
||||
|
||||
let res: Result<i32, ()> = Ok(1);
|
||||
|
||||
let _ = res.map(|x| x + 1).unwrap_or_else(|_e| 0);
|
||||
}
|
||||
|
||||
fn msrv_1_41() {
|
||||
#![clippy::msrv = "1.41"]
|
||||
|
||||
let res: Result<i32, ()> = Ok(1);
|
||||
|
||||
let _ = res.map(|x| x + 1).unwrap_or_else(|_e| 0);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error: called `map(<f>).unwrap_or(<a>)` on an `Option` value. This can be done more directly by calling `map_or(<a>, <f>)` instead
|
||||
--> $DIR/map_unwrap_or.rs:16:13
|
||||
--> $DIR/map_unwrap_or.rs:18:13
|
||||
|
|
||||
LL | let _ = opt.map(|x| x + 1)
|
||||
| _____________^
|
||||
|
@ -15,7 +15,7 @@ LL + let _ = opt.map_or(0, |x| x + 1);
|
|||
|
|
||||
|
||||
error: called `map(<f>).unwrap_or(<a>)` on an `Option` value. This can be done more directly by calling `map_or(<a>, <f>)` instead
|
||||
--> $DIR/map_unwrap_or.rs:20:13
|
||||
--> $DIR/map_unwrap_or.rs:22:13
|
||||
|
|
||||
LL | let _ = opt.map(|x| {
|
||||
| _____________^
|
||||
|
@ -33,7 +33,7 @@ LL ~ );
|
|||
|
|
||||
|
||||
error: called `map(<f>).unwrap_or(<a>)` on an `Option` value. This can be done more directly by calling `map_or(<a>, <f>)` instead
|
||||
--> $DIR/map_unwrap_or.rs:24:13
|
||||
--> $DIR/map_unwrap_or.rs:26:13
|
||||
|
|
||||
LL | let _ = opt.map(|x| x + 1)
|
||||
| _____________^
|
||||
|
@ -50,7 +50,7 @@ LL ~ }, |x| x + 1);
|
|||
|
|
||||
|
||||
error: called `map(<f>).unwrap_or(None)` on an `Option` value. This can be done more directly by calling `and_then(<f>)` instead
|
||||
--> $DIR/map_unwrap_or.rs:29:13
|
||||
--> $DIR/map_unwrap_or.rs:31:13
|
||||
|
|
||||
LL | let _ = opt.map(|x| Some(x + 1)).unwrap_or(None);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -62,7 +62,7 @@ LL + let _ = opt.and_then(|x| Some(x + 1));
|
|||
|
|
||||
|
||||
error: called `map(<f>).unwrap_or(None)` on an `Option` value. This can be done more directly by calling `and_then(<f>)` instead
|
||||
--> $DIR/map_unwrap_or.rs:31:13
|
||||
--> $DIR/map_unwrap_or.rs:33:13
|
||||
|
|
||||
LL | let _ = opt.map(|x| {
|
||||
| _____________^
|
||||
|
@ -80,7 +80,7 @@ LL ~ );
|
|||
|
|
||||
|
||||
error: called `map(<f>).unwrap_or(None)` on an `Option` value. This can be done more directly by calling `and_then(<f>)` instead
|
||||
--> $DIR/map_unwrap_or.rs:35:13
|
||||
--> $DIR/map_unwrap_or.rs:37:13
|
||||
|
|
||||
LL | let _ = opt
|
||||
| _____________^
|
||||
|
@ -95,7 +95,7 @@ LL + .and_then(|x| Some(x + 1));
|
|||
|
|
||||
|
||||
error: called `map(<f>).unwrap_or(<a>)` on an `Option` value. This can be done more directly by calling `map_or(<a>, <f>)` instead
|
||||
--> $DIR/map_unwrap_or.rs:46:13
|
||||
--> $DIR/map_unwrap_or.rs:48:13
|
||||
|
|
||||
LL | let _ = Some("prefix").map(|p| format!("{}.", p)).unwrap_or(id);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -107,7 +107,7 @@ LL + let _ = Some("prefix").map_or(id, |p| format!("{}.", p));
|
|||
|
|
||||
|
||||
error: called `map(<f>).unwrap_or_else(<g>)` on an `Option` value. This can be done more directly by calling `map_or_else(<g>, <f>)` instead
|
||||
--> $DIR/map_unwrap_or.rs:50:13
|
||||
--> $DIR/map_unwrap_or.rs:52:13
|
||||
|
|
||||
LL | let _ = opt.map(|x| {
|
||||
| _____________^
|
||||
|
@ -117,7 +117,7 @@ LL | | ).unwrap_or_else(|| 0);
|
|||
| |__________________________^
|
||||
|
||||
error: called `map(<f>).unwrap_or_else(<g>)` on an `Option` value. This can be done more directly by calling `map_or_else(<g>, <f>)` instead
|
||||
--> $DIR/map_unwrap_or.rs:54:13
|
||||
--> $DIR/map_unwrap_or.rs:56:13
|
||||
|
|
||||
LL | let _ = opt.map(|x| x + 1)
|
||||
| _____________^
|
||||
|
@ -127,7 +127,7 @@ LL | | );
|
|||
| |_________^
|
||||
|
||||
error: called `map(<f>).unwrap_or_else(<g>)` on a `Result` value. This can be done more directly by calling `.map_or_else(<g>, <f>)` instead
|
||||
--> $DIR/map_unwrap_or.rs:66:13
|
||||
--> $DIR/map_unwrap_or.rs:68:13
|
||||
|
|
||||
LL | let _ = res.map(|x| {
|
||||
| _____________^
|
||||
|
@ -137,7 +137,7 @@ LL | | ).unwrap_or_else(|_e| 0);
|
|||
| |____________________________^
|
||||
|
||||
error: called `map(<f>).unwrap_or_else(<g>)` on a `Result` value. This can be done more directly by calling `.map_or_else(<g>, <f>)` instead
|
||||
--> $DIR/map_unwrap_or.rs:70:13
|
||||
--> $DIR/map_unwrap_or.rs:72:13
|
||||
|
|
||||
LL | let _ = res.map(|x| x + 1)
|
||||
| _____________^
|
||||
|
@ -146,5 +146,11 @@ LL | | 0
|
|||
LL | | });
|
||||
| |__________^
|
||||
|
||||
error: aborting due to 11 previous errors
|
||||
error: called `map(<f>).unwrap_or_else(<g>)` on a `Result` value. This can be done more directly by calling `.map_or_else(<g>, <f>)` instead
|
||||
--> $DIR/map_unwrap_or.rs:98:13
|
||||
|
|
||||
LL | let _ = res.map(|x| x + 1).unwrap_or_else(|_e| 0);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `res.map_or_else(|_e| 0, |x| x + 1)`
|
||||
|
||||
error: aborting due to 12 previous errors
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// run-rustfix
|
||||
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![warn(clippy::match_like_matches_macro)]
|
||||
#![allow(unreachable_patterns, dead_code, clippy::equatable_if_let)]
|
||||
|
||||
|
@ -193,3 +194,18 @@ fn main() {
|
|||
_ => false,
|
||||
};
|
||||
}
|
||||
|
||||
fn msrv_1_41() {
|
||||
#![clippy::msrv = "1.41"]
|
||||
|
||||
let _y = match Some(5) {
|
||||
Some(0) => true,
|
||||
_ => false,
|
||||
};
|
||||
}
|
||||
|
||||
fn msrv_1_42() {
|
||||
#![clippy::msrv = "1.42"]
|
||||
|
||||
let _y = matches!(Some(5), Some(0));
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// run-rustfix
|
||||
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![warn(clippy::match_like_matches_macro)]
|
||||
#![allow(unreachable_patterns, dead_code, clippy::equatable_if_let)]
|
||||
|
||||
|
@ -234,3 +235,21 @@ fn main() {
|
|||
_ => false,
|
||||
};
|
||||
}
|
||||
|
||||
fn msrv_1_41() {
|
||||
#![clippy::msrv = "1.41"]
|
||||
|
||||
let _y = match Some(5) {
|
||||
Some(0) => true,
|
||||
_ => false,
|
||||
};
|
||||
}
|
||||
|
||||
fn msrv_1_42() {
|
||||
#![clippy::msrv = "1.42"]
|
||||
|
||||
let _y = match Some(5) {
|
||||
Some(0) => true,
|
||||
_ => false,
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error: match expression looks like `matches!` macro
|
||||
--> $DIR/match_expr_like_matches_macro.rs:10:14
|
||||
--> $DIR/match_expr_like_matches_macro.rs:11:14
|
||||
|
|
||||
LL | let _y = match x {
|
||||
| ______________^
|
||||
|
@ -11,7 +11,7 @@ LL | | };
|
|||
= note: `-D clippy::match-like-matches-macro` implied by `-D warnings`
|
||||
|
||||
error: match expression looks like `matches!` macro
|
||||
--> $DIR/match_expr_like_matches_macro.rs:16:14
|
||||
--> $DIR/match_expr_like_matches_macro.rs:17:14
|
||||
|
|
||||
LL | let _w = match x {
|
||||
| ______________^
|
||||
|
@ -21,7 +21,7 @@ LL | | };
|
|||
| |_____^ help: try this: `matches!(x, Some(_))`
|
||||
|
||||
error: redundant pattern matching, consider using `is_none()`
|
||||
--> $DIR/match_expr_like_matches_macro.rs:22:14
|
||||
--> $DIR/match_expr_like_matches_macro.rs:23:14
|
||||
|
|
||||
LL | let _z = match x {
|
||||
| ______________^
|
||||
|
@ -33,7 +33,7 @@ LL | | };
|
|||
= note: `-D clippy::redundant-pattern-matching` implied by `-D warnings`
|
||||
|
||||
error: match expression looks like `matches!` macro
|
||||
--> $DIR/match_expr_like_matches_macro.rs:28:15
|
||||
--> $DIR/match_expr_like_matches_macro.rs:29:15
|
||||
|
|
||||
LL | let _zz = match x {
|
||||
| _______________^
|
||||
|
@ -43,13 +43,13 @@ LL | | };
|
|||
| |_____^ help: try this: `!matches!(x, Some(r) if r == 0)`
|
||||
|
||||
error: if let .. else expression looks like `matches!` macro
|
||||
--> $DIR/match_expr_like_matches_macro.rs:34:16
|
||||
--> $DIR/match_expr_like_matches_macro.rs:35:16
|
||||
|
|
||||
LL | let _zzz = if let Some(5) = x { true } else { false };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `matches!(x, Some(5))`
|
||||
|
||||
error: match expression looks like `matches!` macro
|
||||
--> $DIR/match_expr_like_matches_macro.rs:58:20
|
||||
--> $DIR/match_expr_like_matches_macro.rs:59:20
|
||||
|
|
||||
LL | let _ans = match x {
|
||||
| ____________________^
|
||||
|
@ -60,7 +60,7 @@ LL | | };
|
|||
| |_________^ help: try this: `matches!(x, E::A(_) | E::B(_))`
|
||||
|
||||
error: match expression looks like `matches!` macro
|
||||
--> $DIR/match_expr_like_matches_macro.rs:68:20
|
||||
--> $DIR/match_expr_like_matches_macro.rs:69:20
|
||||
|
|
||||
LL | let _ans = match x {
|
||||
| ____________________^
|
||||
|
@ -73,7 +73,7 @@ LL | | };
|
|||
| |_________^ help: try this: `matches!(x, E::A(_) | E::B(_))`
|
||||
|
||||
error: match expression looks like `matches!` macro
|
||||
--> $DIR/match_expr_like_matches_macro.rs:78:20
|
||||
--> $DIR/match_expr_like_matches_macro.rs:79:20
|
||||
|
|
||||
LL | let _ans = match x {
|
||||
| ____________________^
|
||||
|
@ -84,7 +84,7 @@ LL | | };
|
|||
| |_________^ help: try this: `!matches!(x, E::B(_) | E::C)`
|
||||
|
||||
error: match expression looks like `matches!` macro
|
||||
--> $DIR/match_expr_like_matches_macro.rs:138:18
|
||||
--> $DIR/match_expr_like_matches_macro.rs:139:18
|
||||
|
|
||||
LL | let _z = match &z {
|
||||
| __________________^
|
||||
|
@ -94,7 +94,7 @@ LL | | };
|
|||
| |_________^ help: try this: `matches!(z, Some(3))`
|
||||
|
||||
error: match expression looks like `matches!` macro
|
||||
--> $DIR/match_expr_like_matches_macro.rs:147:18
|
||||
--> $DIR/match_expr_like_matches_macro.rs:148:18
|
||||
|
|
||||
LL | let _z = match &z {
|
||||
| __________________^
|
||||
|
@ -104,7 +104,7 @@ LL | | };
|
|||
| |_________^ help: try this: `matches!(&z, Some(3))`
|
||||
|
||||
error: match expression looks like `matches!` macro
|
||||
--> $DIR/match_expr_like_matches_macro.rs:164:21
|
||||
--> $DIR/match_expr_like_matches_macro.rs:165:21
|
||||
|
|
||||
LL | let _ = match &z {
|
||||
| _____________________^
|
||||
|
@ -114,7 +114,7 @@ LL | | };
|
|||
| |_____________^ help: try this: `matches!(&z, AnEnum::X)`
|
||||
|
||||
error: match expression looks like `matches!` macro
|
||||
--> $DIR/match_expr_like_matches_macro.rs:178:20
|
||||
--> $DIR/match_expr_like_matches_macro.rs:179:20
|
||||
|
|
||||
LL | let _res = match &val {
|
||||
| ____________________^
|
||||
|
@ -124,7 +124,7 @@ LL | | };
|
|||
| |_________^ help: try this: `matches!(&val, &Some(ref _a))`
|
||||
|
||||
error: match expression looks like `matches!` macro
|
||||
--> $DIR/match_expr_like_matches_macro.rs:190:20
|
||||
--> $DIR/match_expr_like_matches_macro.rs:191:20
|
||||
|
|
||||
LL | let _res = match &val {
|
||||
| ____________________^
|
||||
|
@ -133,5 +133,15 @@ LL | | _ => false,
|
|||
LL | | };
|
||||
| |_________^ help: try this: `matches!(&val, &Some(ref _a))`
|
||||
|
||||
error: aborting due to 13 previous errors
|
||||
error: match expression looks like `matches!` macro
|
||||
--> $DIR/match_expr_like_matches_macro.rs:251:14
|
||||
|
|
||||
LL | let _y = match Some(5) {
|
||||
| ______________^
|
||||
LL | | Some(0) => true,
|
||||
LL | | _ => false,
|
||||
LL | | };
|
||||
| |_____^ help: try this: `matches!(Some(5), Some(0))`
|
||||
|
||||
error: aborting due to 14 previous errors
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
// run-rustfix
|
||||
#![allow(unused_imports)]
|
||||
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![allow(unused)]
|
||||
#![warn(
|
||||
clippy::all,
|
||||
clippy::style,
|
||||
|
@ -77,3 +79,17 @@ fn main() {
|
|||
replace_with_default();
|
||||
dont_lint_primitive();
|
||||
}
|
||||
|
||||
fn msrv_1_39() {
|
||||
#![clippy::msrv = "1.39"]
|
||||
|
||||
let mut s = String::from("foo");
|
||||
let _ = std::mem::replace(&mut s, String::default());
|
||||
}
|
||||
|
||||
fn msrv_1_40() {
|
||||
#![clippy::msrv = "1.40"]
|
||||
|
||||
let mut s = String::from("foo");
|
||||
let _ = std::mem::take(&mut s);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
// run-rustfix
|
||||
#![allow(unused_imports)]
|
||||
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![allow(unused)]
|
||||
#![warn(
|
||||
clippy::all,
|
||||
clippy::style,
|
||||
|
@ -77,3 +79,17 @@ fn main() {
|
|||
replace_with_default();
|
||||
dont_lint_primitive();
|
||||
}
|
||||
|
||||
fn msrv_1_39() {
|
||||
#![clippy::msrv = "1.39"]
|
||||
|
||||
let mut s = String::from("foo");
|
||||
let _ = std::mem::replace(&mut s, String::default());
|
||||
}
|
||||
|
||||
fn msrv_1_40() {
|
||||
#![clippy::msrv = "1.40"]
|
||||
|
||||
let mut s = String::from("foo");
|
||||
let _ = std::mem::replace(&mut s, String::default());
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error: replacing an `Option` with `None`
|
||||
--> $DIR/mem_replace.rs:15:13
|
||||
--> $DIR/mem_replace.rs:17:13
|
||||
|
|
||||
LL | let _ = mem::replace(&mut an_option, None);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider `Option::take()` instead: `an_option.take()`
|
||||
|
@ -7,13 +7,13 @@ LL | let _ = mem::replace(&mut an_option, None);
|
|||
= note: `-D clippy::mem-replace-option-with-none` implied by `-D warnings`
|
||||
|
||||
error: replacing an `Option` with `None`
|
||||
--> $DIR/mem_replace.rs:17:13
|
||||
--> $DIR/mem_replace.rs:19:13
|
||||
|
|
||||
LL | let _ = mem::replace(an_option, None);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider `Option::take()` instead: `an_option.take()`
|
||||
|
||||
error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take`
|
||||
--> $DIR/mem_replace.rs:22:13
|
||||
--> $DIR/mem_replace.rs:24:13
|
||||
|
|
||||
LL | let _ = std::mem::replace(&mut s, String::default());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut s)`
|
||||
|
@ -21,100 +21,106 @@ LL | let _ = std::mem::replace(&mut s, String::default());
|
|||
= note: `-D clippy::mem-replace-with-default` implied by `-D warnings`
|
||||
|
||||
error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take`
|
||||
--> $DIR/mem_replace.rs:25:13
|
||||
--> $DIR/mem_replace.rs:27:13
|
||||
|
|
||||
LL | let _ = std::mem::replace(s, String::default());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(s)`
|
||||
|
||||
error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take`
|
||||
--> $DIR/mem_replace.rs:26:13
|
||||
--> $DIR/mem_replace.rs:28:13
|
||||
|
|
||||
LL | let _ = std::mem::replace(s, Default::default());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(s)`
|
||||
|
||||
error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take`
|
||||
--> $DIR/mem_replace.rs:29:13
|
||||
--> $DIR/mem_replace.rs:31:13
|
||||
|
|
||||
LL | let _ = std::mem::replace(&mut v, Vec::default());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut v)`
|
||||
|
||||
error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take`
|
||||
--> $DIR/mem_replace.rs:30:13
|
||||
--> $DIR/mem_replace.rs:32:13
|
||||
|
|
||||
LL | let _ = std::mem::replace(&mut v, Default::default());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut v)`
|
||||
|
||||
error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take`
|
||||
--> $DIR/mem_replace.rs:31:13
|
||||
--> $DIR/mem_replace.rs:33:13
|
||||
|
|
||||
LL | let _ = std::mem::replace(&mut v, Vec::new());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut v)`
|
||||
|
||||
error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take`
|
||||
--> $DIR/mem_replace.rs:32:13
|
||||
--> $DIR/mem_replace.rs:34:13
|
||||
|
|
||||
LL | let _ = std::mem::replace(&mut v, vec![]);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut v)`
|
||||
|
||||
error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take`
|
||||
--> $DIR/mem_replace.rs:35:13
|
||||
--> $DIR/mem_replace.rs:37:13
|
||||
|
|
||||
LL | let _ = std::mem::replace(&mut hash_map, HashMap::new());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut hash_map)`
|
||||
|
||||
error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take`
|
||||
--> $DIR/mem_replace.rs:38:13
|
||||
--> $DIR/mem_replace.rs:40:13
|
||||
|
|
||||
LL | let _ = std::mem::replace(&mut btree_map, BTreeMap::new());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut btree_map)`
|
||||
|
||||
error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take`
|
||||
--> $DIR/mem_replace.rs:41:13
|
||||
--> $DIR/mem_replace.rs:43:13
|
||||
|
|
||||
LL | let _ = std::mem::replace(&mut vd, VecDeque::new());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut vd)`
|
||||
|
||||
error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take`
|
||||
--> $DIR/mem_replace.rs:44:13
|
||||
--> $DIR/mem_replace.rs:46:13
|
||||
|
|
||||
LL | let _ = std::mem::replace(&mut hash_set, HashSet::new());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut hash_set)`
|
||||
|
||||
error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take`
|
||||
--> $DIR/mem_replace.rs:47:13
|
||||
--> $DIR/mem_replace.rs:49:13
|
||||
|
|
||||
LL | let _ = std::mem::replace(&mut btree_set, BTreeSet::new());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut btree_set)`
|
||||
|
||||
error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take`
|
||||
--> $DIR/mem_replace.rs:50:13
|
||||
--> $DIR/mem_replace.rs:52:13
|
||||
|
|
||||
LL | let _ = std::mem::replace(&mut list, LinkedList::new());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut list)`
|
||||
|
||||
error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take`
|
||||
--> $DIR/mem_replace.rs:53:13
|
||||
--> $DIR/mem_replace.rs:55:13
|
||||
|
|
||||
LL | let _ = std::mem::replace(&mut binary_heap, BinaryHeap::new());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut binary_heap)`
|
||||
|
||||
error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take`
|
||||
--> $DIR/mem_replace.rs:56:13
|
||||
--> $DIR/mem_replace.rs:58:13
|
||||
|
|
||||
LL | let _ = std::mem::replace(&mut tuple, (vec![], BinaryHeap::new()));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut tuple)`
|
||||
|
||||
error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take`
|
||||
--> $DIR/mem_replace.rs:59:13
|
||||
--> $DIR/mem_replace.rs:61:13
|
||||
|
|
||||
LL | let _ = std::mem::replace(&mut refstr, "");
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut refstr)`
|
||||
|
||||
error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take`
|
||||
--> $DIR/mem_replace.rs:62:13
|
||||
--> $DIR/mem_replace.rs:64:13
|
||||
|
|
||||
LL | let _ = std::mem::replace(&mut slice, &[]);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut slice)`
|
||||
|
||||
error: aborting due to 19 previous errors
|
||||
error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take`
|
||||
--> $DIR/mem_replace.rs:94:13
|
||||
|
|
||||
LL | let _ = std::mem::replace(&mut s, String::default());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut s)`
|
||||
|
||||
error: aborting due to 20 previous errors
|
||||
|
||||
|
|
|
@ -1,240 +1,29 @@
|
|||
#![allow(clippy::redundant_clone)]
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![clippy::msrv = "1.0.0"]
|
||||
|
||||
use std::ops::{Deref, RangeFrom};
|
||||
fn main() {}
|
||||
|
||||
fn approx_const() {
|
||||
fn just_under_msrv() {
|
||||
#![clippy::msrv = "1.42.0"]
|
||||
let log2_10 = 3.321928094887362;
|
||||
let log10_2 = 0.301029995663981;
|
||||
}
|
||||
|
||||
fn cloned_instead_of_copied() {
|
||||
let _ = [1].iter().cloned();
|
||||
fn meets_msrv() {
|
||||
#![clippy::msrv = "1.43.0"]
|
||||
let log2_10 = 3.321928094887362;
|
||||
}
|
||||
|
||||
fn option_as_ref_deref() {
|
||||
let mut opt = Some(String::from("123"));
|
||||
|
||||
let _ = opt.as_ref().map(String::as_str);
|
||||
let _ = opt.as_ref().map(|x| x.as_str());
|
||||
let _ = opt.as_mut().map(String::as_mut_str);
|
||||
let _ = opt.as_mut().map(|x| x.as_mut_str());
|
||||
}
|
||||
|
||||
fn match_like_matches() {
|
||||
let _y = match Some(5) {
|
||||
Some(0) => true,
|
||||
_ => false,
|
||||
};
|
||||
}
|
||||
|
||||
fn match_same_arms() {
|
||||
match (1, 2, 3) {
|
||||
(1, .., 3) => 42,
|
||||
(.., 3) => 42, //~ ERROR match arms have same body
|
||||
_ => 0,
|
||||
};
|
||||
}
|
||||
|
||||
fn match_same_arms2() {
|
||||
let _ = match Some(42) {
|
||||
Some(_) => 24,
|
||||
None => 24, //~ ERROR match arms have same body
|
||||
};
|
||||
}
|
||||
|
||||
pub fn manual_strip_msrv() {
|
||||
let s = "hello, world!";
|
||||
if s.starts_with("hello, ") {
|
||||
assert_eq!(s["hello, ".len()..].to_uppercase(), "WORLD!");
|
||||
}
|
||||
}
|
||||
|
||||
pub fn redundant_fieldnames() {
|
||||
let start = 0;
|
||||
let _ = RangeFrom { start: start };
|
||||
}
|
||||
|
||||
pub fn redundant_static_lifetime() {
|
||||
const VAR_ONE: &'static str = "Test constant #1";
|
||||
}
|
||||
|
||||
pub fn checked_conversion() {
|
||||
let value: i64 = 42;
|
||||
let _ = value <= (u32::max_value() as i64) && value >= 0;
|
||||
let _ = value <= (u32::MAX as i64) && value >= 0;
|
||||
}
|
||||
|
||||
pub struct FromOverInto(String);
|
||||
|
||||
impl Into<FromOverInto> for String {
|
||||
fn into(self) -> FromOverInto {
|
||||
FromOverInto(self)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn filter_map_next() {
|
||||
let a = ["1", "lol", "3", "NaN", "5"];
|
||||
|
||||
#[rustfmt::skip]
|
||||
let _: Option<u32> = vec![1, 2, 3, 4, 5, 6]
|
||||
.into_iter()
|
||||
.filter_map(|x| {
|
||||
if x == 2 {
|
||||
Some(x * 2)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
.next();
|
||||
}
|
||||
|
||||
#[allow(clippy::no_effect)]
|
||||
#[allow(clippy::short_circuit_statement)]
|
||||
#[allow(clippy::unnecessary_operation)]
|
||||
pub fn manual_range_contains() {
|
||||
let x = 5;
|
||||
x >= 8 && x < 12;
|
||||
}
|
||||
|
||||
pub fn use_self() {
|
||||
struct Foo;
|
||||
|
||||
impl Foo {
|
||||
fn new() -> Foo {
|
||||
Foo {}
|
||||
}
|
||||
fn test() -> Foo {
|
||||
Foo::new()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn replace_with_default() {
|
||||
let mut s = String::from("foo");
|
||||
let _ = std::mem::replace(&mut s, String::default());
|
||||
}
|
||||
|
||||
fn map_unwrap_or() {
|
||||
let opt = Some(1);
|
||||
|
||||
// Check for `option.map(_).unwrap_or(_)` use.
|
||||
// Single line case.
|
||||
let _ = opt
|
||||
.map(|x| x + 1)
|
||||
// Should lint even though this call is on a separate line.
|
||||
.unwrap_or(0);
|
||||
}
|
||||
|
||||
// Could be const
|
||||
fn missing_const_for_fn() -> i32 {
|
||||
1
|
||||
}
|
||||
|
||||
fn unnest_or_patterns() {
|
||||
struct TS(u8, u8);
|
||||
if let TS(0, x) | TS(1, x) = TS(0, 0) {}
|
||||
}
|
||||
|
||||
#[cfg_attr(rustfmt, rustfmt_skip)]
|
||||
fn deprecated_cfg_attr() {}
|
||||
|
||||
#[warn(clippy::cast_lossless)]
|
||||
fn int_from_bool() -> u8 {
|
||||
true as u8
|
||||
}
|
||||
|
||||
fn err_expect() {
|
||||
let x: Result<u32, &str> = Ok(10);
|
||||
x.err().expect("Testing expect_err");
|
||||
}
|
||||
|
||||
fn cast_abs_to_unsigned() {
|
||||
let x: i32 = 10;
|
||||
assert_eq!(10u32, x.abs() as u32);
|
||||
}
|
||||
|
||||
fn manual_rem_euclid() {
|
||||
let x: i32 = 10;
|
||||
let _: i32 = ((x % 4) + 4) % 4;
|
||||
}
|
||||
|
||||
fn manual_clamp() {
|
||||
let (input, min, max) = (0, -1, 2);
|
||||
let _ = if input < min {
|
||||
min
|
||||
} else if input > max {
|
||||
max
|
||||
} else {
|
||||
input
|
||||
};
|
||||
}
|
||||
|
||||
fn main() {
|
||||
filter_map_next();
|
||||
checked_conversion();
|
||||
redundant_fieldnames();
|
||||
redundant_static_lifetime();
|
||||
option_as_ref_deref();
|
||||
match_like_matches();
|
||||
match_same_arms();
|
||||
match_same_arms2();
|
||||
manual_strip_msrv();
|
||||
manual_range_contains();
|
||||
use_self();
|
||||
replace_with_default();
|
||||
map_unwrap_or();
|
||||
missing_const_for_fn();
|
||||
unnest_or_patterns();
|
||||
int_from_bool();
|
||||
err_expect();
|
||||
cast_abs_to_unsigned();
|
||||
manual_rem_euclid();
|
||||
manual_clamp();
|
||||
}
|
||||
|
||||
mod just_under_msrv {
|
||||
#![feature(custom_inner_attributes)]
|
||||
fn just_above_msrv() {
|
||||
#![clippy::msrv = "1.44.0"]
|
||||
|
||||
fn main() {
|
||||
let s = "hello, world!";
|
||||
if s.starts_with("hello, ") {
|
||||
assert_eq!(s["hello, ".len()..].to_uppercase(), "WORLD!");
|
||||
}
|
||||
}
|
||||
let log2_10 = 3.321928094887362;
|
||||
}
|
||||
|
||||
mod meets_msrv {
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![clippy::msrv = "1.45.0"]
|
||||
|
||||
fn main() {
|
||||
let s = "hello, world!";
|
||||
if s.starts_with("hello, ") {
|
||||
assert_eq!(s["hello, ".len()..].to_uppercase(), "WORLD!");
|
||||
}
|
||||
}
|
||||
fn no_patch_under() {
|
||||
#![clippy::msrv = "1.42"]
|
||||
let log2_10 = 3.321928094887362;
|
||||
}
|
||||
|
||||
mod just_above_msrv {
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![clippy::msrv = "1.46.0"]
|
||||
|
||||
fn main() {
|
||||
let s = "hello, world!";
|
||||
if s.starts_with("hello, ") {
|
||||
assert_eq!(s["hello, ".len()..].to_uppercase(), "WORLD!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mod const_rem_euclid {
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![clippy::msrv = "1.50.0"]
|
||||
|
||||
pub const fn const_rem_euclid_4(num: i32) -> i32 {
|
||||
((num % 4) + 4) % 4
|
||||
}
|
||||
fn no_patch_meets() {
|
||||
#![clippy::msrv = "1.43"]
|
||||
let log2_10 = 3.321928094887362;
|
||||
}
|
||||
|
|
|
@ -1,37 +1,27 @@
|
|||
error: stripping a prefix manually
|
||||
--> $DIR/min_rust_version_attr.rs:216:24
|
||||
error: approximate value of `f{32, 64}::consts::LOG2_10` found
|
||||
--> $DIR/min_rust_version_attr.rs:13:19
|
||||
|
|
||||
LL | assert_eq!(s["hello, ".len()..].to_uppercase(), "WORLD!");
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: the prefix was tested here
|
||||
--> $DIR/min_rust_version_attr.rs:215:9
|
||||
|
|
||||
LL | if s.starts_with("hello, ") {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
= note: `-D clippy::manual-strip` implied by `-D warnings`
|
||||
help: try using the `strip_prefix` method
|
||||
|
|
||||
LL ~ if let Some(<stripped>) = s.strip_prefix("hello, ") {
|
||||
LL ~ assert_eq!(<stripped>.to_uppercase(), "WORLD!");
|
||||
LL | let log2_10 = 3.321928094887362;
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: consider using the constant directly
|
||||
= note: `#[deny(clippy::approx_constant)]` on by default
|
||||
|
||||
error: stripping a prefix manually
|
||||
--> $DIR/min_rust_version_attr.rs:228:24
|
||||
error: approximate value of `f{32, 64}::consts::LOG2_10` found
|
||||
--> $DIR/min_rust_version_attr.rs:18:19
|
||||
|
|
||||
LL | assert_eq!(s["hello, ".len()..].to_uppercase(), "WORLD!");
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: the prefix was tested here
|
||||
--> $DIR/min_rust_version_attr.rs:227:9
|
||||
|
|
||||
LL | if s.starts_with("hello, ") {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
help: try using the `strip_prefix` method
|
||||
|
|
||||
LL ~ if let Some(<stripped>) = s.strip_prefix("hello, ") {
|
||||
LL ~ assert_eq!(<stripped>.to_uppercase(), "WORLD!");
|
||||
LL | let log2_10 = 3.321928094887362;
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: consider using the constant directly
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
error: approximate value of `f{32, 64}::consts::LOG2_10` found
|
||||
--> $DIR/min_rust_version_attr.rs:28:19
|
||||
|
|
||||
LL | let log2_10 = 3.321928094887362;
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: consider using the constant directly
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
|
|
|
@ -2,3 +2,17 @@
|
|||
#![clippy::msrv = "invalid.version"]
|
||||
|
||||
fn main() {}
|
||||
|
||||
#[clippy::msrv = "invalid.version"]
|
||||
fn outer_attr() {}
|
||||
|
||||
mod multiple {
|
||||
#![clippy::msrv = "1.40"]
|
||||
#![clippy::msrv = "=1.35.0"]
|
||||
#![clippy::msrv = "1.10.1"]
|
||||
|
||||
mod foo {
|
||||
#![clippy::msrv = "1"]
|
||||
#![clippy::msrv = "1.0.0"]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,5 +4,47 @@ error: `invalid.version` is not a valid Rust version
|
|||
LL | #![clippy::msrv = "invalid.version"]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
error: `msrv` cannot be an outer attribute
|
||||
--> $DIR/min_rust_version_invalid_attr.rs:6:1
|
||||
|
|
||||
LL | #[clippy::msrv = "invalid.version"]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: `msrv` is defined multiple times
|
||||
--> $DIR/min_rust_version_invalid_attr.rs:11:5
|
||||
|
|
||||
LL | #![clippy::msrv = "=1.35.0"]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: first definition found here
|
||||
--> $DIR/min_rust_version_invalid_attr.rs:10:5
|
||||
|
|
||||
LL | #![clippy::msrv = "1.40"]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: `msrv` is defined multiple times
|
||||
--> $DIR/min_rust_version_invalid_attr.rs:12:5
|
||||
|
|
||||
LL | #![clippy::msrv = "1.10.1"]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: first definition found here
|
||||
--> $DIR/min_rust_version_invalid_attr.rs:10:5
|
||||
|
|
||||
LL | #![clippy::msrv = "1.40"]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: `msrv` is defined multiple times
|
||||
--> $DIR/min_rust_version_invalid_attr.rs:16:9
|
||||
|
|
||||
LL | #![clippy::msrv = "1.0.0"]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: first definition found here
|
||||
--> $DIR/min_rust_version_invalid_attr.rs:15:9
|
||||
|
|
||||
LL | #![clippy::msrv = "1"]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
#![feature(custom_inner_attributes)]
|
||||
#![clippy::msrv = "1.40"]
|
||||
#![clippy::msrv = "=1.35.0"]
|
||||
#![clippy::msrv = "1.10.1"]
|
||||
|
||||
mod foo {
|
||||
#![clippy::msrv = "1"]
|
||||
#![clippy::msrv = "1.0.0"]
|
||||
}
|
||||
|
||||
fn main() {}
|
|
@ -1,38 +0,0 @@
|
|||
error: `msrv` is defined multiple times
|
||||
--> $DIR/min_rust_version_multiple_inner_attr.rs:3:1
|
||||
|
|
||||
LL | #![clippy::msrv = "=1.35.0"]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: first definition found here
|
||||
--> $DIR/min_rust_version_multiple_inner_attr.rs:2:1
|
||||
|
|
||||
LL | #![clippy::msrv = "1.40"]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: `msrv` is defined multiple times
|
||||
--> $DIR/min_rust_version_multiple_inner_attr.rs:4:1
|
||||
|
|
||||
LL | #![clippy::msrv = "1.10.1"]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: first definition found here
|
||||
--> $DIR/min_rust_version_multiple_inner_attr.rs:2:1
|
||||
|
|
||||
LL | #![clippy::msrv = "1.40"]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: `msrv` is defined multiple times
|
||||
--> $DIR/min_rust_version_multiple_inner_attr.rs:8:5
|
||||
|
|
||||
LL | #![clippy::msrv = "1.0.0"]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: first definition found here
|
||||
--> $DIR/min_rust_version_multiple_inner_attr.rs:7:5
|
||||
|
|
||||
LL | #![clippy::msrv = "1"]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
#![allow(clippy::redundant_clone)]
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![clippy::msrv = "1.0"]
|
||||
|
||||
fn manual_strip_msrv() {
|
||||
let s = "hello, world!";
|
||||
if s.starts_with("hello, ") {
|
||||
assert_eq!(s["hello, ".len()..].to_uppercase(), "WORLD!");
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
manual_strip_msrv()
|
||||
}
|
|
@ -1,4 +0,0 @@
|
|||
#![feature(custom_inner_attributes)]
|
||||
|
||||
#[clippy::msrv = "invalid.version"]
|
||||
fn main() {}
|
|
@ -1,8 +0,0 @@
|
|||
error: `msrv` cannot be an outer attribute
|
||||
--> $DIR/min_rust_version_outer_attr.rs:3:1
|
||||
|
|
||||
LL | #[clippy::msrv = "invalid.version"]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
|
@ -77,5 +77,17 @@ mod const_fn_stabilized_before_msrv {
|
|||
}
|
||||
}
|
||||
|
||||
fn msrv_1_45() -> i32 {
|
||||
#![clippy::msrv = "1.45"]
|
||||
|
||||
45
|
||||
}
|
||||
|
||||
fn msrv_1_46() -> i32 {
|
||||
#![clippy::msrv = "1.46"]
|
||||
|
||||
46
|
||||
}
|
||||
|
||||
// Should not be const
|
||||
fn main() {}
|
||||
|
|
|
@ -81,5 +81,15 @@ LL | | byte.is_ascii_digit();
|
|||
LL | | }
|
||||
| |_____^
|
||||
|
||||
error: aborting due to 10 previous errors
|
||||
error: this could be a `const fn`
|
||||
--> $DIR/could_be_const.rs:86:1
|
||||
|
|
||||
LL | / fn msrv_1_46() -> i32 {
|
||||
LL | | #![clippy::msrv = "1.46"]
|
||||
LL | |
|
||||
LL | | 46
|
||||
LL | | }
|
||||
| |_^
|
||||
|
||||
error: aborting due to 11 previous errors
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
// run-rustfix
|
||||
|
||||
#![allow(unused_imports, clippy::redundant_clone)]
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![allow(unused, clippy::redundant_clone)]
|
||||
#![warn(clippy::option_as_ref_deref)]
|
||||
|
||||
use std::ffi::{CString, OsString};
|
||||
|
@ -42,3 +43,17 @@ fn main() {
|
|||
// Issue #5927
|
||||
let _ = opt.as_deref();
|
||||
}
|
||||
|
||||
fn msrv_1_39() {
|
||||
#![clippy::msrv = "1.39"]
|
||||
|
||||
let opt = Some(String::from("123"));
|
||||
let _ = opt.as_ref().map(String::as_str);
|
||||
}
|
||||
|
||||
fn msrv_1_40() {
|
||||
#![clippy::msrv = "1.40"]
|
||||
|
||||
let opt = Some(String::from("123"));
|
||||
let _ = opt.as_deref();
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
// run-rustfix
|
||||
|
||||
#![allow(unused_imports, clippy::redundant_clone)]
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![allow(unused, clippy::redundant_clone)]
|
||||
#![warn(clippy::option_as_ref_deref)]
|
||||
|
||||
use std::ffi::{CString, OsString};
|
||||
|
@ -45,3 +46,17 @@ fn main() {
|
|||
// Issue #5927
|
||||
let _ = opt.as_ref().map(std::ops::Deref::deref);
|
||||
}
|
||||
|
||||
fn msrv_1_39() {
|
||||
#![clippy::msrv = "1.39"]
|
||||
|
||||
let opt = Some(String::from("123"));
|
||||
let _ = opt.as_ref().map(String::as_str);
|
||||
}
|
||||
|
||||
fn msrv_1_40() {
|
||||
#![clippy::msrv = "1.40"]
|
||||
|
||||
let opt = Some(String::from("123"));
|
||||
let _ = opt.as_ref().map(String::as_str);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error: called `.as_ref().map(Deref::deref)` on an Option value. This can be done more directly by calling `opt.clone().as_deref()` instead
|
||||
--> $DIR/option_as_ref_deref.rs:13:13
|
||||
--> $DIR/option_as_ref_deref.rs:14:13
|
||||
|
|
||||
LL | let _ = opt.clone().as_ref().map(Deref::deref).map(str::len);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using as_deref instead: `opt.clone().as_deref()`
|
||||
|
@ -7,7 +7,7 @@ LL | let _ = opt.clone().as_ref().map(Deref::deref).map(str::len);
|
|||
= note: `-D clippy::option-as-ref-deref` implied by `-D warnings`
|
||||
|
||||
error: called `.as_ref().map(Deref::deref)` on an Option value. This can be done more directly by calling `opt.clone().as_deref()` instead
|
||||
--> $DIR/option_as_ref_deref.rs:16:13
|
||||
--> $DIR/option_as_ref_deref.rs:17:13
|
||||
|
|
||||
LL | let _ = opt.clone()
|
||||
| _____________^
|
||||
|
@ -17,94 +17,100 @@ LL | | )
|
|||
| |_________^ help: try using as_deref instead: `opt.clone().as_deref()`
|
||||
|
||||
error: called `.as_mut().map(DerefMut::deref_mut)` on an Option value. This can be done more directly by calling `opt.as_deref_mut()` instead
|
||||
--> $DIR/option_as_ref_deref.rs:22:13
|
||||
--> $DIR/option_as_ref_deref.rs:23:13
|
||||
|
|
||||
LL | let _ = opt.as_mut().map(DerefMut::deref_mut);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using as_deref_mut instead: `opt.as_deref_mut()`
|
||||
|
||||
error: called `.as_ref().map(String::as_str)` on an Option value. This can be done more directly by calling `opt.as_deref()` instead
|
||||
--> $DIR/option_as_ref_deref.rs:24:13
|
||||
--> $DIR/option_as_ref_deref.rs:25:13
|
||||
|
|
||||
LL | let _ = opt.as_ref().map(String::as_str);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using as_deref instead: `opt.as_deref()`
|
||||
|
||||
error: called `.as_ref().map(|x| x.as_str())` on an Option value. This can be done more directly by calling `opt.as_deref()` instead
|
||||
--> $DIR/option_as_ref_deref.rs:25:13
|
||||
--> $DIR/option_as_ref_deref.rs:26:13
|
||||
|
|
||||
LL | let _ = opt.as_ref().map(|x| x.as_str());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using as_deref instead: `opt.as_deref()`
|
||||
|
||||
error: called `.as_mut().map(String::as_mut_str)` on an Option value. This can be done more directly by calling `opt.as_deref_mut()` instead
|
||||
--> $DIR/option_as_ref_deref.rs:26:13
|
||||
--> $DIR/option_as_ref_deref.rs:27:13
|
||||
|
|
||||
LL | let _ = opt.as_mut().map(String::as_mut_str);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using as_deref_mut instead: `opt.as_deref_mut()`
|
||||
|
||||
error: called `.as_mut().map(|x| x.as_mut_str())` on an Option value. This can be done more directly by calling `opt.as_deref_mut()` instead
|
||||
--> $DIR/option_as_ref_deref.rs:27:13
|
||||
--> $DIR/option_as_ref_deref.rs:28:13
|
||||
|
|
||||
LL | let _ = opt.as_mut().map(|x| x.as_mut_str());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using as_deref_mut instead: `opt.as_deref_mut()`
|
||||
|
||||
error: called `.as_ref().map(CString::as_c_str)` on an Option value. This can be done more directly by calling `Some(CString::new(vec![]).unwrap()).as_deref()` instead
|
||||
--> $DIR/option_as_ref_deref.rs:28:13
|
||||
--> $DIR/option_as_ref_deref.rs:29:13
|
||||
|
|
||||
LL | let _ = Some(CString::new(vec![]).unwrap()).as_ref().map(CString::as_c_str);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using as_deref instead: `Some(CString::new(vec![]).unwrap()).as_deref()`
|
||||
|
||||
error: called `.as_ref().map(OsString::as_os_str)` on an Option value. This can be done more directly by calling `Some(OsString::new()).as_deref()` instead
|
||||
--> $DIR/option_as_ref_deref.rs:29:13
|
||||
--> $DIR/option_as_ref_deref.rs:30:13
|
||||
|
|
||||
LL | let _ = Some(OsString::new()).as_ref().map(OsString::as_os_str);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using as_deref instead: `Some(OsString::new()).as_deref()`
|
||||
|
||||
error: called `.as_ref().map(PathBuf::as_path)` on an Option value. This can be done more directly by calling `Some(PathBuf::new()).as_deref()` instead
|
||||
--> $DIR/option_as_ref_deref.rs:30:13
|
||||
--> $DIR/option_as_ref_deref.rs:31:13
|
||||
|
|
||||
LL | let _ = Some(PathBuf::new()).as_ref().map(PathBuf::as_path);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using as_deref instead: `Some(PathBuf::new()).as_deref()`
|
||||
|
||||
error: called `.as_ref().map(Vec::as_slice)` on an Option value. This can be done more directly by calling `Some(Vec::<()>::new()).as_deref()` instead
|
||||
--> $DIR/option_as_ref_deref.rs:31:13
|
||||
--> $DIR/option_as_ref_deref.rs:32:13
|
||||
|
|
||||
LL | let _ = Some(Vec::<()>::new()).as_ref().map(Vec::as_slice);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using as_deref instead: `Some(Vec::<()>::new()).as_deref()`
|
||||
|
||||
error: called `.as_mut().map(Vec::as_mut_slice)` on an Option value. This can be done more directly by calling `Some(Vec::<()>::new()).as_deref_mut()` instead
|
||||
--> $DIR/option_as_ref_deref.rs:32:13
|
||||
--> $DIR/option_as_ref_deref.rs:33:13
|
||||
|
|
||||
LL | let _ = Some(Vec::<()>::new()).as_mut().map(Vec::as_mut_slice);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using as_deref_mut instead: `Some(Vec::<()>::new()).as_deref_mut()`
|
||||
|
||||
error: called `.as_ref().map(|x| x.deref())` on an Option value. This can be done more directly by calling `opt.as_deref()` instead
|
||||
--> $DIR/option_as_ref_deref.rs:34:13
|
||||
--> $DIR/option_as_ref_deref.rs:35:13
|
||||
|
|
||||
LL | let _ = opt.as_ref().map(|x| x.deref());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using as_deref instead: `opt.as_deref()`
|
||||
|
||||
error: called `.as_mut().map(|x| x.deref_mut())` on an Option value. This can be done more directly by calling `opt.clone().as_deref_mut()` instead
|
||||
--> $DIR/option_as_ref_deref.rs:35:13
|
||||
--> $DIR/option_as_ref_deref.rs:36:13
|
||||
|
|
||||
LL | let _ = opt.clone().as_mut().map(|x| x.deref_mut()).map(|x| x.len());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using as_deref_mut instead: `opt.clone().as_deref_mut()`
|
||||
|
||||
error: called `.as_ref().map(|x| &**x)` on an Option value. This can be done more directly by calling `opt.as_deref()` instead
|
||||
--> $DIR/option_as_ref_deref.rs:42:13
|
||||
--> $DIR/option_as_ref_deref.rs:43:13
|
||||
|
|
||||
LL | let _ = opt.as_ref().map(|x| &**x);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using as_deref instead: `opt.as_deref()`
|
||||
|
||||
error: called `.as_mut().map(|x| &mut **x)` on an Option value. This can be done more directly by calling `opt.as_deref_mut()` instead
|
||||
--> $DIR/option_as_ref_deref.rs:43:13
|
||||
--> $DIR/option_as_ref_deref.rs:44:13
|
||||
|
|
||||
LL | let _ = opt.as_mut().map(|x| &mut **x);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using as_deref_mut instead: `opt.as_deref_mut()`
|
||||
|
||||
error: called `.as_ref().map(std::ops::Deref::deref)` on an Option value. This can be done more directly by calling `opt.as_deref()` instead
|
||||
--> $DIR/option_as_ref_deref.rs:46:13
|
||||
--> $DIR/option_as_ref_deref.rs:47:13
|
||||
|
|
||||
LL | let _ = opt.as_ref().map(std::ops::Deref::deref);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using as_deref instead: `opt.as_deref()`
|
||||
|
||||
error: aborting due to 17 previous errors
|
||||
error: called `.as_ref().map(String::as_str)` on an Option value. This can be done more directly by calling `opt.as_deref()` instead
|
||||
--> $DIR/option_as_ref_deref.rs:61:13
|
||||
|
|
||||
LL | let _ = opt.as_ref().map(String::as_str);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using as_deref instead: `opt.as_deref()`
|
||||
|
||||
error: aborting due to 18 previous errors
|
||||
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
// run-rustfix
|
||||
|
||||
#[warn(clippy::manual_range_contains)]
|
||||
#[allow(unused)]
|
||||
#[allow(clippy::no_effect)]
|
||||
#[allow(clippy::short_circuit_statement)]
|
||||
#[allow(clippy::unnecessary_operation)]
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![warn(clippy::manual_range_contains)]
|
||||
#![allow(unused)]
|
||||
#![allow(clippy::no_effect)]
|
||||
#![allow(clippy::short_circuit_statement)]
|
||||
#![allow(clippy::unnecessary_operation)]
|
||||
|
||||
fn main() {
|
||||
let x = 9_i32;
|
||||
|
||||
|
@ -62,3 +64,17 @@ fn main() {
|
|||
pub const fn in_range(a: i32) -> bool {
|
||||
3 <= a && a <= 20
|
||||
}
|
||||
|
||||
fn msrv_1_34() {
|
||||
#![clippy::msrv = "1.34"]
|
||||
|
||||
let x = 5;
|
||||
x >= 8 && x < 34;
|
||||
}
|
||||
|
||||
fn msrv_1_35() {
|
||||
#![clippy::msrv = "1.35"]
|
||||
|
||||
let x = 5;
|
||||
(8..35).contains(&x);
|
||||
}
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
// run-rustfix
|
||||
|
||||
#[warn(clippy::manual_range_contains)]
|
||||
#[allow(unused)]
|
||||
#[allow(clippy::no_effect)]
|
||||
#[allow(clippy::short_circuit_statement)]
|
||||
#[allow(clippy::unnecessary_operation)]
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![warn(clippy::manual_range_contains)]
|
||||
#![allow(unused)]
|
||||
#![allow(clippy::no_effect)]
|
||||
#![allow(clippy::short_circuit_statement)]
|
||||
#![allow(clippy::unnecessary_operation)]
|
||||
|
||||
fn main() {
|
||||
let x = 9_i32;
|
||||
|
||||
|
@ -62,3 +64,17 @@ fn main() {
|
|||
pub const fn in_range(a: i32) -> bool {
|
||||
3 <= a && a <= 20
|
||||
}
|
||||
|
||||
fn msrv_1_34() {
|
||||
#![clippy::msrv = "1.34"]
|
||||
|
||||
let x = 5;
|
||||
x >= 8 && x < 34;
|
||||
}
|
||||
|
||||
fn msrv_1_35() {
|
||||
#![clippy::msrv = "1.35"]
|
||||
|
||||
let x = 5;
|
||||
x >= 8 && x < 35;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error: manual `Range::contains` implementation
|
||||
--> $DIR/range_contains.rs:12:5
|
||||
--> $DIR/range_contains.rs:14:5
|
||||
|
|
||||
LL | x >= 8 && x < 12;
|
||||
| ^^^^^^^^^^^^^^^^ help: use: `(8..12).contains(&x)`
|
||||
|
@ -7,118 +7,124 @@ LL | x >= 8 && x < 12;
|
|||
= note: `-D clippy::manual-range-contains` implied by `-D warnings`
|
||||
|
||||
error: manual `Range::contains` implementation
|
||||
--> $DIR/range_contains.rs:13:5
|
||||
--> $DIR/range_contains.rs:15:5
|
||||
|
|
||||
LL | x < 42 && x >= 21;
|
||||
| ^^^^^^^^^^^^^^^^^ help: use: `(21..42).contains(&x)`
|
||||
|
||||
error: manual `Range::contains` implementation
|
||||
--> $DIR/range_contains.rs:14:5
|
||||
--> $DIR/range_contains.rs:16:5
|
||||
|
|
||||
LL | 100 > x && 1 <= x;
|
||||
| ^^^^^^^^^^^^^^^^^ help: use: `(1..100).contains(&x)`
|
||||
|
||||
error: manual `RangeInclusive::contains` implementation
|
||||
--> $DIR/range_contains.rs:17:5
|
||||
--> $DIR/range_contains.rs:19:5
|
||||
|
|
||||
LL | x >= 9 && x <= 99;
|
||||
| ^^^^^^^^^^^^^^^^^ help: use: `(9..=99).contains(&x)`
|
||||
|
||||
error: manual `RangeInclusive::contains` implementation
|
||||
--> $DIR/range_contains.rs:18:5
|
||||
--> $DIR/range_contains.rs:20:5
|
||||
|
|
||||
LL | x <= 33 && x >= 1;
|
||||
| ^^^^^^^^^^^^^^^^^ help: use: `(1..=33).contains(&x)`
|
||||
|
||||
error: manual `RangeInclusive::contains` implementation
|
||||
--> $DIR/range_contains.rs:19:5
|
||||
--> $DIR/range_contains.rs:21:5
|
||||
|
|
||||
LL | 999 >= x && 1 <= x;
|
||||
| ^^^^^^^^^^^^^^^^^^ help: use: `(1..=999).contains(&x)`
|
||||
|
||||
error: manual `!Range::contains` implementation
|
||||
--> $DIR/range_contains.rs:22:5
|
||||
--> $DIR/range_contains.rs:24:5
|
||||
|
|
||||
LL | x < 8 || x >= 12;
|
||||
| ^^^^^^^^^^^^^^^^ help: use: `!(8..12).contains(&x)`
|
||||
|
||||
error: manual `!Range::contains` implementation
|
||||
--> $DIR/range_contains.rs:23:5
|
||||
--> $DIR/range_contains.rs:25:5
|
||||
|
|
||||
LL | x >= 42 || x < 21;
|
||||
| ^^^^^^^^^^^^^^^^^ help: use: `!(21..42).contains(&x)`
|
||||
|
||||
error: manual `!Range::contains` implementation
|
||||
--> $DIR/range_contains.rs:24:5
|
||||
--> $DIR/range_contains.rs:26:5
|
||||
|
|
||||
LL | 100 <= x || 1 > x;
|
||||
| ^^^^^^^^^^^^^^^^^ help: use: `!(1..100).contains(&x)`
|
||||
|
||||
error: manual `!RangeInclusive::contains` implementation
|
||||
--> $DIR/range_contains.rs:27:5
|
||||
--> $DIR/range_contains.rs:29:5
|
||||
|
|
||||
LL | x < 9 || x > 99;
|
||||
| ^^^^^^^^^^^^^^^ help: use: `!(9..=99).contains(&x)`
|
||||
|
||||
error: manual `!RangeInclusive::contains` implementation
|
||||
--> $DIR/range_contains.rs:28:5
|
||||
--> $DIR/range_contains.rs:30:5
|
||||
|
|
||||
LL | x > 33 || x < 1;
|
||||
| ^^^^^^^^^^^^^^^ help: use: `!(1..=33).contains(&x)`
|
||||
|
||||
error: manual `!RangeInclusive::contains` implementation
|
||||
--> $DIR/range_contains.rs:29:5
|
||||
--> $DIR/range_contains.rs:31:5
|
||||
|
|
||||
LL | 999 < x || 1 > x;
|
||||
| ^^^^^^^^^^^^^^^^ help: use: `!(1..=999).contains(&x)`
|
||||
|
||||
error: manual `Range::contains` implementation
|
||||
--> $DIR/range_contains.rs:44:5
|
||||
--> $DIR/range_contains.rs:46:5
|
||||
|
|
||||
LL | y >= 0. && y < 1.;
|
||||
| ^^^^^^^^^^^^^^^^^ help: use: `(0. ..1.).contains(&y)`
|
||||
|
||||
error: manual `!RangeInclusive::contains` implementation
|
||||
--> $DIR/range_contains.rs:45:5
|
||||
--> $DIR/range_contains.rs:47:5
|
||||
|
|
||||
LL | y < 0. || y > 1.;
|
||||
| ^^^^^^^^^^^^^^^^ help: use: `!(0. ..=1.).contains(&y)`
|
||||
|
||||
error: manual `RangeInclusive::contains` implementation
|
||||
--> $DIR/range_contains.rs:48:5
|
||||
--> $DIR/range_contains.rs:50:5
|
||||
|
|
||||
LL | x >= -10 && x <= 10;
|
||||
| ^^^^^^^^^^^^^^^^^^^ help: use: `(-10..=10).contains(&x)`
|
||||
|
||||
error: manual `RangeInclusive::contains` implementation
|
||||
--> $DIR/range_contains.rs:50:5
|
||||
--> $DIR/range_contains.rs:52:5
|
||||
|
|
||||
LL | y >= -3. && y <= 3.;
|
||||
| ^^^^^^^^^^^^^^^^^^^ help: use: `(-3. ..=3.).contains(&y)`
|
||||
|
||||
error: manual `RangeInclusive::contains` implementation
|
||||
--> $DIR/range_contains.rs:55:30
|
||||
--> $DIR/range_contains.rs:57:30
|
||||
|
|
||||
LL | (x >= 0) && (x <= 10) && (z >= 0) && (z <= 10);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ help: use: `(0..=10).contains(&z)`
|
||||
|
||||
error: manual `RangeInclusive::contains` implementation
|
||||
--> $DIR/range_contains.rs:55:5
|
||||
--> $DIR/range_contains.rs:57:5
|
||||
|
|
||||
LL | (x >= 0) && (x <= 10) && (z >= 0) && (z <= 10);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ help: use: `(0..=10).contains(&x)`
|
||||
|
||||
error: manual `!Range::contains` implementation
|
||||
--> $DIR/range_contains.rs:56:29
|
||||
--> $DIR/range_contains.rs:58:29
|
||||
|
|
||||
LL | (x < 0) || (x >= 10) || (z < 0) || (z >= 10);
|
||||
| ^^^^^^^^^^^^^^^^^^^^ help: use: `!(0..10).contains(&z)`
|
||||
|
||||
error: manual `!Range::contains` implementation
|
||||
--> $DIR/range_contains.rs:56:5
|
||||
--> $DIR/range_contains.rs:58:5
|
||||
|
|
||||
LL | (x < 0) || (x >= 10) || (z < 0) || (z >= 10);
|
||||
| ^^^^^^^^^^^^^^^^^^^^ help: use: `!(0..10).contains(&x)`
|
||||
|
||||
error: aborting due to 20 previous errors
|
||||
error: manual `Range::contains` implementation
|
||||
--> $DIR/range_contains.rs:79:5
|
||||
|
|
||||
LL | x >= 8 && x < 35;
|
||||
| ^^^^^^^^^^^^^^^^ help: use: `(8..35).contains(&x)`
|
||||
|
||||
error: aborting due to 21 previous errors
|
||||
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
// run-rustfix
|
||||
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![warn(clippy::redundant_field_names)]
|
||||
#![allow(clippy::no_effect, dead_code, unused_variables)]
|
||||
|
||||
|
@ -69,3 +71,17 @@ fn issue_3476() {
|
|||
|
||||
S { foo: foo::<i32> };
|
||||
}
|
||||
|
||||
fn msrv_1_16() {
|
||||
#![clippy::msrv = "1.16"]
|
||||
|
||||
let start = 0;
|
||||
let _ = RangeFrom { start: start };
|
||||
}
|
||||
|
||||
fn msrv_1_17() {
|
||||
#![clippy::msrv = "1.17"]
|
||||
|
||||
let start = 0;
|
||||
let _ = RangeFrom { start };
|
||||
}
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
// run-rustfix
|
||||
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![warn(clippy::redundant_field_names)]
|
||||
#![allow(clippy::no_effect, dead_code, unused_variables)]
|
||||
|
||||
|
@ -69,3 +71,17 @@ fn issue_3476() {
|
|||
|
||||
S { foo: foo::<i32> };
|
||||
}
|
||||
|
||||
fn msrv_1_16() {
|
||||
#![clippy::msrv = "1.16"]
|
||||
|
||||
let start = 0;
|
||||
let _ = RangeFrom { start: start };
|
||||
}
|
||||
|
||||
fn msrv_1_17() {
|
||||
#![clippy::msrv = "1.17"]
|
||||
|
||||
let start = 0;
|
||||
let _ = RangeFrom { start: start };
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error: redundant field names in struct initialization
|
||||
--> $DIR/redundant_field_names.rs:34:9
|
||||
--> $DIR/redundant_field_names.rs:36:9
|
||||
|
|
||||
LL | gender: gender,
|
||||
| ^^^^^^^^^^^^^^ help: replace it with: `gender`
|
||||
|
@ -7,40 +7,46 @@ LL | gender: gender,
|
|||
= note: `-D clippy::redundant-field-names` implied by `-D warnings`
|
||||
|
||||
error: redundant field names in struct initialization
|
||||
--> $DIR/redundant_field_names.rs:35:9
|
||||
--> $DIR/redundant_field_names.rs:37:9
|
||||
|
|
||||
LL | age: age,
|
||||
| ^^^^^^^^ help: replace it with: `age`
|
||||
|
||||
error: redundant field names in struct initialization
|
||||
--> $DIR/redundant_field_names.rs:56:25
|
||||
--> $DIR/redundant_field_names.rs:58:25
|
||||
|
|
||||
LL | let _ = RangeFrom { start: start };
|
||||
| ^^^^^^^^^^^^ help: replace it with: `start`
|
||||
|
||||
error: redundant field names in struct initialization
|
||||
--> $DIR/redundant_field_names.rs:57:23
|
||||
--> $DIR/redundant_field_names.rs:59:23
|
||||
|
|
||||
LL | let _ = RangeTo { end: end };
|
||||
| ^^^^^^^^ help: replace it with: `end`
|
||||
|
||||
error: redundant field names in struct initialization
|
||||
--> $DIR/redundant_field_names.rs:58:21
|
||||
--> $DIR/redundant_field_names.rs:60:21
|
||||
|
|
||||
LL | let _ = Range { start: start, end: end };
|
||||
| ^^^^^^^^^^^^ help: replace it with: `start`
|
||||
|
||||
error: redundant field names in struct initialization
|
||||
--> $DIR/redundant_field_names.rs:58:35
|
||||
--> $DIR/redundant_field_names.rs:60:35
|
||||
|
|
||||
LL | let _ = Range { start: start, end: end };
|
||||
| ^^^^^^^^ help: replace it with: `end`
|
||||
|
||||
error: redundant field names in struct initialization
|
||||
--> $DIR/redundant_field_names.rs:60:32
|
||||
--> $DIR/redundant_field_names.rs:62:32
|
||||
|
|
||||
LL | let _ = RangeToInclusive { end: end };
|
||||
| ^^^^^^^^ help: replace it with: `end`
|
||||
|
||||
error: aborting due to 7 previous errors
|
||||
error: redundant field names in struct initialization
|
||||
--> $DIR/redundant_field_names.rs:86:25
|
||||
|
|
||||
LL | let _ = RangeFrom { start: start };
|
||||
| ^^^^^^^^^^^^ help: replace it with: `start`
|
||||
|
||||
error: aborting due to 8 previous errors
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// run-rustfix
|
||||
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![allow(unused)]
|
||||
|
||||
#[derive(Debug)]
|
||||
|
@ -54,3 +55,15 @@ impl Foo {
|
|||
impl Bar for Foo {
|
||||
const TRAIT_VAR: &'static str = "foo";
|
||||
}
|
||||
|
||||
fn msrv_1_16() {
|
||||
#![clippy::msrv = "1.16"]
|
||||
|
||||
static V: &'static u8 = &16;
|
||||
}
|
||||
|
||||
fn msrv_1_17() {
|
||||
#![clippy::msrv = "1.17"]
|
||||
|
||||
static V: &u8 = &17;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
// run-rustfix
|
||||
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![allow(unused)]
|
||||
|
||||
#[derive(Debug)]
|
||||
|
@ -54,3 +55,15 @@ impl Foo {
|
|||
impl Bar for Foo {
|
||||
const TRAIT_VAR: &'static str = "foo";
|
||||
}
|
||||
|
||||
fn msrv_1_16() {
|
||||
#![clippy::msrv = "1.16"]
|
||||
|
||||
static V: &'static u8 = &16;
|
||||
}
|
||||
|
||||
fn msrv_1_17() {
|
||||
#![clippy::msrv = "1.17"]
|
||||
|
||||
static V: &'static u8 = &17;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error: constants have by default a `'static` lifetime
|
||||
--> $DIR/redundant_static_lifetimes.rs:8:17
|
||||
--> $DIR/redundant_static_lifetimes.rs:9:17
|
||||
|
|
||||
LL | const VAR_ONE: &'static str = "Test constant #1"; // ERROR Consider removing 'static.
|
||||
| -^^^^^^^---- help: consider removing `'static`: `&str`
|
||||
|
@ -7,94 +7,100 @@ LL | const VAR_ONE: &'static str = "Test constant #1"; // ERROR Consider removin
|
|||
= note: `-D clippy::redundant-static-lifetimes` implied by `-D warnings`
|
||||
|
||||
error: constants have by default a `'static` lifetime
|
||||
--> $DIR/redundant_static_lifetimes.rs:12:21
|
||||
--> $DIR/redundant_static_lifetimes.rs:13:21
|
||||
|
|
||||
LL | const VAR_THREE: &[&'static str] = &["one", "two"]; // ERROR Consider removing 'static
|
||||
| -^^^^^^^---- help: consider removing `'static`: `&str`
|
||||
|
||||
error: constants have by default a `'static` lifetime
|
||||
--> $DIR/redundant_static_lifetimes.rs:14:32
|
||||
--> $DIR/redundant_static_lifetimes.rs:15:32
|
||||
|
|
||||
LL | const VAR_FOUR: (&str, (&str, &'static str), &'static str) = ("on", ("th", "th"), "on"); // ERROR Consider removing 'static
|
||||
| -^^^^^^^---- help: consider removing `'static`: `&str`
|
||||
|
||||
error: constants have by default a `'static` lifetime
|
||||
--> $DIR/redundant_static_lifetimes.rs:14:47
|
||||
--> $DIR/redundant_static_lifetimes.rs:15:47
|
||||
|
|
||||
LL | const VAR_FOUR: (&str, (&str, &'static str), &'static str) = ("on", ("th", "th"), "on"); // ERROR Consider removing 'static
|
||||
| -^^^^^^^---- help: consider removing `'static`: `&str`
|
||||
|
||||
error: constants have by default a `'static` lifetime
|
||||
--> $DIR/redundant_static_lifetimes.rs:16:17
|
||||
--> $DIR/redundant_static_lifetimes.rs:17:17
|
||||
|
|
||||
LL | const VAR_SIX: &'static u8 = &5;
|
||||
| -^^^^^^^--- help: consider removing `'static`: `&u8`
|
||||
|
||||
error: constants have by default a `'static` lifetime
|
||||
--> $DIR/redundant_static_lifetimes.rs:18:20
|
||||
--> $DIR/redundant_static_lifetimes.rs:19:20
|
||||
|
|
||||
LL | const VAR_HEIGHT: &'static Foo = &Foo {};
|
||||
| -^^^^^^^---- help: consider removing `'static`: `&Foo`
|
||||
|
||||
error: constants have by default a `'static` lifetime
|
||||
--> $DIR/redundant_static_lifetimes.rs:20:19
|
||||
--> $DIR/redundant_static_lifetimes.rs:21:19
|
||||
|
|
||||
LL | const VAR_SLICE: &'static [u8] = b"Test constant #1"; // ERROR Consider removing 'static.
|
||||
| -^^^^^^^----- help: consider removing `'static`: `&[u8]`
|
||||
|
||||
error: constants have by default a `'static` lifetime
|
||||
--> $DIR/redundant_static_lifetimes.rs:22:19
|
||||
--> $DIR/redundant_static_lifetimes.rs:23:19
|
||||
|
|
||||
LL | const VAR_TUPLE: &'static (u8, u8) = &(1, 2); // ERROR Consider removing 'static.
|
||||
| -^^^^^^^--------- help: consider removing `'static`: `&(u8, u8)`
|
||||
|
||||
error: constants have by default a `'static` lifetime
|
||||
--> $DIR/redundant_static_lifetimes.rs:24:19
|
||||
--> $DIR/redundant_static_lifetimes.rs:25:19
|
||||
|
|
||||
LL | const VAR_ARRAY: &'static [u8; 1] = b"T"; // ERROR Consider removing 'static.
|
||||
| -^^^^^^^-------- help: consider removing `'static`: `&[u8; 1]`
|
||||
|
||||
error: statics have by default a `'static` lifetime
|
||||
--> $DIR/redundant_static_lifetimes.rs:26:25
|
||||
--> $DIR/redundant_static_lifetimes.rs:27:25
|
||||
|
|
||||
LL | static STATIC_VAR_ONE: &'static str = "Test static #1"; // ERROR Consider removing 'static.
|
||||
| -^^^^^^^---- help: consider removing `'static`: `&str`
|
||||
|
||||
error: statics have by default a `'static` lifetime
|
||||
--> $DIR/redundant_static_lifetimes.rs:30:29
|
||||
--> $DIR/redundant_static_lifetimes.rs:31:29
|
||||
|
|
||||
LL | static STATIC_VAR_THREE: &[&'static str] = &["one", "two"]; // ERROR Consider removing 'static
|
||||
| -^^^^^^^---- help: consider removing `'static`: `&str`
|
||||
|
||||
error: statics have by default a `'static` lifetime
|
||||
--> $DIR/redundant_static_lifetimes.rs:32:25
|
||||
--> $DIR/redundant_static_lifetimes.rs:33:25
|
||||
|
|
||||
LL | static STATIC_VAR_SIX: &'static u8 = &5;
|
||||
| -^^^^^^^--- help: consider removing `'static`: `&u8`
|
||||
|
||||
error: statics have by default a `'static` lifetime
|
||||
--> $DIR/redundant_static_lifetimes.rs:34:28
|
||||
--> $DIR/redundant_static_lifetimes.rs:35:28
|
||||
|
|
||||
LL | static STATIC_VAR_HEIGHT: &'static Foo = &Foo {};
|
||||
| -^^^^^^^---- help: consider removing `'static`: `&Foo`
|
||||
|
||||
error: statics have by default a `'static` lifetime
|
||||
--> $DIR/redundant_static_lifetimes.rs:36:27
|
||||
--> $DIR/redundant_static_lifetimes.rs:37:27
|
||||
|
|
||||
LL | static STATIC_VAR_SLICE: &'static [u8] = b"Test static #3"; // ERROR Consider removing 'static.
|
||||
| -^^^^^^^----- help: consider removing `'static`: `&[u8]`
|
||||
|
||||
error: statics have by default a `'static` lifetime
|
||||
--> $DIR/redundant_static_lifetimes.rs:38:27
|
||||
--> $DIR/redundant_static_lifetimes.rs:39:27
|
||||
|
|
||||
LL | static STATIC_VAR_TUPLE: &'static (u8, u8) = &(1, 2); // ERROR Consider removing 'static.
|
||||
| -^^^^^^^--------- help: consider removing `'static`: `&(u8, u8)`
|
||||
|
||||
error: statics have by default a `'static` lifetime
|
||||
--> $DIR/redundant_static_lifetimes.rs:40:27
|
||||
--> $DIR/redundant_static_lifetimes.rs:41:27
|
||||
|
|
||||
LL | static STATIC_VAR_ARRAY: &'static [u8; 1] = b"T"; // ERROR Consider removing 'static.
|
||||
| -^^^^^^^-------- help: consider removing `'static`: `&[u8; 1]`
|
||||
|
||||
error: aborting due to 16 previous errors
|
||||
error: statics have by default a `'static` lifetime
|
||||
--> $DIR/redundant_static_lifetimes.rs:68:16
|
||||
|
|
||||
LL | static V: &'static u8 = &17;
|
||||
| -^^^^^^^--- help: consider removing `'static`: `&u8`
|
||||
|
||||
error: aborting due to 17 previous errors
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
// run-rustfix
|
||||
|
||||
#![feature(box_patterns)]
|
||||
#![feature(box_patterns, custom_inner_attributes)]
|
||||
#![warn(clippy::unnested_or_patterns)]
|
||||
#![allow(clippy::cognitive_complexity, clippy::match_ref_pats, clippy::upper_case_acronyms)]
|
||||
#![allow(unreachable_patterns, irrefutable_let_patterns, unused_variables)]
|
||||
#![allow(unreachable_patterns, irrefutable_let_patterns, unused)]
|
||||
|
||||
fn main() {
|
||||
// Should be ignored by this lint, as nesting requires more characters.
|
||||
|
@ -33,3 +33,15 @@ fn main() {
|
|||
if let S { x: 0 | 1, y } = (S { x: 0, y: 1 }) {}
|
||||
if let S { x: 0, y, .. } | S { y, x: 1 } = (S { x: 0, y: 1 }) {}
|
||||
}
|
||||
|
||||
fn msrv_1_52() {
|
||||
#![clippy::msrv = "1.52"]
|
||||
|
||||
if let [1] | [52] = [0] {}
|
||||
}
|
||||
|
||||
fn msrv_1_53() {
|
||||
#![clippy::msrv = "1.53"]
|
||||
|
||||
if let [1 | 53] = [0] {}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
// run-rustfix
|
||||
|
||||
#![feature(box_patterns)]
|
||||
#![feature(box_patterns, custom_inner_attributes)]
|
||||
#![warn(clippy::unnested_or_patterns)]
|
||||
#![allow(clippy::cognitive_complexity, clippy::match_ref_pats, clippy::upper_case_acronyms)]
|
||||
#![allow(unreachable_patterns, irrefutable_let_patterns, unused_variables)]
|
||||
#![allow(unreachable_patterns, irrefutable_let_patterns, unused)]
|
||||
|
||||
fn main() {
|
||||
// Should be ignored by this lint, as nesting requires more characters.
|
||||
|
@ -33,3 +33,15 @@ fn main() {
|
|||
if let S { x: 0, y } | S { y, x: 1 } = (S { x: 0, y: 1 }) {}
|
||||
if let S { x: 0, y, .. } | S { y, x: 1 } = (S { x: 0, y: 1 }) {}
|
||||
}
|
||||
|
||||
fn msrv_1_52() {
|
||||
#![clippy::msrv = "1.52"]
|
||||
|
||||
if let [1] | [52] = [0] {}
|
||||
}
|
||||
|
||||
fn msrv_1_53() {
|
||||
#![clippy::msrv = "1.53"]
|
||||
|
||||
if let [1] | [53] = [0] {}
|
||||
}
|
||||
|
|
|
@ -175,5 +175,16 @@ help: nest the patterns
|
|||
LL | if let S { x: 0 | 1, y } = (S { x: 0, y: 1 }) {}
|
||||
| ~~~~~~~~~~~~~~~~~
|
||||
|
||||
error: aborting due to 16 previous errors
|
||||
error: unnested or-patterns
|
||||
--> $DIR/unnested_or_patterns.rs:46:12
|
||||
|
|
||||
LL | if let [1] | [53] = [0] {}
|
||||
| ^^^^^^^^^^
|
||||
|
|
||||
help: nest the patterns
|
||||
|
|
||||
LL | if let [1 | 53] = [0] {}
|
||||
| ~~~~~~~~
|
||||
|
||||
error: aborting due to 17 previous errors
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
// run-rustfix
|
||||
// aux-build:proc_macro_derive.rs
|
||||
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![warn(clippy::use_self)]
|
||||
#![allow(dead_code, unreachable_code)]
|
||||
#![allow(
|
||||
|
@ -617,3 +618,35 @@ mod issue6902 {
|
|||
Bar = 1,
|
||||
}
|
||||
}
|
||||
|
||||
fn msrv_1_36() {
|
||||
#![clippy::msrv = "1.36"]
|
||||
|
||||
enum E {
|
||||
A,
|
||||
}
|
||||
|
||||
impl E {
|
||||
fn foo(self) {
|
||||
match self {
|
||||
E::A => {},
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn msrv_1_37() {
|
||||
#![clippy::msrv = "1.37"]
|
||||
|
||||
enum E {
|
||||
A,
|
||||
}
|
||||
|
||||
impl E {
|
||||
fn foo(self) {
|
||||
match self {
|
||||
Self::A => {},
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
// run-rustfix
|
||||
// aux-build:proc_macro_derive.rs
|
||||
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![warn(clippy::use_self)]
|
||||
#![allow(dead_code, unreachable_code)]
|
||||
#![allow(
|
||||
|
@ -617,3 +618,35 @@ mod issue6902 {
|
|||
Bar = 1,
|
||||
}
|
||||
}
|
||||
|
||||
fn msrv_1_36() {
|
||||
#![clippy::msrv = "1.36"]
|
||||
|
||||
enum E {
|
||||
A,
|
||||
}
|
||||
|
||||
impl E {
|
||||
fn foo(self) {
|
||||
match self {
|
||||
E::A => {},
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn msrv_1_37() {
|
||||
#![clippy::msrv = "1.37"]
|
||||
|
||||
enum E {
|
||||
A,
|
||||
}
|
||||
|
||||
impl E {
|
||||
fn foo(self) {
|
||||
match self {
|
||||
E::A => {},
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error: unnecessary structure name repetition
|
||||
--> $DIR/use_self.rs:22:21
|
||||
--> $DIR/use_self.rs:23:21
|
||||
|
|
||||
LL | fn new() -> Foo {
|
||||
| ^^^ help: use the applicable keyword: `Self`
|
||||
|
@ -7,244 +7,250 @@ LL | fn new() -> Foo {
|
|||
= note: `-D clippy::use-self` implied by `-D warnings`
|
||||
|
||||
error: unnecessary structure name repetition
|
||||
--> $DIR/use_self.rs:23:13
|
||||
--> $DIR/use_self.rs:24:13
|
||||
|
|
||||
LL | Foo {}
|
||||
| ^^^ help: use the applicable keyword: `Self`
|
||||
|
||||
error: unnecessary structure name repetition
|
||||
--> $DIR/use_self.rs:25:22
|
||||
--> $DIR/use_self.rs:26:22
|
||||
|
|
||||
LL | fn test() -> Foo {
|
||||
| ^^^ help: use the applicable keyword: `Self`
|
||||
|
||||
error: unnecessary structure name repetition
|
||||
--> $DIR/use_self.rs:26:13
|
||||
--> $DIR/use_self.rs:27:13
|
||||
|
|
||||
LL | Foo::new()
|
||||
| ^^^ help: use the applicable keyword: `Self`
|
||||
|
||||
error: unnecessary structure name repetition
|
||||
--> $DIR/use_self.rs:31:25
|
||||
--> $DIR/use_self.rs:32:25
|
||||
|
|
||||
LL | fn default() -> Foo {
|
||||
| ^^^ help: use the applicable keyword: `Self`
|
||||
|
||||
error: unnecessary structure name repetition
|
||||
--> $DIR/use_self.rs:32:13
|
||||
--> $DIR/use_self.rs:33:13
|
||||
|
|
||||
LL | Foo::new()
|
||||
| ^^^ help: use the applicable keyword: `Self`
|
||||
|
||||
error: unnecessary structure name repetition
|
||||
--> $DIR/use_self.rs:97:24
|
||||
--> $DIR/use_self.rs:98:24
|
||||
|
|
||||
LL | fn bad(foos: &[Foo]) -> impl Iterator<Item = &Foo> {
|
||||
| ^^^ help: use the applicable keyword: `Self`
|
||||
|
||||
error: unnecessary structure name repetition
|
||||
--> $DIR/use_self.rs:97:55
|
||||
--> $DIR/use_self.rs:98:55
|
||||
|
|
||||
LL | fn bad(foos: &[Foo]) -> impl Iterator<Item = &Foo> {
|
||||
| ^^^ help: use the applicable keyword: `Self`
|
||||
|
||||
error: unnecessary structure name repetition
|
||||
--> $DIR/use_self.rs:112:13
|
||||
--> $DIR/use_self.rs:113:13
|
||||
|
|
||||
LL | TS(0)
|
||||
| ^^ help: use the applicable keyword: `Self`
|
||||
|
||||
error: unnecessary structure name repetition
|
||||
--> $DIR/use_self.rs:147:29
|
||||
--> $DIR/use_self.rs:148:29
|
||||
|
|
||||
LL | fn bar() -> Bar {
|
||||
| ^^^ help: use the applicable keyword: `Self`
|
||||
|
||||
error: unnecessary structure name repetition
|
||||
--> $DIR/use_self.rs:148:21
|
||||
--> $DIR/use_self.rs:149:21
|
||||
|
|
||||
LL | Bar { foo: Foo {} }
|
||||
| ^^^ help: use the applicable keyword: `Self`
|
||||
|
||||
error: unnecessary structure name repetition
|
||||
--> $DIR/use_self.rs:159:21
|
||||
--> $DIR/use_self.rs:160:21
|
||||
|
|
||||
LL | fn baz() -> Foo {
|
||||
| ^^^ help: use the applicable keyword: `Self`
|
||||
|
||||
error: unnecessary structure name repetition
|
||||
--> $DIR/use_self.rs:160:13
|
||||
--> $DIR/use_self.rs:161:13
|
||||
|
|
||||
LL | Foo {}
|
||||
| ^^^ help: use the applicable keyword: `Self`
|
||||
|
||||
error: unnecessary structure name repetition
|
||||
--> $DIR/use_self.rs:177:21
|
||||
--> $DIR/use_self.rs:178:21
|
||||
|
|
||||
LL | let _ = Enum::B(42);
|
||||
| ^^^^ help: use the applicable keyword: `Self`
|
||||
|
||||
error: unnecessary structure name repetition
|
||||
--> $DIR/use_self.rs:178:21
|
||||
--> $DIR/use_self.rs:179:21
|
||||
|
|
||||
LL | let _ = Enum::C { field: true };
|
||||
| ^^^^ help: use the applicable keyword: `Self`
|
||||
|
||||
error: unnecessary structure name repetition
|
||||
--> $DIR/use_self.rs:179:21
|
||||
--> $DIR/use_self.rs:180:21
|
||||
|
|
||||
LL | let _ = Enum::A;
|
||||
| ^^^^ help: use the applicable keyword: `Self`
|
||||
|
||||
error: unnecessary structure name repetition
|
||||
--> $DIR/use_self.rs:221:13
|
||||
--> $DIR/use_self.rs:222:13
|
||||
|
|
||||
LL | nested::A::fun_1();
|
||||
| ^^^^^^^^^ help: use the applicable keyword: `Self`
|
||||
|
||||
error: unnecessary structure name repetition
|
||||
--> $DIR/use_self.rs:222:13
|
||||
--> $DIR/use_self.rs:223:13
|
||||
|
|
||||
LL | nested::A::A;
|
||||
| ^^^^^^^^^ help: use the applicable keyword: `Self`
|
||||
|
||||
error: unnecessary structure name repetition
|
||||
--> $DIR/use_self.rs:224:13
|
||||
--> $DIR/use_self.rs:225:13
|
||||
|
|
||||
LL | nested::A {};
|
||||
| ^^^^^^^^^ help: use the applicable keyword: `Self`
|
||||
|
||||
error: unnecessary structure name repetition
|
||||
--> $DIR/use_self.rs:243:13
|
||||
--> $DIR/use_self.rs:244:13
|
||||
|
|
||||
LL | TestStruct::from_something()
|
||||
| ^^^^^^^^^^ help: use the applicable keyword: `Self`
|
||||
|
||||
error: unnecessary structure name repetition
|
||||
--> $DIR/use_self.rs:257:25
|
||||
--> $DIR/use_self.rs:258:25
|
||||
|
|
||||
LL | async fn g() -> S {
|
||||
| ^ help: use the applicable keyword: `Self`
|
||||
|
||||
error: unnecessary structure name repetition
|
||||
--> $DIR/use_self.rs:258:13
|
||||
--> $DIR/use_self.rs:259:13
|
||||
|
|
||||
LL | S {}
|
||||
| ^ help: use the applicable keyword: `Self`
|
||||
|
||||
error: unnecessary structure name repetition
|
||||
--> $DIR/use_self.rs:262:16
|
||||
--> $DIR/use_self.rs:263:16
|
||||
|
|
||||
LL | &p[S::A..S::B]
|
||||
| ^ help: use the applicable keyword: `Self`
|
||||
|
||||
error: unnecessary structure name repetition
|
||||
--> $DIR/use_self.rs:262:22
|
||||
--> $DIR/use_self.rs:263:22
|
||||
|
|
||||
LL | &p[S::A..S::B]
|
||||
| ^ help: use the applicable keyword: `Self`
|
||||
|
||||
error: unnecessary structure name repetition
|
||||
--> $DIR/use_self.rs:285:29
|
||||
--> $DIR/use_self.rs:286:29
|
||||
|
|
||||
LL | fn foo(value: T) -> Foo<T> {
|
||||
| ^^^^^^ help: use the applicable keyword: `Self`
|
||||
|
||||
error: unnecessary structure name repetition
|
||||
--> $DIR/use_self.rs:286:13
|
||||
--> $DIR/use_self.rs:287:13
|
||||
|
|
||||
LL | Foo::<T> { value }
|
||||
| ^^^^^^^^ help: use the applicable keyword: `Self`
|
||||
|
||||
error: unnecessary structure name repetition
|
||||
--> $DIR/use_self.rs:458:13
|
||||
--> $DIR/use_self.rs:459:13
|
||||
|
|
||||
LL | A::new::<submod::B>(submod::B {})
|
||||
| ^ help: use the applicable keyword: `Self`
|
||||
|
||||
error: unnecessary structure name repetition
|
||||
--> $DIR/use_self.rs:495:13
|
||||
--> $DIR/use_self.rs:496:13
|
||||
|
|
||||
LL | S2::new()
|
||||
| ^^ help: use the applicable keyword: `Self`
|
||||
|
||||
error: unnecessary structure name repetition
|
||||
--> $DIR/use_self.rs:532:17
|
||||
--> $DIR/use_self.rs:533:17
|
||||
|
|
||||
LL | Foo::Bar => unimplemented!(),
|
||||
| ^^^ help: use the applicable keyword: `Self`
|
||||
|
||||
error: unnecessary structure name repetition
|
||||
--> $DIR/use_self.rs:533:17
|
||||
--> $DIR/use_self.rs:534:17
|
||||
|
|
||||
LL | Foo::Baz => unimplemented!(),
|
||||
| ^^^ help: use the applicable keyword: `Self`
|
||||
|
||||
error: unnecessary structure name repetition
|
||||
--> $DIR/use_self.rs:539:20
|
||||
--> $DIR/use_self.rs:540:20
|
||||
|
|
||||
LL | if let Foo::Bar = self {
|
||||
| ^^^ help: use the applicable keyword: `Self`
|
||||
|
||||
error: unnecessary structure name repetition
|
||||
--> $DIR/use_self.rs:563:17
|
||||
--> $DIR/use_self.rs:564:17
|
||||
|
|
||||
LL | Something::Num(n) => *n,
|
||||
| ^^^^^^^^^ help: use the applicable keyword: `Self`
|
||||
|
||||
error: unnecessary structure name repetition
|
||||
--> $DIR/use_self.rs:564:17
|
||||
--> $DIR/use_self.rs:565:17
|
||||
|
|
||||
LL | Something::TupleNums(n, _m) => *n,
|
||||
| ^^^^^^^^^ help: use the applicable keyword: `Self`
|
||||
|
||||
error: unnecessary structure name repetition
|
||||
--> $DIR/use_self.rs:565:17
|
||||
--> $DIR/use_self.rs:566:17
|
||||
|
|
||||
LL | Something::StructNums { one, two: _ } => *one,
|
||||
| ^^^^^^^^^ help: use the applicable keyword: `Self`
|
||||
|
||||
error: unnecessary structure name repetition
|
||||
--> $DIR/use_self.rs:571:17
|
||||
--> $DIR/use_self.rs:572:17
|
||||
|
|
||||
LL | crate::issue8845::Something::Num(n) => *n,
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the applicable keyword: `Self`
|
||||
|
||||
error: unnecessary structure name repetition
|
||||
--> $DIR/use_self.rs:572:17
|
||||
--> $DIR/use_self.rs:573:17
|
||||
|
|
||||
LL | crate::issue8845::Something::TupleNums(n, _m) => *n,
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the applicable keyword: `Self`
|
||||
|
||||
error: unnecessary structure name repetition
|
||||
--> $DIR/use_self.rs:573:17
|
||||
--> $DIR/use_self.rs:574:17
|
||||
|
|
||||
LL | crate::issue8845::Something::StructNums { one, two: _ } => *one,
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the applicable keyword: `Self`
|
||||
|
||||
error: unnecessary structure name repetition
|
||||
--> $DIR/use_self.rs:589:17
|
||||
--> $DIR/use_self.rs:590:17
|
||||
|
|
||||
LL | let Foo(x) = self;
|
||||
| ^^^ help: use the applicable keyword: `Self`
|
||||
|
||||
error: unnecessary structure name repetition
|
||||
--> $DIR/use_self.rs:594:17
|
||||
--> $DIR/use_self.rs:595:17
|
||||
|
|
||||
LL | let crate::issue8845::Foo(x) = self;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ help: use the applicable keyword: `Self`
|
||||
|
||||
error: unnecessary structure name repetition
|
||||
--> $DIR/use_self.rs:601:17
|
||||
--> $DIR/use_self.rs:602:17
|
||||
|
|
||||
LL | let Bar { x, .. } = self;
|
||||
| ^^^ help: use the applicable keyword: `Self`
|
||||
|
||||
error: unnecessary structure name repetition
|
||||
--> $DIR/use_self.rs:606:17
|
||||
--> $DIR/use_self.rs:607:17
|
||||
|
|
||||
LL | let crate::issue8845::Bar { x, .. } = self;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ help: use the applicable keyword: `Self`
|
||||
|
||||
error: aborting due to 41 previous errors
|
||||
error: unnecessary structure name repetition
|
||||
--> $DIR/use_self.rs:648:17
|
||||
|
|
||||
LL | E::A => {},
|
||||
| ^ help: use the applicable keyword: `Self`
|
||||
|
||||
error: aborting due to 42 previous errors
|
||||
|
||||
|
|
Loading…
Reference in a new issue