mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-12 20:16:49 +00:00
Allow using clippy::msrv
as an outer attribute
This commit is contained in:
parent
030b4b7ad9
commit
461e219d1d
@ -224,7 +224,7 @@ in the `Cargo.toml` can be used.
|
||||
rust-version = "1.30"
|
||||
```
|
||||
|
||||
The MSRV can also be specified as an inner attribute, like below.
|
||||
The MSRV can also be specified as an attribute, like below.
|
||||
|
||||
```rust
|
||||
#![feature(custom_inner_attributes)]
|
||||
|
@ -72,7 +72,7 @@ minimum supported Rust version (MSRV) in the clippy configuration file.
|
||||
msrv = "1.30.0"
|
||||
```
|
||||
|
||||
The MSRV can also be specified as an inner attribute, like below.
|
||||
The MSRV can also be specified as an attribute, like below.
|
||||
|
||||
```rust
|
||||
#![feature(custom_inner_attributes)]
|
||||
|
@ -463,7 +463,7 @@ if !self.msrv.meets(msrvs::STR_STRIP_PREFIX) {
|
||||
}
|
||||
```
|
||||
|
||||
The project's MSRV can also be specified as an inner attribute, which overrides
|
||||
The project's MSRV can also be specified as an attribute, which overrides
|
||||
the value from `clippy.toml`. This can be accounted for using the
|
||||
`extract_msrv_attr!(LintContext)` macro and passing
|
||||
`LateContext`/`EarlyContext`.
|
||||
@ -483,19 +483,15 @@ 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)]
|
||||
|
||||
...
|
||||
|
||||
#[clippy::msrv = "1.44"]
|
||||
fn msrv_1_44() {
|
||||
#![clippy::msrv = "1.44"]
|
||||
|
||||
/* something that would trigger the lint */
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.45"]
|
||||
fn msrv_1_45() {
|
||||
#![clippy::msrv = "1.45"]
|
||||
|
||||
/* something that would trigger the lint */
|
||||
}
|
||||
```
|
||||
|
@ -125,19 +125,19 @@ fn parse_attrs<F: FnMut(u64)>(sess: &Session, attrs: &[ast::Attribute], name: &'
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_unique_inner_attr(sess: &Session, attrs: &[ast::Attribute], name: &'static str) -> Option<ast::Attribute> {
|
||||
let mut unique_attr = None;
|
||||
pub fn get_unique_attr<'a>(
|
||||
sess: &'a Session,
|
||||
attrs: &'a [ast::Attribute],
|
||||
name: &'static str,
|
||||
) -> Option<&'a ast::Attribute> {
|
||||
let mut unique_attr: Option<&ast::Attribute> = None;
|
||||
for attr in get_attr(sess, attrs, name) {
|
||||
match attr.style {
|
||||
ast::AttrStyle::Inner if unique_attr.is_none() => unique_attr = Some(attr.clone()),
|
||||
ast::AttrStyle::Inner => {
|
||||
sess.struct_span_err(attr.span, &format!("`{name}` is defined multiple times"))
|
||||
.span_note(unique_attr.as_ref().unwrap().span, "first definition found here")
|
||||
.emit();
|
||||
},
|
||||
ast::AttrStyle::Outer => {
|
||||
sess.span_err(attr.span, format!("`{name}` cannot be an outer attribute"));
|
||||
},
|
||||
if let Some(duplicate) = unique_attr {
|
||||
sess.struct_span_err(attr.span, &format!("`{name}` is defined multiple times"))
|
||||
.span_note(duplicate.span, "first definition found here")
|
||||
.emit();
|
||||
} else {
|
||||
unique_attr = Some(attr);
|
||||
}
|
||||
}
|
||||
unique_attr
|
||||
|
@ -5,7 +5,7 @@ use rustc_semver::RustcVersion;
|
||||
use rustc_session::Session;
|
||||
use rustc_span::Span;
|
||||
|
||||
use crate::attrs::get_unique_inner_attr;
|
||||
use crate::attrs::get_unique_attr;
|
||||
|
||||
macro_rules! msrv_aliases {
|
||||
($($major:literal,$minor:literal,$patch:literal {
|
||||
@ -118,7 +118,7 @@ impl Msrv {
|
||||
}
|
||||
|
||||
fn parse_attr(sess: &Session, attrs: &[Attribute]) -> Option<RustcVersion> {
|
||||
if let Some(msrv_attr) = get_unique_inner_attr(sess, attrs, "msrv") {
|
||||
if let Some(msrv_attr) = get_unique_attr(sess, attrs, "msrv") {
|
||||
if let Some(msrv) = msrv_attr.value_str() {
|
||||
return parse_msrv(&msrv.to_string(), Some(sess), Some(msrv_attr.span));
|
||||
}
|
||||
|
@ -2,7 +2,6 @@
|
||||
// edition:2018
|
||||
// aux-build:macro_rules.rs
|
||||
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![feature(exclusive_range_pattern)]
|
||||
#![feature(stmt_expr_attributes)]
|
||||
#![warn(clippy::almost_complete_letter_range)]
|
||||
@ -62,16 +61,16 @@ fn main() {
|
||||
b!();
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.25"]
|
||||
fn _under_msrv() {
|
||||
#![clippy::msrv = "1.25"]
|
||||
let _ = match 'a' {
|
||||
'a'...'z' => 1,
|
||||
_ => 2,
|
||||
};
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.26"]
|
||||
fn _meets_msrv() {
|
||||
#![clippy::msrv = "1.26"]
|
||||
let _ = 'a'..='z';
|
||||
let _ = match 'a' {
|
||||
'a'..='z' => 1,
|
||||
|
@ -2,7 +2,6 @@
|
||||
// edition:2018
|
||||
// aux-build:macro_rules.rs
|
||||
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![feature(exclusive_range_pattern)]
|
||||
#![feature(stmt_expr_attributes)]
|
||||
#![warn(clippy::almost_complete_letter_range)]
|
||||
@ -62,16 +61,16 @@ fn main() {
|
||||
b!();
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.25"]
|
||||
fn _under_msrv() {
|
||||
#![clippy::msrv = "1.25"]
|
||||
let _ = match 'a' {
|
||||
'a'..'z' => 1,
|
||||
_ => 2,
|
||||
};
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.26"]
|
||||
fn _meets_msrv() {
|
||||
#![clippy::msrv = "1.26"]
|
||||
let _ = 'a'..'z';
|
||||
let _ = match 'a' {
|
||||
'a'..'z' => 1,
|
||||
|
@ -1,5 +1,5 @@
|
||||
error: almost complete ascii letter range
|
||||
--> $DIR/almost_complete_letter_range.rs:30:17
|
||||
--> $DIR/almost_complete_letter_range.rs:29:17
|
||||
|
|
||||
LL | let _ = ('a') ..'z';
|
||||
| ^^^^^^--^^^
|
||||
@ -9,7 +9,7 @@ LL | let _ = ('a') ..'z';
|
||||
= note: `-D clippy::almost-complete-letter-range` implied by `-D warnings`
|
||||
|
||||
error: almost complete ascii letter range
|
||||
--> $DIR/almost_complete_letter_range.rs:31:17
|
||||
--> $DIR/almost_complete_letter_range.rs:30:17
|
||||
|
|
||||
LL | let _ = 'A' .. ('Z');
|
||||
| ^^^^--^^^^^^
|
||||
@ -17,7 +17,7 @@ LL | let _ = 'A' .. ('Z');
|
||||
| help: use an inclusive range: `..=`
|
||||
|
||||
error: almost complete ascii letter range
|
||||
--> $DIR/almost_complete_letter_range.rs:37:13
|
||||
--> $DIR/almost_complete_letter_range.rs:36:13
|
||||
|
|
||||
LL | let _ = (b'a')..(b'z');
|
||||
| ^^^^^^--^^^^^^
|
||||
@ -25,7 +25,7 @@ LL | let _ = (b'a')..(b'z');
|
||||
| help: use an inclusive range: `..=`
|
||||
|
||||
error: almost complete ascii letter range
|
||||
--> $DIR/almost_complete_letter_range.rs:38:13
|
||||
--> $DIR/almost_complete_letter_range.rs:37:13
|
||||
|
|
||||
LL | let _ = b'A'..b'Z';
|
||||
| ^^^^--^^^^
|
||||
@ -33,7 +33,7 @@ LL | let _ = b'A'..b'Z';
|
||||
| help: use an inclusive range: `..=`
|
||||
|
||||
error: almost complete ascii letter range
|
||||
--> $DIR/almost_complete_letter_range.rs:43:13
|
||||
--> $DIR/almost_complete_letter_range.rs:42:13
|
||||
|
|
||||
LL | let _ = a!()..'z';
|
||||
| ^^^^--^^^
|
||||
@ -41,7 +41,7 @@ LL | let _ = a!()..'z';
|
||||
| help: use an inclusive range: `..=`
|
||||
|
||||
error: almost complete ascii letter range
|
||||
--> $DIR/almost_complete_letter_range.rs:46:9
|
||||
--> $DIR/almost_complete_letter_range.rs:45:9
|
||||
|
|
||||
LL | b'a'..b'z' if true => 1,
|
||||
| ^^^^--^^^^
|
||||
@ -49,7 +49,7 @@ LL | b'a'..b'z' if true => 1,
|
||||
| help: use an inclusive range: `..=`
|
||||
|
||||
error: almost complete ascii letter range
|
||||
--> $DIR/almost_complete_letter_range.rs:47:9
|
||||
--> $DIR/almost_complete_letter_range.rs:46:9
|
||||
|
|
||||
LL | b'A'..b'Z' if true => 2,
|
||||
| ^^^^--^^^^
|
||||
@ -57,7 +57,7 @@ LL | b'A'..b'Z' if true => 2,
|
||||
| help: use an inclusive range: `..=`
|
||||
|
||||
error: almost complete ascii letter range
|
||||
--> $DIR/almost_complete_letter_range.rs:54:9
|
||||
--> $DIR/almost_complete_letter_range.rs:53:9
|
||||
|
|
||||
LL | 'a'..'z' if true => 1,
|
||||
| ^^^--^^^
|
||||
@ -65,7 +65,7 @@ LL | 'a'..'z' if true => 1,
|
||||
| help: use an inclusive range: `..=`
|
||||
|
||||
error: almost complete ascii letter range
|
||||
--> $DIR/almost_complete_letter_range.rs:55:9
|
||||
--> $DIR/almost_complete_letter_range.rs:54:9
|
||||
|
|
||||
LL | 'A'..'Z' if true => 2,
|
||||
| ^^^--^^^
|
||||
@ -73,7 +73,7 @@ LL | 'A'..'Z' if true => 2,
|
||||
| help: use an inclusive range: `..=`
|
||||
|
||||
error: almost complete ascii letter range
|
||||
--> $DIR/almost_complete_letter_range.rs:23:17
|
||||
--> $DIR/almost_complete_letter_range.rs:22:17
|
||||
|
|
||||
LL | let _ = 'a'..'z';
|
||||
| ^^^--^^^
|
||||
@ -86,7 +86,7 @@ LL | b!();
|
||||
= note: this error originates in the macro `b` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: almost complete ascii letter range
|
||||
--> $DIR/almost_complete_letter_range.rs:68:9
|
||||
--> $DIR/almost_complete_letter_range.rs:67:9
|
||||
|
|
||||
LL | 'a'..'z' => 1,
|
||||
| ^^^--^^^
|
||||
@ -94,7 +94,7 @@ LL | 'a'..'z' => 1,
|
||||
| help: use an inclusive range: `...`
|
||||
|
||||
error: almost complete ascii letter range
|
||||
--> $DIR/almost_complete_letter_range.rs:75:13
|
||||
--> $DIR/almost_complete_letter_range.rs:74:13
|
||||
|
|
||||
LL | let _ = 'a'..'z';
|
||||
| ^^^--^^^
|
||||
@ -102,7 +102,7 @@ LL | let _ = 'a'..'z';
|
||||
| help: use an inclusive range: `..=`
|
||||
|
||||
error: almost complete ascii letter range
|
||||
--> $DIR/almost_complete_letter_range.rs:77:9
|
||||
--> $DIR/almost_complete_letter_range.rs:76:9
|
||||
|
|
||||
LL | 'a'..'z' => 1,
|
||||
| ^^^--^^^
|
||||
|
@ -1,6 +1,5 @@
|
||||
// run-rustfix
|
||||
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![warn(clippy::cast_abs_to_unsigned)]
|
||||
#![allow(clippy::uninlined_format_args, unused)]
|
||||
|
||||
@ -33,16 +32,14 @@ fn main() {
|
||||
let _ = (x as i64 - y as i64).unsigned_abs() as u32;
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.50"]
|
||||
fn msrv_1_50() {
|
||||
#![clippy::msrv = "1.50"]
|
||||
|
||||
let x: i32 = 10;
|
||||
assert_eq!(10u32, x.abs() as u32);
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.51"]
|
||||
fn msrv_1_51() {
|
||||
#![clippy::msrv = "1.51"]
|
||||
|
||||
let x: i32 = 10;
|
||||
assert_eq!(10u32, x.unsigned_abs());
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
// run-rustfix
|
||||
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![warn(clippy::cast_abs_to_unsigned)]
|
||||
#![allow(clippy::uninlined_format_args, unused)]
|
||||
|
||||
@ -33,16 +32,14 @@ fn main() {
|
||||
let _ = (x as i64 - y as i64).abs() as u32;
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.50"]
|
||||
fn msrv_1_50() {
|
||||
#![clippy::msrv = "1.50"]
|
||||
|
||||
let x: i32 = 10;
|
||||
assert_eq!(10u32, x.abs() as u32);
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.51"]
|
||||
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:9:18
|
||||
--> $DIR/cast_abs_to_unsigned.rs:8:18
|
||||
|
|
||||
LL | let y: u32 = x.abs() as u32;
|
||||
| ^^^^^^^^^^^^^^ help: replace with: `x.unsigned_abs()`
|
||||
@ -7,103 +7,103 @@ 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:13:20
|
||||
--> $DIR/cast_abs_to_unsigned.rs:12: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:14:20
|
||||
--> $DIR/cast_abs_to_unsigned.rs:13: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:15:13
|
||||
--> $DIR/cast_abs_to_unsigned.rs:14: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:18:13
|
||||
--> $DIR/cast_abs_to_unsigned.rs:17: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:19:13
|
||||
--> $DIR/cast_abs_to_unsigned.rs:18: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:20:13
|
||||
--> $DIR/cast_abs_to_unsigned.rs:19: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:21:13
|
||||
--> $DIR/cast_abs_to_unsigned.rs:20: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:22:13
|
||||
--> $DIR/cast_abs_to_unsigned.rs:21: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:23:13
|
||||
--> $DIR/cast_abs_to_unsigned.rs:22: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:26:13
|
||||
--> $DIR/cast_abs_to_unsigned.rs:25: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:27:13
|
||||
--> $DIR/cast_abs_to_unsigned.rs:26: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:28:13
|
||||
--> $DIR/cast_abs_to_unsigned.rs:27: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:29:13
|
||||
--> $DIR/cast_abs_to_unsigned.rs:28: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:30:13
|
||||
--> $DIR/cast_abs_to_unsigned.rs:29: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:31:13
|
||||
--> $DIR/cast_abs_to_unsigned.rs:30: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:33:13
|
||||
--> $DIR/cast_abs_to_unsigned.rs:32:13
|
||||
|
|
||||
LL | let _ = (x as i64 - y as i64).abs() as u32;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `(x as i64 - y as i64).unsigned_abs()`
|
||||
|
||||
error: casting the result of `i32::abs()` to u32
|
||||
--> $DIR/cast_abs_to_unsigned.rs:47:23
|
||||
--> $DIR/cast_abs_to_unsigned.rs:44:23
|
||||
|
|
||||
LL | assert_eq!(10u32, x.abs() as u32);
|
||||
| ^^^^^^^^^^^^^^ help: replace with: `x.unsigned_abs()`
|
||||
|
@ -1,6 +1,5 @@
|
||||
// run-rustfix
|
||||
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![allow(dead_code)]
|
||||
#![warn(clippy::cast_lossless)]
|
||||
|
||||
@ -42,14 +41,12 @@ mod cast_lossless_in_impl {
|
||||
}
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.27"]
|
||||
fn msrv_1_27() {
|
||||
#![clippy::msrv = "1.27"]
|
||||
|
||||
let _ = true as u8;
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.28"]
|
||||
fn msrv_1_28() {
|
||||
#![clippy::msrv = "1.28"]
|
||||
|
||||
let _ = u8::from(true);
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
// run-rustfix
|
||||
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![allow(dead_code)]
|
||||
#![warn(clippy::cast_lossless)]
|
||||
|
||||
@ -42,14 +41,12 @@ mod cast_lossless_in_impl {
|
||||
}
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.27"]
|
||||
fn msrv_1_27() {
|
||||
#![clippy::msrv = "1.27"]
|
||||
|
||||
let _ = true as u8;
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.28"]
|
||||
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:9:13
|
||||
--> $DIR/cast_lossless_bool.rs:8:13
|
||||
|
|
||||
LL | let _ = true as u8;
|
||||
| ^^^^^^^^^^ help: try: `u8::from(true)`
|
||||
@ -7,79 +7,79 @@ 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:10:13
|
||||
--> $DIR/cast_lossless_bool.rs:9: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:11:13
|
||||
--> $DIR/cast_lossless_bool.rs:10: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:12:13
|
||||
--> $DIR/cast_lossless_bool.rs:11: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:13:13
|
||||
--> $DIR/cast_lossless_bool.rs:12: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:14:13
|
||||
--> $DIR/cast_lossless_bool.rs:13: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:16:13
|
||||
--> $DIR/cast_lossless_bool.rs:15: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:17:13
|
||||
--> $DIR/cast_lossless_bool.rs:16: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:18:13
|
||||
--> $DIR/cast_lossless_bool.rs:17: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:19:13
|
||||
--> $DIR/cast_lossless_bool.rs:18: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:20:13
|
||||
--> $DIR/cast_lossless_bool.rs:19: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:21:13
|
||||
--> $DIR/cast_lossless_bool.rs:20: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:24:13
|
||||
--> $DIR/cast_lossless_bool.rs:23:13
|
||||
|
|
||||
LL | let _ = (true | false) as u16;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ help: try: `u16::from(true | false)`
|
||||
|
||||
error: casting `bool` to `u8` is more cleanly stated with `u8::from(_)`
|
||||
--> $DIR/cast_lossless_bool.rs:54:13
|
||||
--> $DIR/cast_lossless_bool.rs:51:13
|
||||
|
|
||||
LL | let _ = true as u8;
|
||||
| ^^^^^^^^^^ help: try: `u8::from(true)`
|
||||
|
@ -1,5 +1,5 @@
|
||||
// run-rustfix
|
||||
#![feature(stmt_expr_attributes, custom_inner_attributes)]
|
||||
#![feature(stmt_expr_attributes)]
|
||||
|
||||
#![allow(unused, clippy::no_effect, clippy::unnecessary_operation)]
|
||||
#![warn(clippy::deprecated_cfg_attr)]
|
||||
@ -30,16 +30,14 @@ mod foo {
|
||||
pub fn f() {}
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.29"]
|
||||
fn msrv_1_29() {
|
||||
#![clippy::msrv = "1.29"]
|
||||
|
||||
#[cfg_attr(rustfmt, rustfmt::skip)]
|
||||
1+29;
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.30"]
|
||||
fn msrv_1_30() {
|
||||
#![clippy::msrv = "1.30"]
|
||||
|
||||
#[rustfmt::skip]
|
||||
1+30;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
// run-rustfix
|
||||
#![feature(stmt_expr_attributes, custom_inner_attributes)]
|
||||
#![feature(stmt_expr_attributes)]
|
||||
|
||||
#![allow(unused, clippy::no_effect, clippy::unnecessary_operation)]
|
||||
#![warn(clippy::deprecated_cfg_attr)]
|
||||
@ -30,16 +30,14 @@ mod foo {
|
||||
pub fn f() {}
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.29"]
|
||||
fn msrv_1_29() {
|
||||
#![clippy::msrv = "1.29"]
|
||||
|
||||
#[cfg_attr(rustfmt, rustfmt::skip)]
|
||||
1+29;
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.30"]
|
||||
fn msrv_1_30() {
|
||||
#![clippy::msrv = "1.30"]
|
||||
|
||||
#[cfg_attr(rustfmt, rustfmt::skip)]
|
||||
1+30;
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ LL | #[cfg_attr(rustfmt, rustfmt_skip)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `#[rustfmt::skip]`
|
||||
|
||||
error: `cfg_attr` is deprecated for rustfmt and got replaced by tool attributes
|
||||
--> $DIR/cfg_attr_rustfmt.rs:43:5
|
||||
--> $DIR/cfg_attr_rustfmt.rs:41:5
|
||||
|
|
||||
LL | #[cfg_attr(rustfmt, rustfmt::skip)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `#[rustfmt::skip]`
|
||||
|
@ -1,6 +1,5 @@
|
||||
// run-rustfix
|
||||
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![allow(
|
||||
clippy::cast_lossless,
|
||||
unused,
|
||||
@ -78,16 +77,14 @@ pub const fn issue_8898(i: u32) -> bool {
|
||||
i <= i32::MAX as u32
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.33"]
|
||||
fn msrv_1_33() {
|
||||
#![clippy::msrv = "1.33"]
|
||||
|
||||
let value: i64 = 33;
|
||||
let _ = value <= (u32::MAX as i64) && value >= 0;
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.34"]
|
||||
fn msrv_1_34() {
|
||||
#![clippy::msrv = "1.34"]
|
||||
|
||||
let value: i64 = 34;
|
||||
let _ = u32::try_from(value).is_ok();
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
// run-rustfix
|
||||
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![allow(
|
||||
clippy::cast_lossless,
|
||||
unused,
|
||||
@ -78,16 +77,14 @@ pub const fn issue_8898(i: u32) -> bool {
|
||||
i <= i32::MAX as u32
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.33"]
|
||||
fn msrv_1_33() {
|
||||
#![clippy::msrv = "1.33"]
|
||||
|
||||
let value: i64 = 33;
|
||||
let _ = value <= (u32::MAX as i64) && value >= 0;
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.34"]
|
||||
fn msrv_1_34() {
|
||||
#![clippy::msrv = "1.34"]
|
||||
|
||||
let value: i64 = 34;
|
||||
let _ = value <= (u32::MAX as i64) && value >= 0;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
error: checked cast can be simplified
|
||||
--> $DIR/checked_conversions.rs:17:13
|
||||
--> $DIR/checked_conversions.rs:16:13
|
||||
|
|
||||
LL | let _ = value <= (u32::max_value() as i64) && value >= 0;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `u32::try_from(value).is_ok()`
|
||||
@ -7,97 +7,97 @@ 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:18:13
|
||||
--> $DIR/checked_conversions.rs:17: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:22:13
|
||||
--> $DIR/checked_conversions.rs:21: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:23:13
|
||||
--> $DIR/checked_conversions.rs:22: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:27:13
|
||||
--> $DIR/checked_conversions.rs:26: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:28:13
|
||||
--> $DIR/checked_conversions.rs:27: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:34:13
|
||||
--> $DIR/checked_conversions.rs:33: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:35:13
|
||||
--> $DIR/checked_conversions.rs:34: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:39:13
|
||||
--> $DIR/checked_conversions.rs:38: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:40:13
|
||||
--> $DIR/checked_conversions.rs:39: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:46:13
|
||||
--> $DIR/checked_conversions.rs:45: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:47:13
|
||||
--> $DIR/checked_conversions.rs:46: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:51:13
|
||||
--> $DIR/checked_conversions.rs:50: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:52:13
|
||||
--> $DIR/checked_conversions.rs:51: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:56:13
|
||||
--> $DIR/checked_conversions.rs:55: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:57:13
|
||||
--> $DIR/checked_conversions.rs:56:13
|
||||
|
|
||||
LL | let _ = value <= u16::MAX as u32 && value as i32 == 5;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `u16::try_from(value).is_ok()`
|
||||
|
||||
error: checked cast can be simplified
|
||||
--> $DIR/checked_conversions.rs:92:13
|
||||
--> $DIR/checked_conversions.rs:89:13
|
||||
|
|
||||
LL | let _ = value <= (u32::MAX as i64) && value >= 0;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `u32::try_from(value).is_ok()`
|
||||
|
@ -1,6 +1,5 @@
|
||||
// run-rustfix
|
||||
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![warn(clippy::cloned_instead_of_copied)]
|
||||
#![allow(unused)]
|
||||
|
||||
@ -17,23 +16,20 @@ fn main() {
|
||||
let _ = Some(&String::new()).cloned();
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.34"]
|
||||
fn msrv_1_34() {
|
||||
#![clippy::msrv = "1.34"]
|
||||
|
||||
let _ = [1].iter().cloned();
|
||||
let _ = Some(&1).cloned();
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.35"]
|
||||
fn msrv_1_35() {
|
||||
#![clippy::msrv = "1.35"]
|
||||
|
||||
let _ = [1].iter().cloned();
|
||||
let _ = Some(&1).copied(); // Option::copied needs 1.35
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.36"]
|
||||
fn msrv_1_36() {
|
||||
#![clippy::msrv = "1.36"]
|
||||
|
||||
let _ = [1].iter().copied(); // Iterator::copied needs 1.36
|
||||
let _ = Some(&1).copied();
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
// run-rustfix
|
||||
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![warn(clippy::cloned_instead_of_copied)]
|
||||
#![allow(unused)]
|
||||
|
||||
@ -17,23 +16,20 @@ fn main() {
|
||||
let _ = Some(&String::new()).cloned();
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.34"]
|
||||
fn msrv_1_34() {
|
||||
#![clippy::msrv = "1.34"]
|
||||
|
||||
let _ = [1].iter().cloned();
|
||||
let _ = Some(&1).cloned();
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.35"]
|
||||
fn msrv_1_35() {
|
||||
#![clippy::msrv = "1.35"]
|
||||
|
||||
let _ = [1].iter().cloned();
|
||||
let _ = Some(&1).cloned(); // Option::copied needs 1.35
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.36"]
|
||||
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:9:24
|
||||
--> $DIR/cloned_instead_of_copied.rs:8:24
|
||||
|
|
||||
LL | let _ = [1].iter().cloned();
|
||||
| ^^^^^^ help: try: `copied`
|
||||
@ -7,43 +7,43 @@ 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:10:31
|
||||
--> $DIR/cloned_instead_of_copied.rs:9: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:11:22
|
||||
--> $DIR/cloned_instead_of_copied.rs:10:22
|
||||
|
|
||||
LL | let _ = Some(&1).cloned();
|
||||
| ^^^^^^ help: try: `copied`
|
||||
|
||||
error: used `cloned` where `copied` could be used instead
|
||||
--> $DIR/cloned_instead_of_copied.rs:12:34
|
||||
--> $DIR/cloned_instead_of_copied.rs:11: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:13:32
|
||||
--> $DIR/cloned_instead_of_copied.rs:12:32
|
||||
|
|
||||
LL | let _ = Box::new(Some(&1)).cloned();
|
||||
| ^^^^^^ help: try: `copied`
|
||||
|
||||
error: used `cloned` where `copied` could be used instead
|
||||
--> $DIR/cloned_instead_of_copied.rs:31:22
|
||||
--> $DIR/cloned_instead_of_copied.rs:28: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
|
||||
--> $DIR/cloned_instead_of_copied.rs:33: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
|
||||
--> $DIR/cloned_instead_of_copied.rs:34:22
|
||||
|
|
||||
LL | let _ = Some(&1).cloned();
|
||||
| ^^^^^^ help: try: `copied`
|
||||
|
@ -1,6 +1,5 @@
|
||||
// run-rustfix
|
||||
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![allow(unused)]
|
||||
|
||||
struct MyTypeNonDebug;
|
||||
@ -16,16 +15,14 @@ fn main() {
|
||||
test_non_debug.err().expect("Testing non debug type");
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.16"]
|
||||
fn msrv_1_16() {
|
||||
#![clippy::msrv = "1.16"]
|
||||
|
||||
let x: Result<u32, &str> = Ok(16);
|
||||
x.err().expect("16");
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.17"]
|
||||
fn msrv_1_17() {
|
||||
#![clippy::msrv = "1.17"]
|
||||
|
||||
let x: Result<u32, &str> = Ok(17);
|
||||
x.expect_err("17");
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
// run-rustfix
|
||||
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![allow(unused)]
|
||||
|
||||
struct MyTypeNonDebug;
|
||||
@ -16,16 +15,14 @@ fn main() {
|
||||
test_non_debug.err().expect("Testing non debug type");
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.16"]
|
||||
fn msrv_1_16() {
|
||||
#![clippy::msrv = "1.16"]
|
||||
|
||||
let x: Result<u32, &str> = Ok(16);
|
||||
x.err().expect("16");
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.17"]
|
||||
fn msrv_1_17() {
|
||||
#![clippy::msrv = "1.17"]
|
||||
|
||||
let x: Result<u32, &str> = Ok(17);
|
||||
x.err().expect("17");
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
error: called `.err().expect()` on a `Result` value
|
||||
--> $DIR/err_expect.rs:13:16
|
||||
--> $DIR/err_expect.rs:12:16
|
||||
|
|
||||
LL | test_debug.err().expect("Testing debug type");
|
||||
| ^^^^^^^^^^^^ help: try: `expect_err`
|
||||
@ -7,7 +7,7 @@ LL | test_debug.err().expect("Testing debug type");
|
||||
= note: `-D clippy::err-expect` implied by `-D warnings`
|
||||
|
||||
error: called `.err().expect()` on a `Result` value
|
||||
--> $DIR/err_expect.rs:30:7
|
||||
--> $DIR/err_expect.rs:27:7
|
||||
|
|
||||
LL | x.err().expect("17");
|
||||
| ^^^^^^^^^^^^ help: try: `expect_err`
|
||||
|
@ -1,6 +1,5 @@
|
||||
// run-rustfix
|
||||
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![warn(clippy::all, clippy::pedantic)]
|
||||
#![allow(unused)]
|
||||
|
||||
@ -11,16 +10,14 @@ fn main() {
|
||||
assert_eq!(element, Some(1));
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.29"]
|
||||
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();
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.30"]
|
||||
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,5 @@
|
||||
// run-rustfix
|
||||
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![warn(clippy::all, clippy::pedantic)]
|
||||
#![allow(unused)]
|
||||
|
||||
@ -11,16 +10,14 @@ fn main() {
|
||||
assert_eq!(element, Some(1));
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.29"]
|
||||
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();
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.30"]
|
||||
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,5 +1,5 @@
|
||||
error: called `filter_map(..).next()` on an `Iterator`. This is more succinctly expressed by calling `.find_map(..)` instead
|
||||
--> $DIR/filter_map_next_fixable.rs:10:32
|
||||
--> $DIR/filter_map_next_fixable.rs:9: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())`
|
||||
@ -7,7 +7,7 @@ LL | let element: Option<i32> = a.iter().filter_map(|s| s.parse().ok()).next
|
||||
= note: `-D clippy::filter-map-next` implied by `-D warnings`
|
||||
|
||||
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
|
||||
--> $DIR/filter_map_next_fixable.rs:22: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())`
|
||||
|
@ -1,6 +1,5 @@
|
||||
// run-rustfix
|
||||
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![warn(clippy::from_over_into)]
|
||||
#![allow(unused)]
|
||||
|
||||
@ -60,9 +59,8 @@ impl From<String> for A {
|
||||
}
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.40"]
|
||||
fn msrv_1_40() {
|
||||
#![clippy::msrv = "1.40"]
|
||||
|
||||
struct FromOverInto<T>(Vec<T>);
|
||||
|
||||
impl<T> Into<FromOverInto<T>> for Vec<T> {
|
||||
@ -72,9 +70,8 @@ fn msrv_1_40() {
|
||||
}
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.41"]
|
||||
fn msrv_1_41() {
|
||||
#![clippy::msrv = "1.41"]
|
||||
|
||||
struct FromOverInto<T>(Vec<T>);
|
||||
|
||||
impl<T> From<Vec<T>> for FromOverInto<T> {
|
||||
|
@ -1,6 +1,5 @@
|
||||
// run-rustfix
|
||||
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![warn(clippy::from_over_into)]
|
||||
#![allow(unused)]
|
||||
|
||||
@ -60,9 +59,8 @@ impl From<String> for A {
|
||||
}
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.40"]
|
||||
fn msrv_1_40() {
|
||||
#![clippy::msrv = "1.40"]
|
||||
|
||||
struct FromOverInto<T>(Vec<T>);
|
||||
|
||||
impl<T> Into<FromOverInto<T>> for Vec<T> {
|
||||
@ -72,9 +70,8 @@ fn msrv_1_40() {
|
||||
}
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.41"]
|
||||
fn msrv_1_41() {
|
||||
#![clippy::msrv = "1.41"]
|
||||
|
||||
struct FromOverInto<T>(Vec<T>);
|
||||
|
||||
impl<T> Into<FromOverInto<T>> for Vec<T> {
|
||||
|
@ -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:10:1
|
||||
--> $DIR/from_over_into.rs:9: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:18:1
|
||||
--> $DIR/from_over_into.rs:17: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:33:1
|
||||
--> $DIR/from_over_into.rs:32: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:45:1
|
||||
--> $DIR/from_over_into.rs:44:1
|
||||
|
|
||||
LL | impl core::convert::Into<bool> for crate::ExplicitPaths {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
@ -59,7 +59,7 @@ LL ~ val.0
|
||||
|
|
||||
|
||||
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
|
||||
--> $DIR/from_over_into.rs:77:5
|
||||
|
|
||||
LL | impl<T> Into<FromOverInto<T>> for Vec<T> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -1,5 +1,4 @@
|
||||
#![warn(clippy::if_then_some_else_none)]
|
||||
#![feature(custom_inner_attributes)]
|
||||
|
||||
fn main() {
|
||||
// Should issue an error.
|
||||
@ -66,8 +65,8 @@ fn main() {
|
||||
let _ = if foo() { into_some("foo") } else { None };
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.49"]
|
||||
fn _msrv_1_49() {
|
||||
#![clippy::msrv = "1.49"]
|
||||
// `bool::then` was stabilized in 1.50. Do not lint this
|
||||
let _ = if foo() {
|
||||
println!("true!");
|
||||
@ -77,8 +76,8 @@ fn _msrv_1_49() {
|
||||
};
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.50"]
|
||||
fn _msrv_1_50() {
|
||||
#![clippy::msrv = "1.50"]
|
||||
let _ = if foo() {
|
||||
println!("true!");
|
||||
Some(150)
|
||||
|
@ -1,5 +1,5 @@
|
||||
error: this could be simplified with `bool::then`
|
||||
--> $DIR/if_then_some_else_none.rs:6:13
|
||||
--> $DIR/if_then_some_else_none.rs:5:13
|
||||
|
|
||||
LL | let _ = if foo() {
|
||||
| _____________^
|
||||
@ -14,7 +14,7 @@ LL | | };
|
||||
= note: `-D clippy::if-then-some-else-none` implied by `-D warnings`
|
||||
|
||||
error: this could be simplified with `bool::then`
|
||||
--> $DIR/if_then_some_else_none.rs:14:13
|
||||
--> $DIR/if_then_some_else_none.rs:13:13
|
||||
|
|
||||
LL | let _ = if matches!(true, true) {
|
||||
| _____________^
|
||||
@ -28,7 +28,7 @@ LL | | };
|
||||
= help: consider using `bool::then` like: `matches!(true, true).then(|| { /* snippet */ matches!(true, false) })`
|
||||
|
||||
error: this could be simplified with `bool::then_some`
|
||||
--> $DIR/if_then_some_else_none.rs:23:28
|
||||
--> $DIR/if_then_some_else_none.rs:22:28
|
||||
|
|
||||
LL | let _ = x.and_then(|o| if o < 32 { Some(o) } else { None });
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
@ -36,7 +36,7 @@ LL | let _ = x.and_then(|o| if o < 32 { Some(o) } else { None });
|
||||
= help: consider using `bool::then_some` like: `(o < 32).then_some(o)`
|
||||
|
||||
error: this could be simplified with `bool::then_some`
|
||||
--> $DIR/if_then_some_else_none.rs:27:13
|
||||
--> $DIR/if_then_some_else_none.rs:26:13
|
||||
|
|
||||
LL | let _ = if !x { Some(0) } else { None };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
@ -44,7 +44,7 @@ LL | let _ = if !x { Some(0) } else { None };
|
||||
= help: consider using `bool::then_some` like: `(!x).then_some(0)`
|
||||
|
||||
error: this could be simplified with `bool::then`
|
||||
--> $DIR/if_then_some_else_none.rs:82:13
|
||||
--> $DIR/if_then_some_else_none.rs:81:13
|
||||
|
|
||||
LL | let _ = if foo() {
|
||||
| _____________^
|
||||
|
@ -1,4 +1,3 @@
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![warn(clippy::manual_clamp)]
|
||||
#![allow(
|
||||
unused,
|
||||
@ -304,9 +303,8 @@ fn cmp_min_max(input: i32) -> i32 {
|
||||
input * 3
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.49"]
|
||||
fn msrv_1_49() {
|
||||
#![clippy::msrv = "1.49"]
|
||||
|
||||
let (input, min, max) = (0, -1, 2);
|
||||
let _ = if input < min {
|
||||
min
|
||||
@ -317,9 +315,8 @@ fn msrv_1_49() {
|
||||
};
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.50"]
|
||||
fn msrv_1_50() {
|
||||
#![clippy::msrv = "1.50"]
|
||||
|
||||
let (input, min, max) = (0, -1, 2);
|
||||
let _ = if input < min {
|
||||
min
|
||||
|
@ -1,5 +1,5 @@
|
||||
error: clamp-like pattern without using clamp function
|
||||
--> $DIR/manual_clamp.rs:77:5
|
||||
--> $DIR/manual_clamp.rs:76: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:92:5
|
||||
--> $DIR/manual_clamp.rs:91: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:100:5
|
||||
--> $DIR/manual_clamp.rs:99: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:108:5
|
||||
--> $DIR/manual_clamp.rs:107: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:162:5
|
||||
--> $DIR/manual_clamp.rs:161: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:22:14
|
||||
--> $DIR/manual_clamp.rs:21: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:30:14
|
||||
--> $DIR/manual_clamp.rs:29: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:38:14
|
||||
--> $DIR/manual_clamp.rs:37: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:46:14
|
||||
--> $DIR/manual_clamp.rs:45: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:54:14
|
||||
--> $DIR/manual_clamp.rs:53: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:56:14
|
||||
--> $DIR/manual_clamp.rs:55: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:58:14
|
||||
--> $DIR/manual_clamp.rs:57: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:64:14
|
||||
--> $DIR/manual_clamp.rs:63: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:70:14
|
||||
--> $DIR/manual_clamp.rs:69: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:84:15
|
||||
--> $DIR/manual_clamp.rs:83: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:115:15
|
||||
--> $DIR/manual_clamp.rs:114: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:124:19
|
||||
--> $DIR/manual_clamp.rs:123: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:135:19
|
||||
--> $DIR/manual_clamp.rs:134: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:136:19
|
||||
--> $DIR/manual_clamp.rs:135: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:137:19
|
||||
--> $DIR/manual_clamp.rs:136: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:138:19
|
||||
--> $DIR/manual_clamp.rs:137: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:139:19
|
||||
--> $DIR/manual_clamp.rs:138: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:140:19
|
||||
--> $DIR/manual_clamp.rs:139: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:141:19
|
||||
--> $DIR/manual_clamp.rs:140: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:142:19
|
||||
--> $DIR/manual_clamp.rs:141: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:144:19
|
||||
--> $DIR/manual_clamp.rs:143: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:145:19
|
||||
--> $DIR/manual_clamp.rs:144: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:146:19
|
||||
--> $DIR/manual_clamp.rs:145: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:147:19
|
||||
--> $DIR/manual_clamp.rs:146: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:148:19
|
||||
--> $DIR/manual_clamp.rs:147: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:149:19
|
||||
--> $DIR/manual_clamp.rs:148: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:150:19
|
||||
--> $DIR/manual_clamp.rs:149: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:151:19
|
||||
--> $DIR/manual_clamp.rs:150: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:154:5
|
||||
--> $DIR/manual_clamp.rs:153:5
|
||||
|
|
||||
LL | / if x32 < min {
|
||||
LL | | x32 = min;
|
||||
@ -372,7 +372,7 @@ LL | | }
|
||||
= note: clamp will panic if max < min
|
||||
|
||||
error: clamp-like pattern without using clamp function
|
||||
--> $DIR/manual_clamp.rs:324:13
|
||||
--> $DIR/manual_clamp.rs:321:13
|
||||
|
|
||||
LL | let _ = if input < min {
|
||||
| _____________^
|
||||
|
@ -1,6 +1,5 @@
|
||||
// run-rustfix
|
||||
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![allow(unused, dead_code)]
|
||||
#![warn(clippy::manual_is_ascii_check)]
|
||||
|
||||
@ -18,28 +17,26 @@ fn main() {
|
||||
assert!(matches!('x', 'A'..='Z' | 'a'..='z' | '_'));
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.23"]
|
||||
fn msrv_1_23() {
|
||||
#![clippy::msrv = "1.23"]
|
||||
|
||||
assert!(matches!(b'1', b'0'..=b'9'));
|
||||
assert!(matches!('X', 'A'..='Z'));
|
||||
assert!(matches!('x', 'A'..='Z' | 'a'..='z'));
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.24"]
|
||||
fn msrv_1_24() {
|
||||
#![clippy::msrv = "1.24"]
|
||||
|
||||
assert!(b'1'.is_ascii_digit());
|
||||
assert!('X'.is_ascii_uppercase());
|
||||
assert!('x'.is_ascii_alphabetic());
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.46"]
|
||||
fn msrv_1_46() {
|
||||
#![clippy::msrv = "1.46"]
|
||||
const FOO: bool = matches!('x', '0'..='9');
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.47"]
|
||||
fn msrv_1_47() {
|
||||
#![clippy::msrv = "1.47"]
|
||||
const FOO: bool = 'x'.is_ascii_digit();
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
// run-rustfix
|
||||
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![allow(unused, dead_code)]
|
||||
#![warn(clippy::manual_is_ascii_check)]
|
||||
|
||||
@ -18,28 +17,26 @@ fn main() {
|
||||
assert!(matches!('x', 'A'..='Z' | 'a'..='z' | '_'));
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.23"]
|
||||
fn msrv_1_23() {
|
||||
#![clippy::msrv = "1.23"]
|
||||
|
||||
assert!(matches!(b'1', b'0'..=b'9'));
|
||||
assert!(matches!('X', 'A'..='Z'));
|
||||
assert!(matches!('x', 'A'..='Z' | 'a'..='z'));
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.24"]
|
||||
fn msrv_1_24() {
|
||||
#![clippy::msrv = "1.24"]
|
||||
|
||||
assert!(matches!(b'1', b'0'..=b'9'));
|
||||
assert!(matches!('X', 'A'..='Z'));
|
||||
assert!(matches!('x', 'A'..='Z' | 'a'..='z'));
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.46"]
|
||||
fn msrv_1_46() {
|
||||
#![clippy::msrv = "1.46"]
|
||||
const FOO: bool = matches!('x', '0'..='9');
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.47"]
|
||||
fn msrv_1_47() {
|
||||
#![clippy::msrv = "1.47"]
|
||||
const FOO: bool = matches!('x', '0'..='9');
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
error: manual check for common ascii range
|
||||
--> $DIR/manual_is_ascii_check.rs:8:13
|
||||
--> $DIR/manual_is_ascii_check.rs:7:13
|
||||
|
|
||||
LL | assert!(matches!('x', 'a'..='z'));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `'x'.is_ascii_lowercase()`
|
||||
@ -7,61 +7,61 @@ LL | assert!(matches!('x', 'a'..='z'));
|
||||
= note: `-D clippy::manual-is-ascii-check` implied by `-D warnings`
|
||||
|
||||
error: manual check for common ascii range
|
||||
--> $DIR/manual_is_ascii_check.rs:9:13
|
||||
--> $DIR/manual_is_ascii_check.rs:8:13
|
||||
|
|
||||
LL | assert!(matches!('X', 'A'..='Z'));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `'X'.is_ascii_uppercase()`
|
||||
|
||||
error: manual check for common ascii range
|
||||
--> $DIR/manual_is_ascii_check.rs:10:13
|
||||
--> $DIR/manual_is_ascii_check.rs:9:13
|
||||
|
|
||||
LL | assert!(matches!(b'x', b'a'..=b'z'));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `b'x'.is_ascii_lowercase()`
|
||||
|
||||
error: manual check for common ascii range
|
||||
--> $DIR/manual_is_ascii_check.rs:11:13
|
||||
--> $DIR/manual_is_ascii_check.rs:10:13
|
||||
|
|
||||
LL | assert!(matches!(b'X', b'A'..=b'Z'));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `b'X'.is_ascii_uppercase()`
|
||||
|
||||
error: manual check for common ascii range
|
||||
--> $DIR/manual_is_ascii_check.rs:14:13
|
||||
--> $DIR/manual_is_ascii_check.rs:13:13
|
||||
|
|
||||
LL | assert!(matches!(num, '0'..='9'));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `num.is_ascii_digit()`
|
||||
|
||||
error: manual check for common ascii range
|
||||
--> $DIR/manual_is_ascii_check.rs:15:13
|
||||
--> $DIR/manual_is_ascii_check.rs:14:13
|
||||
|
|
||||
LL | assert!(matches!(b'1', b'0'..=b'9'));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `b'1'.is_ascii_digit()`
|
||||
|
||||
error: manual check for common ascii range
|
||||
--> $DIR/manual_is_ascii_check.rs:16:13
|
||||
--> $DIR/manual_is_ascii_check.rs:15:13
|
||||
|
|
||||
LL | assert!(matches!('x', 'A'..='Z' | 'a'..='z'));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `'x'.is_ascii_alphabetic()`
|
||||
|
||||
error: manual check for common ascii range
|
||||
--> $DIR/manual_is_ascii_check.rs:32:13
|
||||
--> $DIR/manual_is_ascii_check.rs:29:13
|
||||
|
|
||||
LL | assert!(matches!(b'1', b'0'..=b'9'));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `b'1'.is_ascii_digit()`
|
||||
|
||||
error: manual check for common ascii range
|
||||
--> $DIR/manual_is_ascii_check.rs:33:13
|
||||
--> $DIR/manual_is_ascii_check.rs:30:13
|
||||
|
|
||||
LL | assert!(matches!('X', 'A'..='Z'));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `'X'.is_ascii_uppercase()`
|
||||
|
||||
error: manual check for common ascii range
|
||||
--> $DIR/manual_is_ascii_check.rs:34:13
|
||||
--> $DIR/manual_is_ascii_check.rs:31:13
|
||||
|
|
||||
LL | assert!(matches!('x', 'A'..='Z' | 'a'..='z'));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `'x'.is_ascii_alphabetic()`
|
||||
|
||||
error: manual check for common ascii range
|
||||
--> $DIR/manual_is_ascii_check.rs:44:23
|
||||
--> $DIR/manual_is_ascii_check.rs:41:23
|
||||
|
|
||||
LL | const FOO: bool = matches!('x', '0'..='9');
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `'x'.is_ascii_digit()`
|
||||
|
@ -1,7 +1,6 @@
|
||||
// run-rustfix
|
||||
// aux-build:macro_rules.rs
|
||||
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![warn(clippy::manual_rem_euclid)]
|
||||
|
||||
#[macro_use]
|
||||
@ -55,31 +54,27 @@ pub const fn const_rem_euclid_4(num: i32) -> i32 {
|
||||
num.rem_euclid(4)
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.37"]
|
||||
pub fn msrv_1_37() {
|
||||
#![clippy::msrv = "1.37"]
|
||||
|
||||
let x: i32 = 10;
|
||||
let _: i32 = ((x % 4) + 4) % 4;
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.38"]
|
||||
pub fn msrv_1_38() {
|
||||
#![clippy::msrv = "1.38"]
|
||||
|
||||
let x: i32 = 10;
|
||||
let _: i32 = x.rem_euclid(4);
|
||||
}
|
||||
|
||||
// For const fns:
|
||||
#[clippy::msrv = "1.51"]
|
||||
pub const fn msrv_1_51() {
|
||||
#![clippy::msrv = "1.51"]
|
||||
|
||||
let x: i32 = 10;
|
||||
let _: i32 = ((x % 4) + 4) % 4;
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.52"]
|
||||
pub const fn msrv_1_52() {
|
||||
#![clippy::msrv = "1.52"]
|
||||
|
||||
let x: i32 = 10;
|
||||
let _: i32 = x.rem_euclid(4);
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
// run-rustfix
|
||||
// aux-build:macro_rules.rs
|
||||
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![warn(clippy::manual_rem_euclid)]
|
||||
|
||||
#[macro_use]
|
||||
@ -55,31 +54,27 @@ pub const fn const_rem_euclid_4(num: i32) -> i32 {
|
||||
((num % 4) + 4) % 4
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.37"]
|
||||
pub fn msrv_1_37() {
|
||||
#![clippy::msrv = "1.37"]
|
||||
|
||||
let x: i32 = 10;
|
||||
let _: i32 = ((x % 4) + 4) % 4;
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.38"]
|
||||
pub fn msrv_1_38() {
|
||||
#![clippy::msrv = "1.38"]
|
||||
|
||||
let x: i32 = 10;
|
||||
let _: i32 = ((x % 4) + 4) % 4;
|
||||
}
|
||||
|
||||
// For const fns:
|
||||
#[clippy::msrv = "1.51"]
|
||||
pub const fn msrv_1_51() {
|
||||
#![clippy::msrv = "1.51"]
|
||||
|
||||
let x: i32 = 10;
|
||||
let _: i32 = ((x % 4) + 4) % 4;
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.52"]
|
||||
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:20:18
|
||||
--> $DIR/manual_rem_euclid.rs:19: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:21:18
|
||||
--> $DIR/manual_rem_euclid.rs:20: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:22:18
|
||||
--> $DIR/manual_rem_euclid.rs:21: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:23:18
|
||||
--> $DIR/manual_rem_euclid.rs:22: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:24:22
|
||||
--> $DIR/manual_rem_euclid.rs:23: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:13:22
|
||||
--> $DIR/manual_rem_euclid.rs:12:22
|
||||
|
|
||||
LL | let _: i32 = ((value % 4) + 4) % 4;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ help: consider using: `value.rem_euclid(4)`
|
||||
@ -42,25 +42,25 @@ 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:50:5
|
||||
--> $DIR/manual_rem_euclid.rs:49:5
|
||||
|
|
||||
LL | ((num % 4) + 4) % 4
|
||||
| ^^^^^^^^^^^^^^^^^^^ help: consider using: `num.rem_euclid(4)`
|
||||
|
||||
error: manual `rem_euclid` implementation
|
||||
--> $DIR/manual_rem_euclid.rs:55:5
|
||||
--> $DIR/manual_rem_euclid.rs:54:5
|
||||
|
|
||||
LL | ((num % 4) + 4) % 4
|
||||
| ^^^^^^^^^^^^^^^^^^^ help: consider using: `num.rem_euclid(4)`
|
||||
|
||||
error: manual `rem_euclid` implementation
|
||||
--> $DIR/manual_rem_euclid.rs:69:18
|
||||
--> $DIR/manual_rem_euclid.rs:66: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
|
||||
--> $DIR/manual_rem_euclid.rs:79:18
|
||||
|
|
||||
LL | let _: i32 = ((x % 4) + 4) % 4;
|
||||
| ^^^^^^^^^^^^^^^^^ help: consider using: `x.rem_euclid(4)`
|
||||
|
@ -1,5 +1,4 @@
|
||||
// run-rustfix
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![warn(clippy::manual_retain)]
|
||||
#![allow(unused)]
|
||||
use std::collections::BTreeMap;
|
||||
@ -216,8 +215,8 @@ fn vec_deque_retain() {
|
||||
bar = foobar.into_iter().filter(|x| x % 2 == 0).collect();
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.52"]
|
||||
fn _msrv_153() {
|
||||
#![clippy::msrv = "1.52"]
|
||||
let mut btree_map: BTreeMap<i8, i8> = (0..8).map(|x| (x, x * 10)).collect();
|
||||
btree_map = btree_map.into_iter().filter(|(k, _)| k % 2 == 0).collect();
|
||||
|
||||
@ -225,14 +224,14 @@ fn _msrv_153() {
|
||||
btree_set = btree_set.iter().filter(|&x| x % 2 == 0).copied().collect();
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.25"]
|
||||
fn _msrv_126() {
|
||||
#![clippy::msrv = "1.25"]
|
||||
let mut s = String::from("foobar");
|
||||
s = s.chars().filter(|&c| c != 'o').to_owned().collect();
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.17"]
|
||||
fn _msrv_118() {
|
||||
#![clippy::msrv = "1.17"]
|
||||
let mut hash_set = HashSet::from([1, 2, 3, 4, 5, 6]);
|
||||
hash_set = hash_set.into_iter().filter(|x| x % 2 == 0).collect();
|
||||
let mut hash_map: HashMap<i8, i8> = (0..8).map(|x| (x, x * 10)).collect();
|
||||
|
@ -1,5 +1,4 @@
|
||||
// run-rustfix
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![warn(clippy::manual_retain)]
|
||||
#![allow(unused)]
|
||||
use std::collections::BTreeMap;
|
||||
@ -222,8 +221,8 @@ fn vec_deque_retain() {
|
||||
bar = foobar.into_iter().filter(|x| x % 2 == 0).collect();
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.52"]
|
||||
fn _msrv_153() {
|
||||
#![clippy::msrv = "1.52"]
|
||||
let mut btree_map: BTreeMap<i8, i8> = (0..8).map(|x| (x, x * 10)).collect();
|
||||
btree_map = btree_map.into_iter().filter(|(k, _)| k % 2 == 0).collect();
|
||||
|
||||
@ -231,14 +230,14 @@ fn _msrv_153() {
|
||||
btree_set = btree_set.iter().filter(|&x| x % 2 == 0).copied().collect();
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.25"]
|
||||
fn _msrv_126() {
|
||||
#![clippy::msrv = "1.25"]
|
||||
let mut s = String::from("foobar");
|
||||
s = s.chars().filter(|&c| c != 'o').to_owned().collect();
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.17"]
|
||||
fn _msrv_118() {
|
||||
#![clippy::msrv = "1.17"]
|
||||
let mut hash_set = HashSet::from([1, 2, 3, 4, 5, 6]);
|
||||
hash_set = hash_set.into_iter().filter(|x| x % 2 == 0).collect();
|
||||
let mut hash_map: HashMap<i8, i8> = (0..8).map(|x| (x, x * 10)).collect();
|
||||
|
@ -1,5 +1,5 @@
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> $DIR/manual_retain.rs:52:5
|
||||
--> $DIR/manual_retain.rs:51:5
|
||||
|
|
||||
LL | btree_map = btree_map.into_iter().filter(|(k, _)| k % 2 == 0).collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `btree_map.retain(|k, _| k % 2 == 0)`
|
||||
@ -7,13 +7,13 @@ LL | btree_map = btree_map.into_iter().filter(|(k, _)| k % 2 == 0).collect()
|
||||
= note: `-D clippy::manual-retain` implied by `-D warnings`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> $DIR/manual_retain.rs:53:5
|
||||
--> $DIR/manual_retain.rs:52:5
|
||||
|
|
||||
LL | btree_map = btree_map.into_iter().filter(|(_, v)| v % 2 == 0).collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `btree_map.retain(|_, &mut v| v % 2 == 0)`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> $DIR/manual_retain.rs:54:5
|
||||
--> $DIR/manual_retain.rs:53:5
|
||||
|
|
||||
LL | / btree_map = btree_map
|
||||
LL | | .into_iter()
|
||||
@ -22,37 +22,37 @@ LL | | .collect();
|
||||
| |__________________^ help: consider calling `.retain()` instead: `btree_map.retain(|k, &mut v| (k % 2 == 0) && (v % 2 == 0))`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> $DIR/manual_retain.rs:76:5
|
||||
--> $DIR/manual_retain.rs:75:5
|
||||
|
|
||||
LL | btree_set = btree_set.iter().filter(|&x| x % 2 == 0).copied().collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `btree_set.retain(|x| x % 2 == 0)`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> $DIR/manual_retain.rs:77:5
|
||||
--> $DIR/manual_retain.rs:76:5
|
||||
|
|
||||
LL | btree_set = btree_set.iter().filter(|&x| x % 2 == 0).cloned().collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `btree_set.retain(|x| x % 2 == 0)`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> $DIR/manual_retain.rs:78:5
|
||||
--> $DIR/manual_retain.rs:77:5
|
||||
|
|
||||
LL | btree_set = btree_set.into_iter().filter(|x| x % 2 == 0).collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `btree_set.retain(|x| x % 2 == 0)`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> $DIR/manual_retain.rs:108:5
|
||||
--> $DIR/manual_retain.rs:107:5
|
||||
|
|
||||
LL | hash_map = hash_map.into_iter().filter(|(k, _)| k % 2 == 0).collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `hash_map.retain(|k, _| k % 2 == 0)`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> $DIR/manual_retain.rs:109:5
|
||||
--> $DIR/manual_retain.rs:108:5
|
||||
|
|
||||
LL | hash_map = hash_map.into_iter().filter(|(_, v)| v % 2 == 0).collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `hash_map.retain(|_, &mut v| v % 2 == 0)`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> $DIR/manual_retain.rs:110:5
|
||||
--> $DIR/manual_retain.rs:109:5
|
||||
|
|
||||
LL | / hash_map = hash_map
|
||||
LL | | .into_iter()
|
||||
@ -61,61 +61,61 @@ LL | | .collect();
|
||||
| |__________________^ help: consider calling `.retain()` instead: `hash_map.retain(|k, &mut v| (k % 2 == 0) && (v % 2 == 0))`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> $DIR/manual_retain.rs:131:5
|
||||
--> $DIR/manual_retain.rs:130:5
|
||||
|
|
||||
LL | hash_set = hash_set.into_iter().filter(|x| x % 2 == 0).collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `hash_set.retain(|x| x % 2 == 0)`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> $DIR/manual_retain.rs:132:5
|
||||
--> $DIR/manual_retain.rs:131:5
|
||||
|
|
||||
LL | hash_set = hash_set.iter().filter(|&x| x % 2 == 0).copied().collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `hash_set.retain(|x| x % 2 == 0)`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> $DIR/manual_retain.rs:133:5
|
||||
--> $DIR/manual_retain.rs:132:5
|
||||
|
|
||||
LL | hash_set = hash_set.iter().filter(|&x| x % 2 == 0).cloned().collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `hash_set.retain(|x| x % 2 == 0)`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> $DIR/manual_retain.rs:162:5
|
||||
--> $DIR/manual_retain.rs:161:5
|
||||
|
|
||||
LL | s = s.chars().filter(|&c| c != 'o').to_owned().collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `s.retain(|c| c != 'o')`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> $DIR/manual_retain.rs:174:5
|
||||
--> $DIR/manual_retain.rs:173:5
|
||||
|
|
||||
LL | vec = vec.iter().filter(|&x| x % 2 == 0).copied().collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec.retain(|x| x % 2 == 0)`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> $DIR/manual_retain.rs:175:5
|
||||
--> $DIR/manual_retain.rs:174:5
|
||||
|
|
||||
LL | vec = vec.iter().filter(|&x| x % 2 == 0).cloned().collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec.retain(|x| x % 2 == 0)`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> $DIR/manual_retain.rs:176:5
|
||||
--> $DIR/manual_retain.rs:175:5
|
||||
|
|
||||
LL | vec = vec.into_iter().filter(|x| x % 2 == 0).collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec.retain(|x| x % 2 == 0)`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> $DIR/manual_retain.rs:198:5
|
||||
--> $DIR/manual_retain.rs:197:5
|
||||
|
|
||||
LL | vec_deque = vec_deque.iter().filter(|&x| x % 2 == 0).copied().collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec_deque.retain(|x| x % 2 == 0)`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> $DIR/manual_retain.rs:199:5
|
||||
--> $DIR/manual_retain.rs:198:5
|
||||
|
|
||||
LL | vec_deque = vec_deque.iter().filter(|&x| x % 2 == 0).cloned().collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec_deque.retain(|x| x % 2 == 0)`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> $DIR/manual_retain.rs:200:5
|
||||
--> $DIR/manual_retain.rs:199:5
|
||||
|
|
||||
LL | vec_deque = vec_deque.into_iter().filter(|x| x % 2 == 0).collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec_deque.retain(|x| x % 2 == 0)`
|
||||
|
@ -1,6 +1,5 @@
|
||||
// run-rustfix
|
||||
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![warn(clippy::manual_split_once)]
|
||||
#![allow(unused, clippy::iter_skip_next, clippy::iter_nth_zero)]
|
||||
|
||||
@ -127,8 +126,8 @@ fn indirect() -> Option<()> {
|
||||
None
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.51"]
|
||||
fn _msrv_1_51() {
|
||||
#![clippy::msrv = "1.51"]
|
||||
// `str::split_once` was stabilized in 1.52. Do not lint this
|
||||
let _ = "key=value".splitn(2, '=').nth(1).unwrap();
|
||||
|
||||
@ -137,8 +136,8 @@ fn _msrv_1_51() {
|
||||
let b = iter.next().unwrap();
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.52"]
|
||||
fn _msrv_1_52() {
|
||||
#![clippy::msrv = "1.52"]
|
||||
let _ = "key=value".split_once('=').unwrap().1;
|
||||
|
||||
let (a, b) = "a.b.c".split_once('.').unwrap();
|
||||
|
@ -1,6 +1,5 @@
|
||||
// run-rustfix
|
||||
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![warn(clippy::manual_split_once)]
|
||||
#![allow(unused, clippy::iter_skip_next, clippy::iter_nth_zero)]
|
||||
|
||||
@ -127,8 +126,8 @@ fn indirect() -> Option<()> {
|
||||
None
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.51"]
|
||||
fn _msrv_1_51() {
|
||||
#![clippy::msrv = "1.51"]
|
||||
// `str::split_once` was stabilized in 1.52. Do not lint this
|
||||
let _ = "key=value".splitn(2, '=').nth(1).unwrap();
|
||||
|
||||
@ -137,8 +136,8 @@ fn _msrv_1_51() {
|
||||
let b = iter.next().unwrap();
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.52"]
|
||||
fn _msrv_1_52() {
|
||||
#![clippy::msrv = "1.52"]
|
||||
let _ = "key=value".splitn(2, '=').nth(1).unwrap();
|
||||
|
||||
let mut iter = "a.b.c".splitn(2, '.');
|
||||
|
@ -1,5 +1,5 @@
|
||||
error: manual implementation of `split_once`
|
||||
--> $DIR/manual_split_once.rs:14:13
|
||||
--> $DIR/manual_split_once.rs:13:13
|
||||
|
|
||||
LL | let _ = "key=value".splitn(2, '=').nth(1).unwrap();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `"key=value".split_once('=').unwrap().1`
|
||||
@ -7,79 +7,79 @@ LL | let _ = "key=value".splitn(2, '=').nth(1).unwrap();
|
||||
= note: `-D clippy::manual-split-once` implied by `-D warnings`
|
||||
|
||||
error: manual implementation of `split_once`
|
||||
--> $DIR/manual_split_once.rs:15:13
|
||||
--> $DIR/manual_split_once.rs:14:13
|
||||
|
|
||||
LL | let _ = "key=value".splitn(2, '=').skip(1).next().unwrap();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `"key=value".split_once('=').unwrap().1`
|
||||
|
||||
error: manual implementation of `split_once`
|
||||
--> $DIR/manual_split_once.rs:16:18
|
||||
--> $DIR/manual_split_once.rs:15:18
|
||||
|
|
||||
LL | let (_, _) = "key=value".splitn(2, '=').next_tuple().unwrap();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `"key=value".split_once('=')`
|
||||
|
||||
error: manual implementation of `split_once`
|
||||
--> $DIR/manual_split_once.rs:19:13
|
||||
--> $DIR/manual_split_once.rs:18:13
|
||||
|
|
||||
LL | let _ = s.splitn(2, '=').nth(1).unwrap();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `s.split_once('=').unwrap().1`
|
||||
|
||||
error: manual implementation of `split_once`
|
||||
--> $DIR/manual_split_once.rs:22:13
|
||||
--> $DIR/manual_split_once.rs:21:13
|
||||
|
|
||||
LL | let _ = s.splitn(2, '=').nth(1).unwrap();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `s.split_once('=').unwrap().1`
|
||||
|
||||
error: manual implementation of `split_once`
|
||||
--> $DIR/manual_split_once.rs:25:13
|
||||
--> $DIR/manual_split_once.rs:24:13
|
||||
|
|
||||
LL | let _ = s.splitn(2, '=').skip(1).next().unwrap();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `s.split_once('=').unwrap().1`
|
||||
|
||||
error: manual implementation of `split_once`
|
||||
--> $DIR/manual_split_once.rs:28:17
|
||||
--> $DIR/manual_split_once.rs:27:17
|
||||
|
|
||||
LL | let _ = s.splitn(2, '=').nth(1)?;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `s.split_once('=')?.1`
|
||||
|
||||
error: manual implementation of `split_once`
|
||||
--> $DIR/manual_split_once.rs:29:17
|
||||
--> $DIR/manual_split_once.rs:28:17
|
||||
|
|
||||
LL | let _ = s.splitn(2, '=').skip(1).next()?;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `s.split_once('=')?.1`
|
||||
|
||||
error: manual implementation of `rsplit_once`
|
||||
--> $DIR/manual_split_once.rs:30:17
|
||||
--> $DIR/manual_split_once.rs:29:17
|
||||
|
|
||||
LL | let _ = s.rsplitn(2, '=').nth(1)?;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `s.rsplit_once('=')?.0`
|
||||
|
||||
error: manual implementation of `rsplit_once`
|
||||
--> $DIR/manual_split_once.rs:31:17
|
||||
--> $DIR/manual_split_once.rs:30:17
|
||||
|
|
||||
LL | let _ = s.rsplitn(2, '=').skip(1).next()?;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `s.rsplit_once('=')?.0`
|
||||
|
||||
error: manual implementation of `rsplit_once`
|
||||
--> $DIR/manual_split_once.rs:39:13
|
||||
--> $DIR/manual_split_once.rs:38:13
|
||||
|
|
||||
LL | let _ = "key=value".rsplitn(2, '=').nth(1).unwrap();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `"key=value".rsplit_once('=').unwrap().0`
|
||||
|
||||
error: manual implementation of `rsplit_once`
|
||||
--> $DIR/manual_split_once.rs:40:18
|
||||
--> $DIR/manual_split_once.rs:39:18
|
||||
|
|
||||
LL | let (_, _) = "key=value".rsplitn(2, '=').next_tuple().unwrap();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `"key=value".rsplit_once('=').map(|(x, y)| (y, x))`
|
||||
|
||||
error: manual implementation of `rsplit_once`
|
||||
--> $DIR/manual_split_once.rs:41:13
|
||||
--> $DIR/manual_split_once.rs:40:13
|
||||
|
|
||||
LL | let _ = s.rsplitn(2, '=').nth(1);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `s.rsplit_once('=').map(|x| x.0)`
|
||||
|
||||
error: manual implementation of `split_once`
|
||||
--> $DIR/manual_split_once.rs:45:5
|
||||
--> $DIR/manual_split_once.rs:44:5
|
||||
|
|
||||
LL | let mut iter = "a.b.c".splitn(2, '.');
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
@ -104,7 +104,7 @@ LL +
|
||||
|
|
||||
|
||||
error: manual implementation of `split_once`
|
||||
--> $DIR/manual_split_once.rs:49:5
|
||||
--> $DIR/manual_split_once.rs:48:5
|
||||
|
|
||||
LL | let mut iter = "a.b.c".splitn(2, '.');
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
@ -129,7 +129,7 @@ LL +
|
||||
|
|
||||
|
||||
error: manual implementation of `rsplit_once`
|
||||
--> $DIR/manual_split_once.rs:53:5
|
||||
--> $DIR/manual_split_once.rs:52:5
|
||||
|
|
||||
LL | let mut iter = "a.b.c".rsplitn(2, '.');
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
@ -154,7 +154,7 @@ LL +
|
||||
|
|
||||
|
||||
error: manual implementation of `rsplit_once`
|
||||
--> $DIR/manual_split_once.rs:57:5
|
||||
--> $DIR/manual_split_once.rs:56:5
|
||||
|
|
||||
LL | let mut iter = "a.b.c".rsplitn(2, '.');
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
@ -179,13 +179,13 @@ LL +
|
||||
|
|
||||
|
||||
error: manual implementation of `split_once`
|
||||
--> $DIR/manual_split_once.rs:142:13
|
||||
--> $DIR/manual_split_once.rs:141:13
|
||||
|
|
||||
LL | let _ = "key=value".splitn(2, '=').nth(1).unwrap();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `"key=value".split_once('=').unwrap().1`
|
||||
|
||||
error: manual implementation of `split_once`
|
||||
--> $DIR/manual_split_once.rs:144:5
|
||||
--> $DIR/manual_split_once.rs:143:5
|
||||
|
|
||||
LL | let mut iter = "a.b.c".splitn(2, '.');
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -1,6 +1,5 @@
|
||||
// run-rustfix
|
||||
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![warn(clippy::manual_str_repeat)]
|
||||
|
||||
use std::borrow::Cow;
|
||||
@ -54,13 +53,13 @@ fn main() {
|
||||
let _: String = repeat(x).take(count).collect();
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.15"]
|
||||
fn _msrv_1_15() {
|
||||
#![clippy::msrv = "1.15"]
|
||||
// `str::repeat` was stabilized in 1.16. Do not lint this
|
||||
let _: String = std::iter::repeat("test").take(10).collect();
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.16"]
|
||||
fn _msrv_1_16() {
|
||||
#![clippy::msrv = "1.16"]
|
||||
let _: String = "test".repeat(10);
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
// run-rustfix
|
||||
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![warn(clippy::manual_str_repeat)]
|
||||
|
||||
use std::borrow::Cow;
|
||||
@ -54,13 +53,13 @@ fn main() {
|
||||
let _: String = repeat(x).take(count).collect();
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.15"]
|
||||
fn _msrv_1_15() {
|
||||
#![clippy::msrv = "1.15"]
|
||||
// `str::repeat` was stabilized in 1.16. Do not lint this
|
||||
let _: String = std::iter::repeat("test").take(10).collect();
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.16"]
|
||||
fn _msrv_1_16() {
|
||||
#![clippy::msrv = "1.16"]
|
||||
let _: String = std::iter::repeat("test").take(10).collect();
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
error: manual implementation of `str::repeat` using iterators
|
||||
--> $DIR/manual_str_repeat.rs:10:21
|
||||
--> $DIR/manual_str_repeat.rs:9:21
|
||||
|
|
||||
LL | let _: String = std::iter::repeat("test").take(10).collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `"test".repeat(10)`
|
||||
@ -7,55 +7,55 @@ LL | let _: String = std::iter::repeat("test").take(10).collect();
|
||||
= note: `-D clippy::manual-str-repeat` implied by `-D warnings`
|
||||
|
||||
error: manual implementation of `str::repeat` using iterators
|
||||
--> $DIR/manual_str_repeat.rs:11:21
|
||||
--> $DIR/manual_str_repeat.rs:10:21
|
||||
|
|
||||
LL | let _: String = std::iter::repeat('x').take(10).collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `"x".repeat(10)`
|
||||
|
||||
error: manual implementation of `str::repeat` using iterators
|
||||
--> $DIR/manual_str_repeat.rs:12:21
|
||||
--> $DIR/manual_str_repeat.rs:11:21
|
||||
|
|
||||
LL | let _: String = std::iter::repeat('/'').take(10).collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `"'".repeat(10)`
|
||||
|
||||
error: manual implementation of `str::repeat` using iterators
|
||||
--> $DIR/manual_str_repeat.rs:13:21
|
||||
--> $DIR/manual_str_repeat.rs:12:21
|
||||
|
|
||||
LL | let _: String = std::iter::repeat('"').take(10).collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `"/"".repeat(10)`
|
||||
|
||||
error: manual implementation of `str::repeat` using iterators
|
||||
--> $DIR/manual_str_repeat.rs:17:13
|
||||
--> $DIR/manual_str_repeat.rs:16:13
|
||||
|
|
||||
LL | let _ = repeat(x).take(count + 2).collect::<String>();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `x.repeat(count + 2)`
|
||||
|
||||
error: manual implementation of `str::repeat` using iterators
|
||||
--> $DIR/manual_str_repeat.rs:26:21
|
||||
--> $DIR/manual_str_repeat.rs:25:21
|
||||
|
|
||||
LL | let _: String = repeat(*x).take(count).collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `(*x).repeat(count)`
|
||||
|
||||
error: manual implementation of `str::repeat` using iterators
|
||||
--> $DIR/manual_str_repeat.rs:35:21
|
||||
--> $DIR/manual_str_repeat.rs:34:21
|
||||
|
|
||||
LL | let _: String = repeat(x).take(count).collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `x.repeat(count)`
|
||||
|
||||
error: manual implementation of `str::repeat` using iterators
|
||||
--> $DIR/manual_str_repeat.rs:47:21
|
||||
--> $DIR/manual_str_repeat.rs:46:21
|
||||
|
|
||||
LL | let _: String = repeat(Cow::Borrowed("test")).take(count).collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `Cow::Borrowed("test").repeat(count)`
|
||||
|
||||
error: manual implementation of `str::repeat` using iterators
|
||||
--> $DIR/manual_str_repeat.rs:50:21
|
||||
--> $DIR/manual_str_repeat.rs:49:21
|
||||
|
|
||||
LL | let _: String = repeat(x).take(count).collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `x.repeat(count)`
|
||||
|
||||
error: manual implementation of `str::repeat` using iterators
|
||||
--> $DIR/manual_str_repeat.rs:65:21
|
||||
--> $DIR/manual_str_repeat.rs:64:21
|
||||
|
|
||||
LL | let _: String = std::iter::repeat("test").take(10).collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `"test".repeat(10)`
|
||||
|
@ -1,4 +1,3 @@
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![warn(clippy::manual_strip)]
|
||||
|
||||
fn main() {
|
||||
@ -66,18 +65,16 @@ fn main() {
|
||||
}
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.44"]
|
||||
fn msrv_1_44() {
|
||||
#![clippy::msrv = "1.44"]
|
||||
|
||||
let s = "abc";
|
||||
if s.starts_with('a') {
|
||||
s[1..].to_string();
|
||||
}
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.45"]
|
||||
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:8:24
|
||||
--> $DIR/manual_strip.rs:7:24
|
||||
|
|
||||
LL | str::to_string(&s["ab".len()..]);
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: the prefix was tested here
|
||||
--> $DIR/manual_strip.rs:7:5
|
||||
--> $DIR/manual_strip.rs:6:5
|
||||
|
|
||||
LL | if s.starts_with("ab") {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||
@ -21,13 +21,13 @@ LL ~ <stripped>.to_string();
|
||||
|
|
||||
|
||||
error: stripping a suffix manually
|
||||
--> $DIR/manual_strip.rs:16:24
|
||||
--> $DIR/manual_strip.rs:15:24
|
||||
|
|
||||
LL | str::to_string(&s[..s.len() - "bc".len()]);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: the suffix was tested here
|
||||
--> $DIR/manual_strip.rs:15:5
|
||||
--> $DIR/manual_strip.rs:14:5
|
||||
|
|
||||
LL | if s.ends_with("bc") {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
@ -42,13 +42,13 @@ LL ~ <stripped>.to_string();
|
||||
|
|
||||
|
||||
error: stripping a prefix manually
|
||||
--> $DIR/manual_strip.rs:25:24
|
||||
--> $DIR/manual_strip.rs:24:24
|
||||
|
|
||||
LL | str::to_string(&s[1..]);
|
||||
| ^^^^^^^
|
||||
|
|
||||
note: the prefix was tested here
|
||||
--> $DIR/manual_strip.rs:24:5
|
||||
--> $DIR/manual_strip.rs:23:5
|
||||
|
|
||||
LL | if s.starts_with('a') {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
@ -60,13 +60,13 @@ LL ~ <stripped>.to_string();
|
||||
|
|
||||
|
||||
error: stripping a prefix manually
|
||||
--> $DIR/manual_strip.rs:32:24
|
||||
--> $DIR/manual_strip.rs:31:24
|
||||
|
|
||||
LL | str::to_string(&s[prefix.len()..]);
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: the prefix was tested here
|
||||
--> $DIR/manual_strip.rs:31:5
|
||||
--> $DIR/manual_strip.rs:30: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:38:24
|
||||
--> $DIR/manual_strip.rs:37:24
|
||||
|
|
||||
LL | str::to_string(&s[PREFIX.len()..]);
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: the prefix was tested here
|
||||
--> $DIR/manual_strip.rs:37:5
|
||||
--> $DIR/manual_strip.rs:36: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:45:24
|
||||
--> $DIR/manual_strip.rs:44:24
|
||||
|
|
||||
LL | str::to_string(&TARGET[prefix.len()..]);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: the prefix was tested here
|
||||
--> $DIR/manual_strip.rs:44:5
|
||||
--> $DIR/manual_strip.rs:43: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:51:9
|
||||
--> $DIR/manual_strip.rs:50:9
|
||||
|
|
||||
LL | s1[2..].to_uppercase();
|
||||
| ^^^^^^^
|
||||
|
|
||||
note: the prefix was tested here
|
||||
--> $DIR/manual_strip.rs:50:5
|
||||
--> $DIR/manual_strip.rs:49:5
|
||||
|
|
||||
LL | if s1.starts_with("ab") {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
@ -129,13 +129,13 @@ LL ~ <stripped>.to_uppercase();
|
||||
|
|
||||
|
||||
error: stripping a prefix manually
|
||||
--> $DIR/manual_strip.rs:83:9
|
||||
--> $DIR/manual_strip.rs:80:9
|
||||
|
|
||||
LL | s[1..].to_string();
|
||||
| ^^^^^^
|
||||
|
|
||||
note: the prefix was tested here
|
||||
--> $DIR/manual_strip.rs:82:5
|
||||
--> $DIR/manual_strip.rs:79:5
|
||||
|
|
||||
LL | if s.starts_with('a') {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -1,6 +1,5 @@
|
||||
// aux-build:option_helpers.rs
|
||||
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![warn(clippy::map_unwrap_or)]
|
||||
#![allow(clippy::uninlined_format_args, clippy::unnecessary_lazy_evaluations)]
|
||||
|
||||
@ -82,17 +81,15 @@ fn main() {
|
||||
result_methods();
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.40"]
|
||||
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);
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.41"]
|
||||
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:18:13
|
||||
--> $DIR/map_unwrap_or.rs:17: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:22:13
|
||||
--> $DIR/map_unwrap_or.rs:21: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:26:13
|
||||
--> $DIR/map_unwrap_or.rs:25: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:31:13
|
||||
--> $DIR/map_unwrap_or.rs:30: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:33:13
|
||||
--> $DIR/map_unwrap_or.rs:32: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:37:13
|
||||
--> $DIR/map_unwrap_or.rs:36: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:48:13
|
||||
--> $DIR/map_unwrap_or.rs:47: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:52:13
|
||||
--> $DIR/map_unwrap_or.rs:51: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:56:13
|
||||
--> $DIR/map_unwrap_or.rs:55: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:68:13
|
||||
--> $DIR/map_unwrap_or.rs:67: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:72:13
|
||||
--> $DIR/map_unwrap_or.rs:71:13
|
||||
|
|
||||
LL | let _ = res.map(|x| x + 1)
|
||||
| _____________^
|
||||
@ -147,7 +147,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:98:13
|
||||
--> $DIR/map_unwrap_or.rs:95: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)`
|
||||
|
@ -1,6 +1,5 @@
|
||||
// run-rustfix
|
||||
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![warn(clippy::match_like_matches_macro)]
|
||||
#![allow(
|
||||
unreachable_patterns,
|
||||
@ -200,17 +199,15 @@ fn main() {
|
||||
};
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.41"]
|
||||
fn msrv_1_41() {
|
||||
#![clippy::msrv = "1.41"]
|
||||
|
||||
let _y = match Some(5) {
|
||||
Some(0) => true,
|
||||
_ => false,
|
||||
};
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.42"]
|
||||
fn msrv_1_42() {
|
||||
#![clippy::msrv = "1.42"]
|
||||
|
||||
let _y = matches!(Some(5), Some(0));
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
// run-rustfix
|
||||
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![warn(clippy::match_like_matches_macro)]
|
||||
#![allow(
|
||||
unreachable_patterns,
|
||||
@ -241,18 +240,16 @@ fn main() {
|
||||
};
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.41"]
|
||||
fn msrv_1_41() {
|
||||
#![clippy::msrv = "1.41"]
|
||||
|
||||
let _y = match Some(5) {
|
||||
Some(0) => true,
|
||||
_ => false,
|
||||
};
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.42"]
|
||||
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:16:14
|
||||
--> $DIR/match_expr_like_matches_macro.rs:15: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:22:14
|
||||
--> $DIR/match_expr_like_matches_macro.rs:21: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:28:14
|
||||
--> $DIR/match_expr_like_matches_macro.rs:27: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:34:15
|
||||
--> $DIR/match_expr_like_matches_macro.rs:33: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:40:16
|
||||
--> $DIR/match_expr_like_matches_macro.rs:39: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:64:20
|
||||
--> $DIR/match_expr_like_matches_macro.rs:63: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:74:20
|
||||
--> $DIR/match_expr_like_matches_macro.rs:73: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:84:20
|
||||
--> $DIR/match_expr_like_matches_macro.rs:83: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:144:18
|
||||
--> $DIR/match_expr_like_matches_macro.rs:143: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:153:18
|
||||
--> $DIR/match_expr_like_matches_macro.rs:152: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:170:21
|
||||
--> $DIR/match_expr_like_matches_macro.rs:169: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:184:20
|
||||
--> $DIR/match_expr_like_matches_macro.rs:183: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:196:20
|
||||
--> $DIR/match_expr_like_matches_macro.rs:195:20
|
||||
|
|
||||
LL | let _res = match &val {
|
||||
| ____________________^
|
||||
@ -134,7 +134,7 @@ LL | | };
|
||||
| |_________^ help: try this: `matches!(&val, &Some(ref _a))`
|
||||
|
||||
error: match expression looks like `matches!` macro
|
||||
--> $DIR/match_expr_like_matches_macro.rs:256:14
|
||||
--> $DIR/match_expr_like_matches_macro.rs:253:14
|
||||
|
|
||||
LL | let _y = match Some(5) {
|
||||
| ______________^
|
||||
|
@ -1,6 +1,5 @@
|
||||
// run-rustfix
|
||||
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![allow(unused)]
|
||||
#![warn(
|
||||
clippy::all,
|
||||
@ -80,16 +79,14 @@ fn main() {
|
||||
dont_lint_primitive();
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.39"]
|
||||
fn msrv_1_39() {
|
||||
#![clippy::msrv = "1.39"]
|
||||
|
||||
let mut s = String::from("foo");
|
||||
let _ = std::mem::replace(&mut s, String::default());
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.40"]
|
||||
fn msrv_1_40() {
|
||||
#![clippy::msrv = "1.40"]
|
||||
|
||||
let mut s = String::from("foo");
|
||||
let _ = std::mem::take(&mut s);
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
// run-rustfix
|
||||
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![allow(unused)]
|
||||
#![warn(
|
||||
clippy::all,
|
||||
@ -80,16 +79,14 @@ fn main() {
|
||||
dont_lint_primitive();
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.39"]
|
||||
fn msrv_1_39() {
|
||||
#![clippy::msrv = "1.39"]
|
||||
|
||||
let mut s = String::from("foo");
|
||||
let _ = std::mem::replace(&mut s, String::default());
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.40"]
|
||||
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:17:13
|
||||
--> $DIR/mem_replace.rs:16: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:19:13
|
||||
--> $DIR/mem_replace.rs:18: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:24:13
|
||||
--> $DIR/mem_replace.rs:23:13
|
||||
|
|
||||
LL | let _ = std::mem::replace(&mut s, String::default());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut s)`
|
||||
@ -21,103 +21,103 @@ 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:27:13
|
||||
--> $DIR/mem_replace.rs:26: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:28:13
|
||||
--> $DIR/mem_replace.rs:27: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:31:13
|
||||
--> $DIR/mem_replace.rs:30: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:32:13
|
||||
--> $DIR/mem_replace.rs:31: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:33:13
|
||||
--> $DIR/mem_replace.rs:32: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:34:13
|
||||
--> $DIR/mem_replace.rs:33: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:37:13
|
||||
--> $DIR/mem_replace.rs:36: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:40:13
|
||||
--> $DIR/mem_replace.rs:39: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:43:13
|
||||
--> $DIR/mem_replace.rs:42: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:46:13
|
||||
--> $DIR/mem_replace.rs:45: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:49:13
|
||||
--> $DIR/mem_replace.rs:48: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:52:13
|
||||
--> $DIR/mem_replace.rs:51: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:55:13
|
||||
--> $DIR/mem_replace.rs:54: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:58:13
|
||||
--> $DIR/mem_replace.rs:57: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:61:13
|
||||
--> $DIR/mem_replace.rs:60: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:64:13
|
||||
--> $DIR/mem_replace.rs:63:13
|
||||
|
|
||||
LL | let _ = std::mem::replace(&mut slice, &[]);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut slice)`
|
||||
|
||||
error: replacing a value of type `T` with `T::default()` is better expressed using `std::mem::take`
|
||||
--> $DIR/mem_replace.rs:94:13
|
||||
--> $DIR/mem_replace.rs:91:13
|
||||
|
|
||||
LL | let _ = std::mem::replace(&mut s, String::default());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `std::mem::take(&mut s)`
|
||||
|
@ -3,27 +3,37 @@
|
||||
|
||||
fn main() {}
|
||||
|
||||
#[clippy::msrv = "1.42.0"]
|
||||
fn just_under_msrv() {
|
||||
#![clippy::msrv = "1.42.0"]
|
||||
let log2_10 = 3.321928094887362;
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.43.0"]
|
||||
fn meets_msrv() {
|
||||
#![clippy::msrv = "1.43.0"]
|
||||
let log2_10 = 3.321928094887362;
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.44.0"]
|
||||
fn just_above_msrv() {
|
||||
#![clippy::msrv = "1.44.0"]
|
||||
let log2_10 = 3.321928094887362;
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.42"]
|
||||
fn no_patch_under() {
|
||||
let log2_10 = 3.321928094887362;
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.43"]
|
||||
fn no_patch_meets() {
|
||||
let log2_10 = 3.321928094887362;
|
||||
}
|
||||
|
||||
fn inner_attr_under() {
|
||||
#![clippy::msrv = "1.42"]
|
||||
let log2_10 = 3.321928094887362;
|
||||
}
|
||||
|
||||
fn no_patch_meets() {
|
||||
fn inner_attr_meets() {
|
||||
#![clippy::msrv = "1.43"]
|
||||
let log2_10 = 3.321928094887362;
|
||||
}
|
||||
|
@ -32,12 +32,20 @@ LL | let log2_10 = 3.321928094887362;
|
||||
= help: consider using the constant directly
|
||||
|
||||
error: approximate value of `f{32, 64}::consts::LOG2_10` found
|
||||
--> $DIR/min_rust_version_attr.rs:45:27
|
||||
--> $DIR/min_rust_version_attr.rs:48:19
|
||||
|
|
||||
LL | let log2_10 = 3.321928094887362;
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: consider using the constant directly
|
||||
|
||||
error: approximate value of `f{32, 64}::consts::LOG2_10` found
|
||||
--> $DIR/min_rust_version_attr.rs:55:27
|
||||
|
|
||||
LL | let log2_10 = 3.321928094887362;
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: consider using the constant directly
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
error: aborting due to 6 previous errors
|
||||
|
||||
|
@ -4,7 +4,7 @@ error: `invalid.version` is not a valid Rust version
|
||||
LL | #![clippy::msrv = "invalid.version"]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: `msrv` cannot be an outer attribute
|
||||
error: `invalid.version` is not a valid Rust version
|
||||
--> $DIR/min_rust_version_invalid_attr.rs:6:1
|
||||
|
|
||||
LL | #[clippy::msrv = "invalid.version"]
|
||||
|
@ -7,7 +7,6 @@
|
||||
|
||||
#![warn(clippy::missing_const_for_fn)]
|
||||
#![feature(start)]
|
||||
#![feature(custom_inner_attributes)]
|
||||
|
||||
extern crate helper;
|
||||
extern crate proc_macro_with_span;
|
||||
@ -115,9 +114,8 @@ fn unstably_const_fn() {
|
||||
helper::unstably_const_fn()
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.46.0"]
|
||||
mod const_fn_stabilized_after_msrv {
|
||||
#![clippy::msrv = "1.46.0"]
|
||||
|
||||
// Do not lint this because `u8::is_ascii_digit` is stabilized as a const function in 1.47.0.
|
||||
fn const_fn_stabilized_after_msrv(byte: u8) {
|
||||
byte.is_ascii_digit();
|
||||
|
@ -1,6 +1,5 @@
|
||||
#![warn(clippy::missing_const_for_fn)]
|
||||
#![allow(incomplete_features, clippy::let_and_return)]
|
||||
#![feature(custom_inner_attributes)]
|
||||
|
||||
use std::mem::transmute;
|
||||
|
||||
@ -68,24 +67,21 @@ mod with_drop {
|
||||
}
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.47.0"]
|
||||
mod const_fn_stabilized_before_msrv {
|
||||
#![clippy::msrv = "1.47.0"]
|
||||
|
||||
// This could be const because `u8::is_ascii_digit` is a stable const function in 1.47.
|
||||
fn const_fn_stabilized_before_msrv(byte: u8) {
|
||||
byte.is_ascii_digit();
|
||||
}
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.45"]
|
||||
fn msrv_1_45() -> i32 {
|
||||
#![clippy::msrv = "1.45"]
|
||||
|
||||
45
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.46"]
|
||||
fn msrv_1_46() -> i32 {
|
||||
#![clippy::msrv = "1.46"]
|
||||
|
||||
46
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
error: this could be a `const fn`
|
||||
--> $DIR/could_be_const.rs:13:5
|
||||
--> $DIR/could_be_const.rs:12:5
|
||||
|
|
||||
LL | / pub fn new() -> Self {
|
||||
LL | | Self { guess: 42 }
|
||||
@ -9,7 +9,7 @@ LL | | }
|
||||
= note: `-D clippy::missing-const-for-fn` implied by `-D warnings`
|
||||
|
||||
error: this could be a `const fn`
|
||||
--> $DIR/could_be_const.rs:17:5
|
||||
--> $DIR/could_be_const.rs:16:5
|
||||
|
|
||||
LL | / fn const_generic_params<'a, T, const N: usize>(&self, b: &'a [T; N]) -> &'a [T; N] {
|
||||
LL | | b
|
||||
@ -17,7 +17,7 @@ LL | | }
|
||||
| |_____^
|
||||
|
||||
error: this could be a `const fn`
|
||||
--> $DIR/could_be_const.rs:23:1
|
||||
--> $DIR/could_be_const.rs:22:1
|
||||
|
|
||||
LL | / fn one() -> i32 {
|
||||
LL | | 1
|
||||
@ -25,7 +25,7 @@ LL | | }
|
||||
| |_^
|
||||
|
||||
error: this could be a `const fn`
|
||||
--> $DIR/could_be_const.rs:28:1
|
||||
--> $DIR/could_be_const.rs:27:1
|
||||
|
|
||||
LL | / fn two() -> i32 {
|
||||
LL | | let abc = 2;
|
||||
@ -34,7 +34,7 @@ LL | | }
|
||||
| |_^
|
||||
|
||||
error: this could be a `const fn`
|
||||
--> $DIR/could_be_const.rs:34:1
|
||||
--> $DIR/could_be_const.rs:33:1
|
||||
|
|
||||
LL | / fn string() -> String {
|
||||
LL | | String::new()
|
||||
@ -42,7 +42,7 @@ LL | | }
|
||||
| |_^
|
||||
|
||||
error: this could be a `const fn`
|
||||
--> $DIR/could_be_const.rs:39:1
|
||||
--> $DIR/could_be_const.rs:38:1
|
||||
|
|
||||
LL | / unsafe fn four() -> i32 {
|
||||
LL | | 4
|
||||
@ -50,7 +50,7 @@ LL | | }
|
||||
| |_^
|
||||
|
||||
error: this could be a `const fn`
|
||||
--> $DIR/could_be_const.rs:44:1
|
||||
--> $DIR/could_be_const.rs:43:1
|
||||
|
|
||||
LL | / fn generic<T>(t: T) -> T {
|
||||
LL | | t
|
||||
@ -58,7 +58,7 @@ LL | | }
|
||||
| |_^
|
||||
|
||||
error: this could be a `const fn`
|
||||
--> $DIR/could_be_const.rs:52:1
|
||||
--> $DIR/could_be_const.rs:51:1
|
||||
|
|
||||
LL | / fn generic_arr<T: Copy>(t: [T; 1]) -> T {
|
||||
LL | | t[0]
|
||||
@ -66,7 +66,7 @@ LL | | }
|
||||
| |_^
|
||||
|
||||
error: this could be a `const fn`
|
||||
--> $DIR/could_be_const.rs:65:9
|
||||
--> $DIR/could_be_const.rs:64:9
|
||||
|
|
||||
LL | / pub fn b(self, a: &A) -> B {
|
||||
LL | | B
|
||||
@ -74,7 +74,7 @@ LL | | }
|
||||
| |_________^
|
||||
|
||||
error: this could be a `const fn`
|
||||
--> $DIR/could_be_const.rs:75:5
|
||||
--> $DIR/could_be_const.rs:73:5
|
||||
|
|
||||
LL | / fn const_fn_stabilized_before_msrv(byte: u8) {
|
||||
LL | | byte.is_ascii_digit();
|
||||
@ -82,11 +82,9 @@ LL | | }
|
||||
| |_____^
|
||||
|
||||
error: this could be a `const fn`
|
||||
--> $DIR/could_be_const.rs:86:1
|
||||
--> $DIR/could_be_const.rs:84:1
|
||||
|
|
||||
LL | / fn msrv_1_46() -> i32 {
|
||||
LL | | #![clippy::msrv = "1.46"]
|
||||
LL | |
|
||||
LL | | 46
|
||||
LL | | }
|
||||
| |_^
|
||||
|
@ -1,13 +1,13 @@
|
||||
// run-rustfix
|
||||
#![feature(custom_inner_attributes, lint_reasons)]
|
||||
|
||||
#[warn(clippy::all, clippy::needless_borrow)]
|
||||
#[allow(unused_variables)]
|
||||
#[allow(
|
||||
#![feature(lint_reasons)]
|
||||
#![allow(
|
||||
unused,
|
||||
clippy::uninlined_format_args,
|
||||
clippy::unnecessary_mut_passed,
|
||||
clippy::unnecessary_to_owned
|
||||
)]
|
||||
#![warn(clippy::needless_borrow)]
|
||||
|
||||
fn main() {
|
||||
let a = 5;
|
||||
let ref_a = &a;
|
||||
@ -171,14 +171,12 @@ impl<'a> Trait for &'a str {}
|
||||
|
||||
fn h(_: &dyn Trait) {}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn check_expect_suppression() {
|
||||
let a = 5;
|
||||
#[expect(clippy::needless_borrow)]
|
||||
let _ = x(&&a);
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
mod issue9160 {
|
||||
pub struct S<F> {
|
||||
f: F,
|
||||
@ -267,7 +265,6 @@ where
|
||||
}
|
||||
|
||||
// https://github.com/rust-lang/rust-clippy/pull/9136#pullrequestreview-1037379321
|
||||
#[allow(dead_code)]
|
||||
mod copyable_iterator {
|
||||
#[derive(Clone, Copy)]
|
||||
struct Iter;
|
||||
@ -287,25 +284,20 @@ mod copyable_iterator {
|
||||
}
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.52.0"]
|
||||
mod under_msrv {
|
||||
#![allow(dead_code)]
|
||||
#![clippy::msrv = "1.52.0"]
|
||||
|
||||
fn foo() {
|
||||
let _ = std::process::Command::new("ls").args(&["-a", "-l"]).status().unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.53.0"]
|
||||
mod meets_msrv {
|
||||
#![allow(dead_code)]
|
||||
#![clippy::msrv = "1.53.0"]
|
||||
|
||||
fn foo() {
|
||||
let _ = std::process::Command::new("ls").args(["-a", "-l"]).status().unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(unused)]
|
||||
fn issue9383() {
|
||||
// Should not lint because unions need explicit deref when accessing field
|
||||
use std::mem::ManuallyDrop;
|
||||
@ -334,7 +326,6 @@ fn issue9383() {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn closure_test() {
|
||||
let env = "env".to_owned();
|
||||
let arg = "arg".to_owned();
|
||||
@ -348,7 +339,6 @@ fn closure_test() {
|
||||
f(arg);
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
mod significant_drop {
|
||||
#[derive(Debug)]
|
||||
struct X;
|
||||
@ -368,7 +358,6 @@ mod significant_drop {
|
||||
fn debug(_: impl std::fmt::Debug) {}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
mod used_exactly_once {
|
||||
fn foo(x: String) {
|
||||
use_x(x);
|
||||
@ -376,7 +365,6 @@ mod used_exactly_once {
|
||||
fn use_x(_: impl AsRef<str>) {}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
mod used_more_than_once {
|
||||
fn foo(x: String) {
|
||||
use_x(&x);
|
||||
@ -387,7 +375,6 @@ mod used_more_than_once {
|
||||
}
|
||||
|
||||
// https://github.com/rust-lang/rust-clippy/issues/9111#issuecomment-1277114280
|
||||
#[allow(dead_code)]
|
||||
mod issue_9111 {
|
||||
struct A;
|
||||
|
||||
@ -409,7 +396,6 @@ mod issue_9111 {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
mod issue_9710 {
|
||||
fn main() {
|
||||
let string = String::new();
|
||||
@ -421,7 +407,6 @@ mod issue_9710 {
|
||||
fn f<T: AsRef<str>>(_: T) {}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
mod issue_9739 {
|
||||
fn foo<D: std::fmt::Display>(_it: impl IntoIterator<Item = D>) {}
|
||||
|
||||
@ -434,7 +419,6 @@ mod issue_9739 {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
mod issue_9739_method_variant {
|
||||
struct S;
|
||||
|
||||
@ -451,7 +435,6 @@ mod issue_9739_method_variant {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
mod issue_9782 {
|
||||
fn foo<T: AsRef<[u8]>>(t: T) {
|
||||
println!("{}", std::mem::size_of::<T>());
|
||||
@ -475,7 +458,6 @@ mod issue_9782 {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
mod issue_9782_type_relative_variant {
|
||||
struct S;
|
||||
|
||||
@ -493,7 +475,6 @@ mod issue_9782_type_relative_variant {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
mod issue_9782_method_variant {
|
||||
struct S;
|
||||
|
||||
|
@ -1,13 +1,13 @@
|
||||
// run-rustfix
|
||||
#![feature(custom_inner_attributes, lint_reasons)]
|
||||
|
||||
#[warn(clippy::all, clippy::needless_borrow)]
|
||||
#[allow(unused_variables)]
|
||||
#[allow(
|
||||
#![feature(lint_reasons)]
|
||||
#![allow(
|
||||
unused,
|
||||
clippy::uninlined_format_args,
|
||||
clippy::unnecessary_mut_passed,
|
||||
clippy::unnecessary_to_owned
|
||||
)]
|
||||
#![warn(clippy::needless_borrow)]
|
||||
|
||||
fn main() {
|
||||
let a = 5;
|
||||
let ref_a = &a;
|
||||
@ -171,14 +171,12 @@ impl<'a> Trait for &'a str {}
|
||||
|
||||
fn h(_: &dyn Trait) {}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn check_expect_suppression() {
|
||||
let a = 5;
|
||||
#[expect(clippy::needless_borrow)]
|
||||
let _ = x(&&a);
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
mod issue9160 {
|
||||
pub struct S<F> {
|
||||
f: F,
|
||||
@ -267,7 +265,6 @@ where
|
||||
}
|
||||
|
||||
// https://github.com/rust-lang/rust-clippy/pull/9136#pullrequestreview-1037379321
|
||||
#[allow(dead_code)]
|
||||
mod copyable_iterator {
|
||||
#[derive(Clone, Copy)]
|
||||
struct Iter;
|
||||
@ -287,25 +284,20 @@ mod copyable_iterator {
|
||||
}
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.52.0"]
|
||||
mod under_msrv {
|
||||
#![allow(dead_code)]
|
||||
#![clippy::msrv = "1.52.0"]
|
||||
|
||||
fn foo() {
|
||||
let _ = std::process::Command::new("ls").args(&["-a", "-l"]).status().unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.53.0"]
|
||||
mod meets_msrv {
|
||||
#![allow(dead_code)]
|
||||
#![clippy::msrv = "1.53.0"]
|
||||
|
||||
fn foo() {
|
||||
let _ = std::process::Command::new("ls").args(&["-a", "-l"]).status().unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(unused)]
|
||||
fn issue9383() {
|
||||
// Should not lint because unions need explicit deref when accessing field
|
||||
use std::mem::ManuallyDrop;
|
||||
@ -334,7 +326,6 @@ fn issue9383() {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn closure_test() {
|
||||
let env = "env".to_owned();
|
||||
let arg = "arg".to_owned();
|
||||
@ -348,7 +339,6 @@ fn closure_test() {
|
||||
f(arg);
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
mod significant_drop {
|
||||
#[derive(Debug)]
|
||||
struct X;
|
||||
@ -368,7 +358,6 @@ mod significant_drop {
|
||||
fn debug(_: impl std::fmt::Debug) {}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
mod used_exactly_once {
|
||||
fn foo(x: String) {
|
||||
use_x(&x);
|
||||
@ -376,7 +365,6 @@ mod used_exactly_once {
|
||||
fn use_x(_: impl AsRef<str>) {}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
mod used_more_than_once {
|
||||
fn foo(x: String) {
|
||||
use_x(&x);
|
||||
@ -387,7 +375,6 @@ mod used_more_than_once {
|
||||
}
|
||||
|
||||
// https://github.com/rust-lang/rust-clippy/issues/9111#issuecomment-1277114280
|
||||
#[allow(dead_code)]
|
||||
mod issue_9111 {
|
||||
struct A;
|
||||
|
||||
@ -409,7 +396,6 @@ mod issue_9111 {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
mod issue_9710 {
|
||||
fn main() {
|
||||
let string = String::new();
|
||||
@ -421,7 +407,6 @@ mod issue_9710 {
|
||||
fn f<T: AsRef<str>>(_: T) {}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
mod issue_9739 {
|
||||
fn foo<D: std::fmt::Display>(_it: impl IntoIterator<Item = D>) {}
|
||||
|
||||
@ -434,7 +419,6 @@ mod issue_9739 {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
mod issue_9739_method_variant {
|
||||
struct S;
|
||||
|
||||
@ -451,7 +435,6 @@ mod issue_9739_method_variant {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
mod issue_9782 {
|
||||
fn foo<T: AsRef<[u8]>>(t: T) {
|
||||
println!("{}", std::mem::size_of::<T>());
|
||||
@ -475,7 +458,6 @@ mod issue_9782 {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
mod issue_9782_type_relative_variant {
|
||||
struct S;
|
||||
|
||||
@ -493,7 +475,6 @@ mod issue_9782_type_relative_variant {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
mod issue_9782_method_variant {
|
||||
struct S;
|
||||
|
||||
|
@ -163,55 +163,55 @@ LL | let _ = std::fs::write("x", &"".to_string());
|
||||
| ^^^^^^^^^^^^^^^ help: change this to: `"".to_string()`
|
||||
|
||||
error: this expression borrows a value the compiler would automatically borrow
|
||||
--> $DIR/needless_borrow.rs:192:13
|
||||
--> $DIR/needless_borrow.rs:190:13
|
||||
|
|
||||
LL | (&self.f)()
|
||||
| ^^^^^^^^^ help: change this to: `(self.f)`
|
||||
|
||||
error: this expression borrows a value the compiler would automatically borrow
|
||||
--> $DIR/needless_borrow.rs:201:13
|
||||
--> $DIR/needless_borrow.rs:199:13
|
||||
|
|
||||
LL | (&mut self.f)()
|
||||
| ^^^^^^^^^^^^^ help: change this to: `(self.f)`
|
||||
|
||||
error: the borrowed expression implements the required traits
|
||||
--> $DIR/needless_borrow.rs:286:20
|
||||
--> $DIR/needless_borrow.rs:283:20
|
||||
|
|
||||
LL | takes_iter(&mut x)
|
||||
| ^^^^^^ help: change this to: `x`
|
||||
|
||||
error: the borrowed expression implements the required traits
|
||||
--> $DIR/needless_borrow.rs:304:55
|
||||
--> $DIR/needless_borrow.rs:297:55
|
||||
|
|
||||
LL | let _ = std::process::Command::new("ls").args(&["-a", "-l"]).status().unwrap();
|
||||
| ^^^^^^^^^^^^^ help: change this to: `["-a", "-l"]`
|
||||
|
||||
error: the borrowed expression implements the required traits
|
||||
--> $DIR/needless_borrow.rs:344:37
|
||||
--> $DIR/needless_borrow.rs:335:37
|
||||
|
|
||||
LL | let _ = std::fs::write("x", &arg);
|
||||
| ^^^^ help: change this to: `arg`
|
||||
|
||||
error: the borrowed expression implements the required traits
|
||||
--> $DIR/needless_borrow.rs:345:37
|
||||
--> $DIR/needless_borrow.rs:336:37
|
||||
|
|
||||
LL | let _ = std::fs::write("x", &loc);
|
||||
| ^^^^ help: change this to: `loc`
|
||||
|
||||
error: the borrowed expression implements the required traits
|
||||
--> $DIR/needless_borrow.rs:364:15
|
||||
--> $DIR/needless_borrow.rs:354:15
|
||||
|
|
||||
LL | debug(&x);
|
||||
| ^^ help: change this to: `x`
|
||||
|
||||
error: the borrowed expression implements the required traits
|
||||
--> $DIR/needless_borrow.rs:374:15
|
||||
--> $DIR/needless_borrow.rs:363:15
|
||||
|
|
||||
LL | use_x(&x);
|
||||
| ^^ help: change this to: `x`
|
||||
|
||||
error: the borrowed expression implements the required traits
|
||||
--> $DIR/needless_borrow.rs:474:13
|
||||
--> $DIR/needless_borrow.rs:457:13
|
||||
|
|
||||
LL | foo(&a);
|
||||
| ^^ help: change this to: `a`
|
||||
|
@ -8,7 +8,6 @@
|
||||
dead_code,
|
||||
unused_must_use
|
||||
)]
|
||||
#![feature(custom_inner_attributes)]
|
||||
|
||||
struct TO {
|
||||
magic: Option<usize>,
|
||||
|
@ -8,7 +8,6 @@
|
||||
dead_code,
|
||||
unused_must_use
|
||||
)]
|
||||
#![feature(custom_inner_attributes)]
|
||||
|
||||
struct TO {
|
||||
magic: Option<usize>,
|
||||
|
@ -1,5 +1,5 @@
|
||||
error: question mark operator is useless here
|
||||
--> $DIR/needless_question_mark.rs:23:12
|
||||
--> $DIR/needless_question_mark.rs:22:12
|
||||
|
|
||||
LL | return Some(to.magic?);
|
||||
| ^^^^^^^^^^^^^^^ help: try removing question mark and `Some()`: `to.magic`
|
||||
@ -7,67 +7,67 @@ LL | return Some(to.magic?);
|
||||
= note: `-D clippy::needless-question-mark` implied by `-D warnings`
|
||||
|
||||
error: question mark operator is useless here
|
||||
--> $DIR/needless_question_mark.rs:31:12
|
||||
--> $DIR/needless_question_mark.rs:30:12
|
||||
|
|
||||
LL | return Some(to.magic?)
|
||||
| ^^^^^^^^^^^^^^^ help: try removing question mark and `Some()`: `to.magic`
|
||||
|
||||
error: question mark operator is useless here
|
||||
--> $DIR/needless_question_mark.rs:36:5
|
||||
--> $DIR/needless_question_mark.rs:35:5
|
||||
|
|
||||
LL | Some(to.magic?)
|
||||
| ^^^^^^^^^^^^^^^ help: try removing question mark and `Some()`: `to.magic`
|
||||
|
||||
error: question mark operator is useless here
|
||||
--> $DIR/needless_question_mark.rs:41:21
|
||||
--> $DIR/needless_question_mark.rs:40:21
|
||||
|
|
||||
LL | to.and_then(|t| Some(t.magic?))
|
||||
| ^^^^^^^^^^^^^^ help: try removing question mark and `Some()`: `t.magic`
|
||||
|
||||
error: question mark operator is useless here
|
||||
--> $DIR/needless_question_mark.rs:50:9
|
||||
--> $DIR/needless_question_mark.rs:49:9
|
||||
|
|
||||
LL | Some(t.magic?)
|
||||
| ^^^^^^^^^^^^^^ help: try removing question mark and `Some()`: `t.magic`
|
||||
|
||||
error: question mark operator is useless here
|
||||
--> $DIR/needless_question_mark.rs:55:12
|
||||
--> $DIR/needless_question_mark.rs:54:12
|
||||
|
|
||||
LL | return Ok(tr.magic?);
|
||||
| ^^^^^^^^^^^^^ help: try removing question mark and `Ok()`: `tr.magic`
|
||||
|
||||
error: question mark operator is useless here
|
||||
--> $DIR/needless_question_mark.rs:62:12
|
||||
--> $DIR/needless_question_mark.rs:61:12
|
||||
|
|
||||
LL | return Ok(tr.magic?)
|
||||
| ^^^^^^^^^^^^^ help: try removing question mark and `Ok()`: `tr.magic`
|
||||
|
||||
error: question mark operator is useless here
|
||||
--> $DIR/needless_question_mark.rs:66:5
|
||||
--> $DIR/needless_question_mark.rs:65:5
|
||||
|
|
||||
LL | Ok(tr.magic?)
|
||||
| ^^^^^^^^^^^^^ help: try removing question mark and `Ok()`: `tr.magic`
|
||||
|
||||
error: question mark operator is useless here
|
||||
--> $DIR/needless_question_mark.rs:70:21
|
||||
--> $DIR/needless_question_mark.rs:69:21
|
||||
|
|
||||
LL | tr.and_then(|t| Ok(t.magic?))
|
||||
| ^^^^^^^^^^^^ help: try removing question mark and `Ok()`: `t.magic`
|
||||
|
||||
error: question mark operator is useless here
|
||||
--> $DIR/needless_question_mark.rs:78:9
|
||||
--> $DIR/needless_question_mark.rs:77:9
|
||||
|
|
||||
LL | Ok(t.magic?)
|
||||
| ^^^^^^^^^^^^ help: try removing question mark and `Ok()`: `t.magic`
|
||||
|
||||
error: question mark operator is useless here
|
||||
--> $DIR/needless_question_mark.rs:85:16
|
||||
--> $DIR/needless_question_mark.rs:84:16
|
||||
|
|
||||
LL | return Ok(t.magic?);
|
||||
| ^^^^^^^^^^^^ help: try removing question mark and `Ok()`: `t.magic`
|
||||
|
||||
error: question mark operator is useless here
|
||||
--> $DIR/needless_question_mark.rs:120:27
|
||||
--> $DIR/needless_question_mark.rs:119:27
|
||||
|
|
||||
LL | || -> Option<_> { Some(Some($expr)?) }()
|
||||
| ^^^^^^^^^^^^^^^^^^ help: try removing question mark and `Some()`: `Some($expr)`
|
||||
@ -78,13 +78,13 @@ LL | let _x = some_and_qmark_in_macro!(x?);
|
||||
= note: this error originates in the macro `some_and_qmark_in_macro` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: question mark operator is useless here
|
||||
--> $DIR/needless_question_mark.rs:131:5
|
||||
--> $DIR/needless_question_mark.rs:130:5
|
||||
|
|
||||
LL | Some(to.magic?)
|
||||
| ^^^^^^^^^^^^^^^ help: try removing question mark and `Some()`: `to.magic`
|
||||
|
||||
error: question mark operator is useless here
|
||||
--> $DIR/needless_question_mark.rs:139:5
|
||||
--> $DIR/needless_question_mark.rs:138:5
|
||||
|
|
||||
LL | Ok(s.magic?)
|
||||
| ^^^^^^^^^^^^ help: try removing question mark and `Ok()`: `s.magic`
|
||||
|
@ -1,7 +1,6 @@
|
||||
// run-rustfix
|
||||
// edition:2018
|
||||
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![warn(clippy::needless_splitn)]
|
||||
#![allow(clippy::iter_skip_next, clippy::iter_nth_zero, clippy::manual_split_once)]
|
||||
|
||||
@ -40,8 +39,8 @@ fn _question_mark(s: &str) -> Option<()> {
|
||||
Some(())
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.51"]
|
||||
fn _test_msrv() {
|
||||
#![clippy::msrv = "1.51"]
|
||||
// `manual_split_once` MSRV shouldn't apply to `needless_splitn`
|
||||
let _ = "key=value".split('=').nth(0).unwrap();
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
// run-rustfix
|
||||
// edition:2018
|
||||
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![warn(clippy::needless_splitn)]
|
||||
#![allow(clippy::iter_skip_next, clippy::iter_nth_zero, clippy::manual_split_once)]
|
||||
|
||||
@ -40,8 +39,8 @@ fn _question_mark(s: &str) -> Option<()> {
|
||||
Some(())
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.51"]
|
||||
fn _test_msrv() {
|
||||
#![clippy::msrv = "1.51"]
|
||||
// `manual_split_once` MSRV shouldn't apply to `needless_splitn`
|
||||
let _ = "key=value".splitn(2, '=').nth(0).unwrap();
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
error: unnecessary use of `splitn`
|
||||
--> $DIR/needless_splitn.rs:15:13
|
||||
--> $DIR/needless_splitn.rs:14:13
|
||||
|
|
||||
LL | let _ = str.splitn(2, '=').next();
|
||||
| ^^^^^^^^^^^^^^^^^^ help: try this: `str.split('=')`
|
||||
@ -7,73 +7,73 @@ LL | let _ = str.splitn(2, '=').next();
|
||||
= note: `-D clippy::needless-splitn` implied by `-D warnings`
|
||||
|
||||
error: unnecessary use of `splitn`
|
||||
--> $DIR/needless_splitn.rs:16:13
|
||||
--> $DIR/needless_splitn.rs:15:13
|
||||
|
|
||||
LL | let _ = str.splitn(2, '=').nth(0);
|
||||
| ^^^^^^^^^^^^^^^^^^ help: try this: `str.split('=')`
|
||||
|
||||
error: unnecessary use of `splitn`
|
||||
--> $DIR/needless_splitn.rs:19:18
|
||||
--> $DIR/needless_splitn.rs:18:18
|
||||
|
|
||||
LL | let (_, _) = str.splitn(3, '=').next_tuple().unwrap();
|
||||
| ^^^^^^^^^^^^^^^^^^ help: try this: `str.split('=')`
|
||||
|
||||
error: unnecessary use of `rsplitn`
|
||||
--> $DIR/needless_splitn.rs:22:13
|
||||
--> $DIR/needless_splitn.rs:21:13
|
||||
|
|
||||
LL | let _ = str.rsplitn(2, '=').next();
|
||||
| ^^^^^^^^^^^^^^^^^^^ help: try this: `str.rsplit('=')`
|
||||
|
||||
error: unnecessary use of `rsplitn`
|
||||
--> $DIR/needless_splitn.rs:23:13
|
||||
--> $DIR/needless_splitn.rs:22:13
|
||||
|
|
||||
LL | let _ = str.rsplitn(2, '=').nth(0);
|
||||
| ^^^^^^^^^^^^^^^^^^^ help: try this: `str.rsplit('=')`
|
||||
|
||||
error: unnecessary use of `rsplitn`
|
||||
--> $DIR/needless_splitn.rs:26:18
|
||||
--> $DIR/needless_splitn.rs:25:18
|
||||
|
|
||||
LL | let (_, _) = str.rsplitn(3, '=').next_tuple().unwrap();
|
||||
| ^^^^^^^^^^^^^^^^^^^ help: try this: `str.rsplit('=')`
|
||||
|
||||
error: unnecessary use of `splitn`
|
||||
--> $DIR/needless_splitn.rs:28:13
|
||||
--> $DIR/needless_splitn.rs:27:13
|
||||
|
|
||||
LL | let _ = str.splitn(5, '=').next();
|
||||
| ^^^^^^^^^^^^^^^^^^ help: try this: `str.split('=')`
|
||||
|
||||
error: unnecessary use of `splitn`
|
||||
--> $DIR/needless_splitn.rs:29:13
|
||||
--> $DIR/needless_splitn.rs:28:13
|
||||
|
|
||||
LL | let _ = str.splitn(5, '=').nth(3);
|
||||
| ^^^^^^^^^^^^^^^^^^ help: try this: `str.split('=')`
|
||||
|
||||
error: unnecessary use of `splitn`
|
||||
--> $DIR/needless_splitn.rs:35:13
|
||||
--> $DIR/needless_splitn.rs:34:13
|
||||
|
|
||||
LL | let _ = s.splitn(2, '=').next()?;
|
||||
| ^^^^^^^^^^^^^^^^ help: try this: `s.split('=')`
|
||||
|
||||
error: unnecessary use of `splitn`
|
||||
--> $DIR/needless_splitn.rs:36:13
|
||||
--> $DIR/needless_splitn.rs:35:13
|
||||
|
|
||||
LL | let _ = s.splitn(2, '=').nth(0)?;
|
||||
| ^^^^^^^^^^^^^^^^ help: try this: `s.split('=')`
|
||||
|
||||
error: unnecessary use of `rsplitn`
|
||||
--> $DIR/needless_splitn.rs:37:13
|
||||
--> $DIR/needless_splitn.rs:36:13
|
||||
|
|
||||
LL | let _ = s.rsplitn(2, '=').next()?;
|
||||
| ^^^^^^^^^^^^^^^^^ help: try this: `s.rsplit('=')`
|
||||
|
||||
error: unnecessary use of `rsplitn`
|
||||
--> $DIR/needless_splitn.rs:38:13
|
||||
--> $DIR/needless_splitn.rs:37:13
|
||||
|
|
||||
LL | let _ = s.rsplitn(2, '=').nth(0)?;
|
||||
| ^^^^^^^^^^^^^^^^^ help: try this: `s.rsplit('=')`
|
||||
|
||||
error: unnecessary use of `splitn`
|
||||
--> $DIR/needless_splitn.rs:46:13
|
||||
--> $DIR/needless_splitn.rs:45:13
|
||||
|
|
||||
LL | let _ = "key=value".splitn(2, '=').nth(0).unwrap();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `"key=value".split('=')`
|
||||
|
@ -1,6 +1,5 @@
|
||||
// run-rustfix
|
||||
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![allow(unused, clippy::redundant_clone)]
|
||||
#![warn(clippy::option_as_ref_deref)]
|
||||
|
||||
@ -44,16 +43,14 @@ fn main() {
|
||||
let _ = opt.as_deref();
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.39"]
|
||||
fn msrv_1_39() {
|
||||
#![clippy::msrv = "1.39"]
|
||||
|
||||
let opt = Some(String::from("123"));
|
||||
let _ = opt.as_ref().map(String::as_str);
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.40"]
|
||||
fn msrv_1_40() {
|
||||
#![clippy::msrv = "1.40"]
|
||||
|
||||
let opt = Some(String::from("123"));
|
||||
let _ = opt.as_deref();
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
// run-rustfix
|
||||
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![allow(unused, clippy::redundant_clone)]
|
||||
#![warn(clippy::option_as_ref_deref)]
|
||||
|
||||
@ -47,16 +46,14 @@ fn main() {
|
||||
let _ = opt.as_ref().map(std::ops::Deref::deref);
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.39"]
|
||||
fn msrv_1_39() {
|
||||
#![clippy::msrv = "1.39"]
|
||||
|
||||
let opt = Some(String::from("123"));
|
||||
let _ = opt.as_ref().map(String::as_str);
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.40"]
|
||||
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:14:13
|
||||
--> $DIR/option_as_ref_deref.rs:13: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:17:13
|
||||
--> $DIR/option_as_ref_deref.rs:16:13
|
||||
|
|
||||
LL | let _ = opt.clone()
|
||||
| _____________^
|
||||
@ -17,97 +17,97 @@ 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:23:13
|
||||
--> $DIR/option_as_ref_deref.rs:22: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:25:13
|
||||
--> $DIR/option_as_ref_deref.rs:24: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:26:13
|
||||
--> $DIR/option_as_ref_deref.rs:25: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:27:13
|
||||
--> $DIR/option_as_ref_deref.rs:26: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:28:13
|
||||
--> $DIR/option_as_ref_deref.rs:27: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:29:13
|
||||
--> $DIR/option_as_ref_deref.rs:28: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:30:13
|
||||
--> $DIR/option_as_ref_deref.rs:29: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:31:13
|
||||
--> $DIR/option_as_ref_deref.rs:30: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:32:13
|
||||
--> $DIR/option_as_ref_deref.rs:31: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:33:13
|
||||
--> $DIR/option_as_ref_deref.rs:32: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:35:13
|
||||
--> $DIR/option_as_ref_deref.rs:34: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:36:13
|
||||
--> $DIR/option_as_ref_deref.rs:35: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:43:13
|
||||
--> $DIR/option_as_ref_deref.rs:42: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:44:13
|
||||
--> $DIR/option_as_ref_deref.rs:43: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:47:13
|
||||
--> $DIR/option_as_ref_deref.rs:46:13
|
||||
|
|
||||
LL | let _ = opt.as_ref().map(std::ops::Deref::deref);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using as_deref instead: `opt.as_deref()`
|
||||
|
||||
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
|
||||
--> $DIR/option_as_ref_deref.rs:58:13
|
||||
|
|
||||
LL | let _ = opt.as_ref().map(String::as_str);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using as_deref instead: `opt.as_deref()`
|
||||
|
@ -2,7 +2,6 @@
|
||||
// aux-build:macro_rules.rs
|
||||
|
||||
#![warn(clippy::ptr_as_ptr)]
|
||||
#![feature(custom_inner_attributes)]
|
||||
|
||||
extern crate macro_rules;
|
||||
|
||||
@ -45,8 +44,8 @@ fn main() {
|
||||
let _ = macro_rules::ptr_as_ptr_cast!(ptr);
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.37"]
|
||||
fn _msrv_1_37() {
|
||||
#![clippy::msrv = "1.37"]
|
||||
let ptr: *const u32 = &42_u32;
|
||||
let mut_ptr: *mut u32 = &mut 42_u32;
|
||||
|
||||
@ -55,8 +54,8 @@ fn _msrv_1_37() {
|
||||
let _ = mut_ptr as *mut i32;
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.38"]
|
||||
fn _msrv_1_38() {
|
||||
#![clippy::msrv = "1.38"]
|
||||
let ptr: *const u32 = &42_u32;
|
||||
let mut_ptr: *mut u32 = &mut 42_u32;
|
||||
|
||||
|
@ -2,7 +2,6 @@
|
||||
// aux-build:macro_rules.rs
|
||||
|
||||
#![warn(clippy::ptr_as_ptr)]
|
||||
#![feature(custom_inner_attributes)]
|
||||
|
||||
extern crate macro_rules;
|
||||
|
||||
@ -45,8 +44,8 @@ fn main() {
|
||||
let _ = macro_rules::ptr_as_ptr_cast!(ptr);
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.37"]
|
||||
fn _msrv_1_37() {
|
||||
#![clippy::msrv = "1.37"]
|
||||
let ptr: *const u32 = &42_u32;
|
||||
let mut_ptr: *mut u32 = &mut 42_u32;
|
||||
|
||||
@ -55,8 +54,8 @@ fn _msrv_1_37() {
|
||||
let _ = mut_ptr as *mut i32;
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.38"]
|
||||
fn _msrv_1_38() {
|
||||
#![clippy::msrv = "1.38"]
|
||||
let ptr: *const u32 = &42_u32;
|
||||
let mut_ptr: *mut u32 = &mut 42_u32;
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
error: `as` casting between raw pointers without changing its mutability
|
||||
--> $DIR/ptr_as_ptr.rs:19:13
|
||||
--> $DIR/ptr_as_ptr.rs:18:13
|
||||
|
|
||||
LL | let _ = ptr as *const i32;
|
||||
| ^^^^^^^^^^^^^^^^^ help: try `pointer::cast`, a safer alternative: `ptr.cast::<i32>()`
|
||||
@ -7,31 +7,31 @@ LL | let _ = ptr as *const i32;
|
||||
= note: `-D clippy::ptr-as-ptr` implied by `-D warnings`
|
||||
|
||||
error: `as` casting between raw pointers without changing its mutability
|
||||
--> $DIR/ptr_as_ptr.rs:20:13
|
||||
--> $DIR/ptr_as_ptr.rs:19:13
|
||||
|
|
||||
LL | let _ = mut_ptr as *mut i32;
|
||||
| ^^^^^^^^^^^^^^^^^^^ help: try `pointer::cast`, a safer alternative: `mut_ptr.cast::<i32>()`
|
||||
|
||||
error: `as` casting between raw pointers without changing its mutability
|
||||
--> $DIR/ptr_as_ptr.rs:25:17
|
||||
--> $DIR/ptr_as_ptr.rs:24:17
|
||||
|
|
||||
LL | let _ = *ptr_ptr as *const i32;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ help: try `pointer::cast`, a safer alternative: `(*ptr_ptr).cast::<i32>()`
|
||||
|
||||
error: `as` casting between raw pointers without changing its mutability
|
||||
--> $DIR/ptr_as_ptr.rs:38:25
|
||||
--> $DIR/ptr_as_ptr.rs:37:25
|
||||
|
|
||||
LL | let _: *const i32 = ptr as *const _;
|
||||
| ^^^^^^^^^^^^^^^ help: try `pointer::cast`, a safer alternative: `ptr.cast()`
|
||||
|
||||
error: `as` casting between raw pointers without changing its mutability
|
||||
--> $DIR/ptr_as_ptr.rs:39:23
|
||||
--> $DIR/ptr_as_ptr.rs:38:23
|
||||
|
|
||||
LL | let _: *mut i32 = mut_ptr as _;
|
||||
| ^^^^^^^^^^^^ help: try `pointer::cast`, a safer alternative: `mut_ptr.cast()`
|
||||
|
||||
error: `as` casting between raw pointers without changing its mutability
|
||||
--> $DIR/ptr_as_ptr.rs:11:9
|
||||
--> $DIR/ptr_as_ptr.rs:10:9
|
||||
|
|
||||
LL | $ptr as *const i32
|
||||
| ^^^^^^^^^^^^^^^^^^ help: try `pointer::cast`, a safer alternative: `$ptr.cast::<i32>()`
|
||||
@ -42,13 +42,13 @@ LL | let _ = cast_it!(ptr);
|
||||
= note: this error originates in the macro `cast_it` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: `as` casting between raw pointers without changing its mutability
|
||||
--> $DIR/ptr_as_ptr.rs:63:13
|
||||
--> $DIR/ptr_as_ptr.rs:62:13
|
||||
|
|
||||
LL | let _ = ptr as *const i32;
|
||||
| ^^^^^^^^^^^^^^^^^ help: try `pointer::cast`, a safer alternative: `ptr.cast::<i32>()`
|
||||
|
||||
error: `as` casting between raw pointers without changing its mutability
|
||||
--> $DIR/ptr_as_ptr.rs:64:13
|
||||
--> $DIR/ptr_as_ptr.rs:63:13
|
||||
|
|
||||
LL | let _ = mut_ptr as *mut i32;
|
||||
| ^^^^^^^^^^^^^^^^^^^ help: try `pointer::cast`, a safer alternative: `mut_ptr.cast::<i32>()`
|
||||
|
@ -1,6 +1,5 @@
|
||||
// run-rustfix
|
||||
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![warn(clippy::manual_range_contains)]
|
||||
#![allow(unused)]
|
||||
#![allow(clippy::no_effect)]
|
||||
@ -65,16 +64,14 @@ pub const fn in_range(a: i32) -> bool {
|
||||
3 <= a && a <= 20
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.34"]
|
||||
fn msrv_1_34() {
|
||||
#![clippy::msrv = "1.34"]
|
||||
|
||||
let x = 5;
|
||||
x >= 8 && x < 34;
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.35"]
|
||||
fn msrv_1_35() {
|
||||
#![clippy::msrv = "1.35"]
|
||||
|
||||
let x = 5;
|
||||
(8..35).contains(&x);
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
// run-rustfix
|
||||
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![warn(clippy::manual_range_contains)]
|
||||
#![allow(unused)]
|
||||
#![allow(clippy::no_effect)]
|
||||
@ -65,16 +64,14 @@ pub const fn in_range(a: i32) -> bool {
|
||||
3 <= a && a <= 20
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.34"]
|
||||
fn msrv_1_34() {
|
||||
#![clippy::msrv = "1.34"]
|
||||
|
||||
let x = 5;
|
||||
x >= 8 && x < 34;
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.35"]
|
||||
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:14:5
|
||||
--> $DIR/range_contains.rs:13:5
|
||||
|
|
||||
LL | x >= 8 && x < 12;
|
||||
| ^^^^^^^^^^^^^^^^ help: use: `(8..12).contains(&x)`
|
||||
@ -7,121 +7,121 @@ LL | x >= 8 && x < 12;
|
||||
= note: `-D clippy::manual-range-contains` implied by `-D warnings`
|
||||
|
||||
error: manual `Range::contains` implementation
|
||||
--> $DIR/range_contains.rs:15:5
|
||||
--> $DIR/range_contains.rs:14:5
|
||||
|
|
||||
LL | x < 42 && x >= 21;
|
||||
| ^^^^^^^^^^^^^^^^^ help: use: `(21..42).contains(&x)`
|
||||
|
||||
error: manual `Range::contains` implementation
|
||||
--> $DIR/range_contains.rs:16:5
|
||||
--> $DIR/range_contains.rs:15:5
|
||||
|
|
||||
LL | 100 > x && 1 <= x;
|
||||
| ^^^^^^^^^^^^^^^^^ help: use: `(1..100).contains(&x)`
|
||||
|
||||
error: manual `RangeInclusive::contains` implementation
|
||||
--> $DIR/range_contains.rs:19:5
|
||||
--> $DIR/range_contains.rs:18:5
|
||||
|
|
||||
LL | x >= 9 && x <= 99;
|
||||
| ^^^^^^^^^^^^^^^^^ help: use: `(9..=99).contains(&x)`
|
||||
|
||||
error: manual `RangeInclusive::contains` implementation
|
||||
--> $DIR/range_contains.rs:20:5
|
||||
--> $DIR/range_contains.rs:19:5
|
||||
|
|
||||
LL | x <= 33 && x >= 1;
|
||||
| ^^^^^^^^^^^^^^^^^ help: use: `(1..=33).contains(&x)`
|
||||
|
||||
error: manual `RangeInclusive::contains` implementation
|
||||
--> $DIR/range_contains.rs:21:5
|
||||
--> $DIR/range_contains.rs:20:5
|
||||
|
|
||||
LL | 999 >= x && 1 <= x;
|
||||
| ^^^^^^^^^^^^^^^^^^ help: use: `(1..=999).contains(&x)`
|
||||
|
||||
error: manual `!Range::contains` implementation
|
||||
--> $DIR/range_contains.rs:24:5
|
||||
--> $DIR/range_contains.rs:23:5
|
||||
|
|
||||
LL | x < 8 || x >= 12;
|
||||
| ^^^^^^^^^^^^^^^^ help: use: `!(8..12).contains(&x)`
|
||||
|
||||
error: manual `!Range::contains` implementation
|
||||
--> $DIR/range_contains.rs:25:5
|
||||
--> $DIR/range_contains.rs:24:5
|
||||
|
|
||||
LL | x >= 42 || x < 21;
|
||||
| ^^^^^^^^^^^^^^^^^ help: use: `!(21..42).contains(&x)`
|
||||
|
||||
error: manual `!Range::contains` implementation
|
||||
--> $DIR/range_contains.rs:26:5
|
||||
--> $DIR/range_contains.rs:25:5
|
||||
|
|
||||
LL | 100 <= x || 1 > x;
|
||||
| ^^^^^^^^^^^^^^^^^ help: use: `!(1..100).contains(&x)`
|
||||
|
||||
error: manual `!RangeInclusive::contains` implementation
|
||||
--> $DIR/range_contains.rs:29:5
|
||||
--> $DIR/range_contains.rs:28:5
|
||||
|
|
||||
LL | x < 9 || x > 99;
|
||||
| ^^^^^^^^^^^^^^^ help: use: `!(9..=99).contains(&x)`
|
||||
|
||||
error: manual `!RangeInclusive::contains` implementation
|
||||
--> $DIR/range_contains.rs:30:5
|
||||
--> $DIR/range_contains.rs:29:5
|
||||
|
|
||||
LL | x > 33 || x < 1;
|
||||
| ^^^^^^^^^^^^^^^ help: use: `!(1..=33).contains(&x)`
|
||||
|
||||
error: manual `!RangeInclusive::contains` implementation
|
||||
--> $DIR/range_contains.rs:31:5
|
||||
--> $DIR/range_contains.rs:30:5
|
||||
|
|
||||
LL | 999 < x || 1 > x;
|
||||
| ^^^^^^^^^^^^^^^^ help: use: `!(1..=999).contains(&x)`
|
||||
|
||||
error: manual `Range::contains` implementation
|
||||
--> $DIR/range_contains.rs:46:5
|
||||
--> $DIR/range_contains.rs:45:5
|
||||
|
|
||||
LL | y >= 0. && y < 1.;
|
||||
| ^^^^^^^^^^^^^^^^^ help: use: `(0. ..1.).contains(&y)`
|
||||
|
||||
error: manual `!RangeInclusive::contains` implementation
|
||||
--> $DIR/range_contains.rs:47: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:50:5
|
||||
--> $DIR/range_contains.rs:49:5
|
||||
|
|
||||
LL | x >= -10 && x <= 10;
|
||||
| ^^^^^^^^^^^^^^^^^^^ help: use: `(-10..=10).contains(&x)`
|
||||
|
||||
error: manual `RangeInclusive::contains` implementation
|
||||
--> $DIR/range_contains.rs:52:5
|
||||
--> $DIR/range_contains.rs:51:5
|
||||
|
|
||||
LL | y >= -3. && y <= 3.;
|
||||
| ^^^^^^^^^^^^^^^^^^^ help: use: `(-3. ..=3.).contains(&y)`
|
||||
|
||||
error: manual `RangeInclusive::contains` implementation
|
||||
--> $DIR/range_contains.rs:57:30
|
||||
--> $DIR/range_contains.rs:56: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:57:5
|
||||
--> $DIR/range_contains.rs:56: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:58:29
|
||||
--> $DIR/range_contains.rs:57: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:58: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:79:5
|
||||
--> $DIR/range_contains.rs:76:5
|
||||
|
|
||||
LL | x >= 8 && x < 35;
|
||||
| ^^^^^^^^^^^^^^^^ help: use: `(8..35).contains(&x)`
|
||||
|
@ -1,6 +1,5 @@
|
||||
// run-rustfix
|
||||
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![warn(clippy::redundant_field_names)]
|
||||
#![allow(clippy::no_effect, dead_code, unused_variables)]
|
||||
|
||||
@ -72,16 +71,14 @@ fn issue_3476() {
|
||||
S { foo: foo::<i32> };
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.16"]
|
||||
fn msrv_1_16() {
|
||||
#![clippy::msrv = "1.16"]
|
||||
|
||||
let start = 0;
|
||||
let _ = RangeFrom { start: start };
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.17"]
|
||||
fn msrv_1_17() {
|
||||
#![clippy::msrv = "1.17"]
|
||||
|
||||
let start = 0;
|
||||
let _ = RangeFrom { start };
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
// run-rustfix
|
||||
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![warn(clippy::redundant_field_names)]
|
||||
#![allow(clippy::no_effect, dead_code, unused_variables)]
|
||||
|
||||
@ -72,16 +71,14 @@ fn issue_3476() {
|
||||
S { foo: foo::<i32> };
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.16"]
|
||||
fn msrv_1_16() {
|
||||
#![clippy::msrv = "1.16"]
|
||||
|
||||
let start = 0;
|
||||
let _ = RangeFrom { start: start };
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.17"]
|
||||
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:36:9
|
||||
--> $DIR/redundant_field_names.rs:35:9
|
||||
|
|
||||
LL | gender: gender,
|
||||
| ^^^^^^^^^^^^^^ help: replace it with: `gender`
|
||||
@ -7,43 +7,43 @@ 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:37:9
|
||||
--> $DIR/redundant_field_names.rs:36:9
|
||||
|
|
||||
LL | age: age,
|
||||
| ^^^^^^^^ help: replace it with: `age`
|
||||
|
||||
error: redundant field names in struct initialization
|
||||
--> $DIR/redundant_field_names.rs:58:25
|
||||
--> $DIR/redundant_field_names.rs:57:25
|
||||
|
|
||||
LL | let _ = RangeFrom { start: start };
|
||||
| ^^^^^^^^^^^^ help: replace it with: `start`
|
||||
|
||||
error: redundant field names in struct initialization
|
||||
--> $DIR/redundant_field_names.rs:59:23
|
||||
--> $DIR/redundant_field_names.rs:58:23
|
||||
|
|
||||
LL | let _ = RangeTo { end: end };
|
||||
| ^^^^^^^^ help: replace it with: `end`
|
||||
|
||||
error: redundant field names in struct initialization
|
||||
--> $DIR/redundant_field_names.rs:60:21
|
||||
--> $DIR/redundant_field_names.rs:59: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:60:35
|
||||
--> $DIR/redundant_field_names.rs:59: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:62:32
|
||||
--> $DIR/redundant_field_names.rs:61:32
|
||||
|
|
||||
LL | let _ = RangeToInclusive { end: end };
|
||||
| ^^^^^^^^ help: replace it with: `end`
|
||||
|
||||
error: redundant field names in struct initialization
|
||||
--> $DIR/redundant_field_names.rs:86:25
|
||||
--> $DIR/redundant_field_names.rs:83:25
|
||||
|
|
||||
LL | let _ = RangeFrom { start: start };
|
||||
| ^^^^^^^^^^^^ help: replace it with: `start`
|
||||
|
@ -1,6 +1,5 @@
|
||||
// run-rustfix
|
||||
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![allow(unused)]
|
||||
|
||||
#[derive(Debug)]
|
||||
@ -56,14 +55,12 @@ impl Bar for Foo {
|
||||
const TRAIT_VAR: &'static str = "foo";
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.16"]
|
||||
fn msrv_1_16() {
|
||||
#![clippy::msrv = "1.16"]
|
||||
|
||||
static V: &'static u8 = &16;
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.17"]
|
||||
fn msrv_1_17() {
|
||||
#![clippy::msrv = "1.17"]
|
||||
|
||||
static V: &u8 = &17;
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
// run-rustfix
|
||||
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![allow(unused)]
|
||||
|
||||
#[derive(Debug)]
|
||||
@ -56,14 +55,12 @@ impl Bar for Foo {
|
||||
const TRAIT_VAR: &'static str = "foo";
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.16"]
|
||||
fn msrv_1_16() {
|
||||
#![clippy::msrv = "1.16"]
|
||||
|
||||
static V: &'static u8 = &16;
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.17"]
|
||||
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:9:17
|
||||
--> $DIR/redundant_static_lifetimes.rs:8:17
|
||||
|
|
||||
LL | const VAR_ONE: &'static str = "Test constant #1"; // ERROR Consider removing 'static.
|
||||
| -^^^^^^^---- help: consider removing `'static`: `&str`
|
||||
@ -7,97 +7,97 @@ 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:13:21
|
||||
--> $DIR/redundant_static_lifetimes.rs:12: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:15:32
|
||||
--> $DIR/redundant_static_lifetimes.rs:14: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:15:47
|
||||
--> $DIR/redundant_static_lifetimes.rs:14: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:17:17
|
||||
--> $DIR/redundant_static_lifetimes.rs:16: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:19:20
|
||||
--> $DIR/redundant_static_lifetimes.rs:18: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:21:19
|
||||
--> $DIR/redundant_static_lifetimes.rs:20: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:23:19
|
||||
--> $DIR/redundant_static_lifetimes.rs:22: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:25:19
|
||||
--> $DIR/redundant_static_lifetimes.rs:24: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:27:25
|
||||
--> $DIR/redundant_static_lifetimes.rs:26: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:31:29
|
||||
--> $DIR/redundant_static_lifetimes.rs:30: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:33:25
|
||||
--> $DIR/redundant_static_lifetimes.rs:32: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:35:28
|
||||
--> $DIR/redundant_static_lifetimes.rs:34: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:37:27
|
||||
--> $DIR/redundant_static_lifetimes.rs:36: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:39:27
|
||||
--> $DIR/redundant_static_lifetimes.rs:38: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:41:27
|
||||
--> $DIR/redundant_static_lifetimes.rs:40:27
|
||||
|
|
||||
LL | static STATIC_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:68:16
|
||||
--> $DIR/redundant_static_lifetimes.rs:65:16
|
||||
|
|
||||
LL | static V: &'static u8 = &17;
|
||||
| -^^^^^^^--- help: consider removing `'static`: `&u8`
|
||||
|
@ -1,12 +1,11 @@
|
||||
// run-rustfix
|
||||
#![warn(clippy::seek_from_current)]
|
||||
#![feature(custom_inner_attributes)]
|
||||
|
||||
use std::fs::File;
|
||||
use std::io::{self, Seek, SeekFrom, Write};
|
||||
|
||||
#[clippy::msrv = "1.50"]
|
||||
fn _msrv_1_50() -> io::Result<()> {
|
||||
#![clippy::msrv = "1.50"]
|
||||
let mut f = File::create("foo.txt")?;
|
||||
f.write_all(b"Hi!")?;
|
||||
f.seek(SeekFrom::Current(0))?;
|
||||
@ -14,8 +13,8 @@ fn _msrv_1_50() -> io::Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.51"]
|
||||
fn _msrv_1_51() -> io::Result<()> {
|
||||
#![clippy::msrv = "1.51"]
|
||||
let mut f = File::create("foo.txt")?;
|
||||
f.write_all(b"Hi!")?;
|
||||
f.stream_position()?;
|
||||
|
@ -1,12 +1,11 @@
|
||||
// run-rustfix
|
||||
#![warn(clippy::seek_from_current)]
|
||||
#![feature(custom_inner_attributes)]
|
||||
|
||||
use std::fs::File;
|
||||
use std::io::{self, Seek, SeekFrom, Write};
|
||||
|
||||
#[clippy::msrv = "1.50"]
|
||||
fn _msrv_1_50() -> io::Result<()> {
|
||||
#![clippy::msrv = "1.50"]
|
||||
let mut f = File::create("foo.txt")?;
|
||||
f.write_all(b"Hi!")?;
|
||||
f.seek(SeekFrom::Current(0))?;
|
||||
@ -14,8 +13,8 @@ fn _msrv_1_50() -> io::Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.51"]
|
||||
fn _msrv_1_51() -> io::Result<()> {
|
||||
#![clippy::msrv = "1.51"]
|
||||
let mut f = File::create("foo.txt")?;
|
||||
f.write_all(b"Hi!")?;
|
||||
f.seek(SeekFrom::Current(0))?;
|
||||
|
@ -1,5 +1,5 @@
|
||||
error: using `SeekFrom::Current` to start from current position
|
||||
--> $DIR/seek_from_current.rs:21:5
|
||||
--> $DIR/seek_from_current.rs:20:5
|
||||
|
|
||||
LL | f.seek(SeekFrom::Current(0))?;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `f.stream_position()`
|
||||
|
@ -1,6 +1,5 @@
|
||||
// run-rustfix
|
||||
#![allow(unused)]
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![warn(clippy::seek_to_start_instead_of_rewind)]
|
||||
|
||||
use std::fs::OpenOptions;
|
||||
@ -94,9 +93,8 @@ fn main() {
|
||||
assert_eq!(&buf, hello);
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.54"]
|
||||
fn msrv_1_54() {
|
||||
#![clippy::msrv = "1.54"]
|
||||
|
||||
let mut f = OpenOptions::new()
|
||||
.write(true)
|
||||
.read(true)
|
||||
@ -115,9 +113,8 @@ fn msrv_1_54() {
|
||||
assert_eq!(&buf, hello);
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.55"]
|
||||
fn msrv_1_55() {
|
||||
#![clippy::msrv = "1.55"]
|
||||
|
||||
let mut f = OpenOptions::new()
|
||||
.write(true)
|
||||
.read(true)
|
||||
|
@ -1,6 +1,5 @@
|
||||
// run-rustfix
|
||||
#![allow(unused)]
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![warn(clippy::seek_to_start_instead_of_rewind)]
|
||||
|
||||
use std::fs::OpenOptions;
|
||||
@ -94,9 +93,8 @@ fn main() {
|
||||
assert_eq!(&buf, hello);
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.54"]
|
||||
fn msrv_1_54() {
|
||||
#![clippy::msrv = "1.54"]
|
||||
|
||||
let mut f = OpenOptions::new()
|
||||
.write(true)
|
||||
.read(true)
|
||||
@ -115,9 +113,8 @@ fn msrv_1_54() {
|
||||
assert_eq!(&buf, hello);
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.55"]
|
||||
fn msrv_1_55() {
|
||||
#![clippy::msrv = "1.55"]
|
||||
|
||||
let mut f = OpenOptions::new()
|
||||
.write(true)
|
||||
.read(true)
|
||||
|
@ -1,5 +1,5 @@
|
||||
error: used `seek` to go to the start of the stream
|
||||
--> $DIR/seek_to_start_instead_of_rewind.rs:54:7
|
||||
--> $DIR/seek_to_start_instead_of_rewind.rs:53:7
|
||||
|
|
||||
LL | t.seek(SeekFrom::Start(0));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `rewind()`
|
||||
@ -7,13 +7,13 @@ LL | t.seek(SeekFrom::Start(0));
|
||||
= note: `-D clippy::seek-to-start-instead-of-rewind` implied by `-D warnings`
|
||||
|
||||
error: used `seek` to go to the start of the stream
|
||||
--> $DIR/seek_to_start_instead_of_rewind.rs:59:7
|
||||
--> $DIR/seek_to_start_instead_of_rewind.rs:58:7
|
||||
|
|
||||
LL | t.seek(SeekFrom::Start(0));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `rewind()`
|
||||
|
||||
error: used `seek` to go to the start of the stream
|
||||
--> $DIR/seek_to_start_instead_of_rewind.rs:131:7
|
||||
--> $DIR/seek_to_start_instead_of_rewind.rs:128:7
|
||||
|
|
||||
LL | f.seek(SeekFrom::Start(0));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `rewind()`
|
||||
|
@ -1,6 +1,5 @@
|
||||
// run-rustfix
|
||||
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![warn(clippy::transmute_ptr_to_ref)]
|
||||
#![allow(clippy::match_single_binding)]
|
||||
|
||||
@ -51,8 +50,8 @@ unsafe fn _issue8924<'a, 'b, 'c>(x: *const &'a u32, y: *const &'b u32) -> &'c &'
|
||||
}
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.38"]
|
||||
unsafe fn _meets_msrv<'a, 'b, 'c>(x: *const &'a u32) -> &'c &'b u32 {
|
||||
#![clippy::msrv = "1.38"]
|
||||
let a = 0u32;
|
||||
let a = &a as *const u32;
|
||||
let _: &u32 = &*a;
|
||||
@ -63,8 +62,8 @@ unsafe fn _meets_msrv<'a, 'b, 'c>(x: *const &'a u32) -> &'c &'b u32 {
|
||||
}
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.37"]
|
||||
unsafe fn _under_msrv<'a, 'b, 'c>(x: *const &'a u32) -> &'c &'b u32 {
|
||||
#![clippy::msrv = "1.37"]
|
||||
let a = 0u32;
|
||||
let a = &a as *const u32;
|
||||
let _: &u32 = &*a;
|
||||
|
@ -1,6 +1,5 @@
|
||||
// run-rustfix
|
||||
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![warn(clippy::transmute_ptr_to_ref)]
|
||||
#![allow(clippy::match_single_binding)]
|
||||
|
||||
@ -51,8 +50,8 @@ unsafe fn _issue8924<'a, 'b, 'c>(x: *const &'a u32, y: *const &'b u32) -> &'c &'
|
||||
}
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.38"]
|
||||
unsafe fn _meets_msrv<'a, 'b, 'c>(x: *const &'a u32) -> &'c &'b u32 {
|
||||
#![clippy::msrv = "1.38"]
|
||||
let a = 0u32;
|
||||
let a = &a as *const u32;
|
||||
let _: &u32 = std::mem::transmute(a);
|
||||
@ -63,8 +62,8 @@ unsafe fn _meets_msrv<'a, 'b, 'c>(x: *const &'a u32) -> &'c &'b u32 {
|
||||
}
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.37"]
|
||||
unsafe fn _under_msrv<'a, 'b, 'c>(x: *const &'a u32) -> &'c &'b u32 {
|
||||
#![clippy::msrv = "1.37"]
|
||||
let a = 0u32;
|
||||
let a = &a as *const u32;
|
||||
let _: &u32 = std::mem::transmute(a);
|
||||
|
@ -1,5 +1,5 @@
|
||||
error: transmute from a pointer type (`*const T`) to a reference type (`&T`)
|
||||
--> $DIR/transmute_ptr_to_ref.rs:8:17
|
||||
--> $DIR/transmute_ptr_to_ref.rs:7:17
|
||||
|
|
||||
LL | let _: &T = std::mem::transmute(p);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*p`
|
||||
@ -7,127 +7,127 @@ LL | let _: &T = std::mem::transmute(p);
|
||||
= note: `-D clippy::transmute-ptr-to-ref` implied by `-D warnings`
|
||||
|
||||
error: transmute from a pointer type (`*mut T`) to a reference type (`&mut T`)
|
||||
--> $DIR/transmute_ptr_to_ref.rs:11:21
|
||||
--> $DIR/transmute_ptr_to_ref.rs:10:21
|
||||
|
|
||||
LL | let _: &mut T = std::mem::transmute(m);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ help: try: `&mut *m`
|
||||
|
||||
error: transmute from a pointer type (`*mut T`) to a reference type (`&T`)
|
||||
--> $DIR/transmute_ptr_to_ref.rs:14:17
|
||||
--> $DIR/transmute_ptr_to_ref.rs:13:17
|
||||
|
|
||||
LL | let _: &T = std::mem::transmute(m);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*m`
|
||||
|
||||
error: transmute from a pointer type (`*mut T`) to a reference type (`&mut T`)
|
||||
--> $DIR/transmute_ptr_to_ref.rs:17:21
|
||||
--> $DIR/transmute_ptr_to_ref.rs:16:21
|
||||
|
|
||||
LL | let _: &mut T = std::mem::transmute(p as *mut T);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&mut *(p as *mut T)`
|
||||
|
||||
error: transmute from a pointer type (`*const U`) to a reference type (`&T`)
|
||||
--> $DIR/transmute_ptr_to_ref.rs:20:17
|
||||
--> $DIR/transmute_ptr_to_ref.rs:19:17
|
||||
|
|
||||
LL | let _: &T = std::mem::transmute(o);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(o as *const T)`
|
||||
|
||||
error: transmute from a pointer type (`*mut U`) to a reference type (`&mut T`)
|
||||
--> $DIR/transmute_ptr_to_ref.rs:23:21
|
||||
--> $DIR/transmute_ptr_to_ref.rs:22:21
|
||||
|
|
||||
LL | let _: &mut T = std::mem::transmute(om);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&mut *(om as *mut T)`
|
||||
|
||||
error: transmute from a pointer type (`*mut U`) to a reference type (`&T`)
|
||||
--> $DIR/transmute_ptr_to_ref.rs:26:17
|
||||
--> $DIR/transmute_ptr_to_ref.rs:25:17
|
||||
|
|
||||
LL | let _: &T = std::mem::transmute(om);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(om as *const T)`
|
||||
|
||||
error: transmute from a pointer type (`*const i32`) to a reference type (`&_issue1231::Foo<'_, u8>`)
|
||||
--> $DIR/transmute_ptr_to_ref.rs:36:32
|
||||
--> $DIR/transmute_ptr_to_ref.rs:35:32
|
||||
|
|
||||
LL | let _: &Foo<u8> = unsafe { std::mem::transmute::<_, &Foo<_>>(raw) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*raw.cast::<Foo<_>>()`
|
||||
|
||||
error: transmute from a pointer type (`*const i32`) to a reference type (`&_issue1231::Foo<'_, &u8>`)
|
||||
--> $DIR/transmute_ptr_to_ref.rs:38:33
|
||||
--> $DIR/transmute_ptr_to_ref.rs:37:33
|
||||
|
|
||||
LL | let _: &Foo<&u8> = unsafe { std::mem::transmute::<_, &Foo<&_>>(raw) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*raw.cast::<Foo<&_>>()`
|
||||
|
||||
error: transmute from a pointer type (`*const i32`) to a reference type (`&u8`)
|
||||
--> $DIR/transmute_ptr_to_ref.rs:42:14
|
||||
--> $DIR/transmute_ptr_to_ref.rs:41:14
|
||||
|
|
||||
LL | unsafe { std::mem::transmute::<_, Bar>(raw) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(raw as *const u8)`
|
||||
|
||||
error: transmute from a pointer type (`*const &u32`) to a reference type (`&&u32`)
|
||||
--> $DIR/transmute_ptr_to_ref.rs:47:14
|
||||
--> $DIR/transmute_ptr_to_ref.rs:46:14
|
||||
|
|
||||
LL | 0 => std::mem::transmute(x),
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*x.cast::<&u32>()`
|
||||
|
||||
error: transmute from a pointer type (`*const &u32`) to a reference type (`&&u32`)
|
||||
--> $DIR/transmute_ptr_to_ref.rs:48:14
|
||||
--> $DIR/transmute_ptr_to_ref.rs:47:14
|
||||
|
|
||||
LL | 1 => std::mem::transmute(y),
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*y.cast::<&u32>()`
|
||||
|
||||
error: transmute from a pointer type (`*const &u32`) to a reference type (`&&u32`)
|
||||
--> $DIR/transmute_ptr_to_ref.rs:49:14
|
||||
--> $DIR/transmute_ptr_to_ref.rs:48:14
|
||||
|
|
||||
LL | 2 => std::mem::transmute::<_, &&'b u32>(x),
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*x.cast::<&'b u32>()`
|
||||
|
||||
error: transmute from a pointer type (`*const &u32`) to a reference type (`&&u32`)
|
||||
--> $DIR/transmute_ptr_to_ref.rs:50:14
|
||||
--> $DIR/transmute_ptr_to_ref.rs:49:14
|
||||
|
|
||||
LL | _ => std::mem::transmute::<_, &&'b u32>(y),
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*y.cast::<&'b u32>()`
|
||||
|
||||
error: transmute from a pointer type (`*const u32`) to a reference type (`&u32`)
|
||||
--> $DIR/transmute_ptr_to_ref.rs:58:19
|
||||
--> $DIR/transmute_ptr_to_ref.rs:57:19
|
||||
|
|
||||
LL | let _: &u32 = std::mem::transmute(a);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*a`
|
||||
|
||||
error: transmute from a pointer type (`*const u32`) to a reference type (`&u32`)
|
||||
--> $DIR/transmute_ptr_to_ref.rs:59:19
|
||||
--> $DIR/transmute_ptr_to_ref.rs:58:19
|
||||
|
|
||||
LL | let _: &u32 = std::mem::transmute::<_, &u32>(a);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*a.cast::<u32>()`
|
||||
|
||||
error: transmute from a pointer type (`*const &u32`) to a reference type (`&&u32`)
|
||||
--> $DIR/transmute_ptr_to_ref.rs:61:14
|
||||
--> $DIR/transmute_ptr_to_ref.rs:60:14
|
||||
|
|
||||
LL | 0 => std::mem::transmute(x),
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*x.cast::<&u32>()`
|
||||
|
||||
error: transmute from a pointer type (`*const &u32`) to a reference type (`&&u32`)
|
||||
--> $DIR/transmute_ptr_to_ref.rs:62:14
|
||||
--> $DIR/transmute_ptr_to_ref.rs:61:14
|
||||
|
|
||||
LL | _ => std::mem::transmute::<_, &&'b u32>(x),
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*x.cast::<&'b u32>()`
|
||||
|
||||
error: transmute from a pointer type (`*const u32`) to a reference type (`&u32`)
|
||||
--> $DIR/transmute_ptr_to_ref.rs:70:19
|
||||
--> $DIR/transmute_ptr_to_ref.rs:69:19
|
||||
|
|
||||
LL | let _: &u32 = std::mem::transmute(a);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*a`
|
||||
|
||||
error: transmute from a pointer type (`*const u32`) to a reference type (`&u32`)
|
||||
--> $DIR/transmute_ptr_to_ref.rs:71:19
|
||||
--> $DIR/transmute_ptr_to_ref.rs:70:19
|
||||
|
|
||||
LL | let _: &u32 = std::mem::transmute::<_, &u32>(a);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(a as *const u32)`
|
||||
|
||||
error: transmute from a pointer type (`*const &u32`) to a reference type (`&&u32`)
|
||||
--> $DIR/transmute_ptr_to_ref.rs:73:14
|
||||
--> $DIR/transmute_ptr_to_ref.rs:72:14
|
||||
|
|
||||
LL | 0 => std::mem::transmute(x),
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(x as *const () as *const &u32)`
|
||||
|
||||
error: transmute from a pointer type (`*const &u32`) to a reference type (`&&u32`)
|
||||
--> $DIR/transmute_ptr_to_ref.rs:74:14
|
||||
--> $DIR/transmute_ptr_to_ref.rs:73:14
|
||||
|
|
||||
LL | _ => std::mem::transmute::<_, &&'b u32>(x),
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(x as *const () as *const &'b u32)`
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user