Merge commit '93f0a9a91f' into clippy-subtree-update
This commit is contained in:
parent
0901b9fecf
commit
7e83df4068
155 changed files with 4359 additions and 2646 deletions
222
tests/ui/assigning_clones.fixed
Normal file
222
tests/ui/assigning_clones.fixed
Normal file
|
|
@ -0,0 +1,222 @@
|
|||
#![allow(unused)]
|
||||
#![allow(clippy::redundant_clone)]
|
||||
#![allow(clippy::ptr_arg)] // https://github.com/rust-lang/rust-clippy/issues/10612
|
||||
#![allow(clippy::needless_late_init)]
|
||||
#![allow(clippy::box_collection)]
|
||||
#![warn(clippy::assigning_clones)]
|
||||
|
||||
use std::borrow::ToOwned;
|
||||
use std::ops::{Add, Deref, DerefMut};
|
||||
|
||||
// Clone
|
||||
pub struct HasCloneFrom;
|
||||
|
||||
impl Clone for HasCloneFrom {
|
||||
fn clone(&self) -> Self {
|
||||
Self
|
||||
}
|
||||
fn clone_from(&mut self, source: &Self) {
|
||||
*self = HasCloneFrom;
|
||||
}
|
||||
}
|
||||
|
||||
fn clone_method_rhs_val(mut_thing: &mut HasCloneFrom, value_thing: HasCloneFrom) {
|
||||
mut_thing.clone_from(&value_thing);
|
||||
}
|
||||
|
||||
fn clone_method_rhs_ref(mut_thing: &mut HasCloneFrom, ref_thing: &HasCloneFrom) {
|
||||
mut_thing.clone_from(ref_thing);
|
||||
}
|
||||
|
||||
fn clone_method_lhs_val(mut mut_thing: HasCloneFrom, ref_thing: &HasCloneFrom) {
|
||||
mut_thing.clone_from(ref_thing);
|
||||
}
|
||||
|
||||
fn clone_function_lhs_mut_ref(mut_thing: &mut HasCloneFrom, ref_thing: &HasCloneFrom) {
|
||||
Clone::clone_from(mut_thing, ref_thing);
|
||||
}
|
||||
|
||||
fn clone_function_lhs_val(mut mut_thing: HasCloneFrom, ref_thing: &HasCloneFrom) {
|
||||
Clone::clone_from(&mut mut_thing, ref_thing);
|
||||
}
|
||||
|
||||
fn clone_function_through_trait(mut_thing: &mut HasCloneFrom, ref_thing: &HasCloneFrom) {
|
||||
Clone::clone_from(mut_thing, ref_thing);
|
||||
}
|
||||
|
||||
fn clone_function_through_type(mut_thing: &mut HasCloneFrom, ref_thing: &HasCloneFrom) {
|
||||
Clone::clone_from(mut_thing, ref_thing);
|
||||
}
|
||||
|
||||
fn clone_function_fully_qualified(mut_thing: &mut HasCloneFrom, ref_thing: &HasCloneFrom) {
|
||||
Clone::clone_from(mut_thing, ref_thing);
|
||||
}
|
||||
|
||||
fn clone_method_lhs_complex(mut_thing: &mut HasCloneFrom, ref_thing: &HasCloneFrom) {
|
||||
// These parens should be kept as necessary for a receiver
|
||||
(mut_thing + &mut HasCloneFrom).clone_from(ref_thing);
|
||||
}
|
||||
|
||||
fn clone_method_rhs_complex(mut_thing: &mut HasCloneFrom, ref_thing: &HasCloneFrom) {
|
||||
// These parens should be removed since they are not needed in a function argument
|
||||
mut_thing.clone_from(ref_thing + ref_thing);
|
||||
}
|
||||
|
||||
fn assign_to_init_mut_var(b: HasCloneFrom) -> HasCloneFrom {
|
||||
let mut a = HasCloneFrom;
|
||||
for _ in 1..10 {
|
||||
a.clone_from(&b);
|
||||
}
|
||||
a
|
||||
}
|
||||
|
||||
fn assign_to_late_init_mut_var(b: HasCloneFrom) {
|
||||
let mut a;
|
||||
a = HasCloneFrom;
|
||||
a = b.clone();
|
||||
}
|
||||
|
||||
fn assign_to_uninit_var(b: HasCloneFrom) {
|
||||
let a;
|
||||
a = b.clone();
|
||||
}
|
||||
|
||||
fn assign_to_uninit_mut_var(b: HasCloneFrom) {
|
||||
let mut a;
|
||||
a = b.clone();
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct HasDeriveClone;
|
||||
|
||||
fn ignore_derive_clone(a: &mut HasDeriveClone, b: &HasDeriveClone) {
|
||||
// Should not be linted, since the Clone impl is derived
|
||||
*a = b.clone();
|
||||
}
|
||||
|
||||
pub struct HasCloneImpl;
|
||||
|
||||
impl Clone for HasCloneImpl {
|
||||
fn clone(&self) -> Self {
|
||||
Self
|
||||
}
|
||||
}
|
||||
|
||||
fn ignore_missing_clone_from(a: &mut HasCloneImpl, b: &HasCloneImpl) {
|
||||
// Should not be linted, since the Clone impl doesn't override clone_from
|
||||
*a = b.clone();
|
||||
}
|
||||
|
||||
struct FakeClone;
|
||||
|
||||
impl FakeClone {
|
||||
/// This looks just like `Clone::clone`
|
||||
fn clone(&self) -> Self {
|
||||
FakeClone
|
||||
}
|
||||
}
|
||||
|
||||
fn ignore_fake_clone() {
|
||||
let mut a = FakeClone;
|
||||
let b = FakeClone;
|
||||
// Should not be linted, since the Clone impl doesn't come from std
|
||||
a = b.clone();
|
||||
}
|
||||
|
||||
fn ignore_generic_clone<T: Clone>(a: &mut T, b: &T) {
|
||||
// Should not be linted, since we don't know the actual clone impl
|
||||
*a = b.clone();
|
||||
}
|
||||
|
||||
macro_rules! clone_inside {
|
||||
($a:expr, $b: expr) => {
|
||||
$a = $b.clone();
|
||||
};
|
||||
}
|
||||
|
||||
fn clone_inside_macro() {
|
||||
let mut a = String::new();
|
||||
let b = String::new();
|
||||
clone_inside!(a, b);
|
||||
}
|
||||
|
||||
// ToOwned
|
||||
fn owned_method_mut_ref(mut_string: &mut String, ref_str: &str) {
|
||||
ref_str.clone_into(mut_string);
|
||||
}
|
||||
|
||||
fn owned_method_val(mut mut_string: String, ref_str: &str) {
|
||||
ref_str.clone_into(&mut mut_string);
|
||||
}
|
||||
|
||||
struct HasDeref {
|
||||
a: String,
|
||||
}
|
||||
|
||||
impl Deref for HasDeref {
|
||||
type Target = String;
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.a
|
||||
}
|
||||
}
|
||||
|
||||
impl DerefMut for HasDeref {
|
||||
fn deref_mut(&mut self) -> &mut Self::Target {
|
||||
&mut self.a
|
||||
}
|
||||
}
|
||||
|
||||
fn owned_method_box(mut_box_string: &mut Box<String>, ref_str: &str) {
|
||||
ref_str.clone_into(&mut (*mut_box_string));
|
||||
}
|
||||
|
||||
fn owned_method_deref(mut_box_string: &mut HasDeref, ref_str: &str) {
|
||||
ref_str.clone_into(&mut (*mut_box_string));
|
||||
}
|
||||
|
||||
fn owned_function_mut_ref(mut_thing: &mut String, ref_str: &str) {
|
||||
ToOwned::clone_into(ref_str, mut_thing);
|
||||
}
|
||||
|
||||
fn owned_function_val(mut mut_thing: String, ref_str: &str) {
|
||||
ToOwned::clone_into(ref_str, &mut mut_thing);
|
||||
}
|
||||
|
||||
struct FakeToOwned;
|
||||
impl FakeToOwned {
|
||||
/// This looks just like `ToOwned::to_owned`
|
||||
fn to_owned(&self) -> Self {
|
||||
FakeToOwned
|
||||
}
|
||||
}
|
||||
|
||||
fn fake_to_owned() {
|
||||
let mut a = FakeToOwned;
|
||||
let b = FakeToOwned;
|
||||
// Should not be linted, since the ToOwned impl doesn't come from std
|
||||
a = b.to_owned();
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
||||
/// Trait implementation to allow producing a `Thing` with a low-precedence expression.
|
||||
impl Add for HasCloneFrom {
|
||||
type Output = Self;
|
||||
fn add(self, _: HasCloneFrom) -> Self {
|
||||
self
|
||||
}
|
||||
}
|
||||
/// Trait implementation to allow producing a `&Thing` with a low-precedence expression.
|
||||
impl<'a> Add for &'a HasCloneFrom {
|
||||
type Output = Self;
|
||||
fn add(self, _: &'a HasCloneFrom) -> Self {
|
||||
self
|
||||
}
|
||||
}
|
||||
/// Trait implementation to allow producing a `&mut Thing` with a low-precedence expression.
|
||||
impl<'a> Add for &'a mut HasCloneFrom {
|
||||
type Output = Self;
|
||||
fn add(self, _: &'a mut HasCloneFrom) -> Self {
|
||||
self
|
||||
}
|
||||
}
|
||||
222
tests/ui/assigning_clones.rs
Normal file
222
tests/ui/assigning_clones.rs
Normal file
|
|
@ -0,0 +1,222 @@
|
|||
#![allow(unused)]
|
||||
#![allow(clippy::redundant_clone)]
|
||||
#![allow(clippy::ptr_arg)] // https://github.com/rust-lang/rust-clippy/issues/10612
|
||||
#![allow(clippy::needless_late_init)]
|
||||
#![allow(clippy::box_collection)]
|
||||
#![warn(clippy::assigning_clones)]
|
||||
|
||||
use std::borrow::ToOwned;
|
||||
use std::ops::{Add, Deref, DerefMut};
|
||||
|
||||
// Clone
|
||||
pub struct HasCloneFrom;
|
||||
|
||||
impl Clone for HasCloneFrom {
|
||||
fn clone(&self) -> Self {
|
||||
Self
|
||||
}
|
||||
fn clone_from(&mut self, source: &Self) {
|
||||
*self = HasCloneFrom;
|
||||
}
|
||||
}
|
||||
|
||||
fn clone_method_rhs_val(mut_thing: &mut HasCloneFrom, value_thing: HasCloneFrom) {
|
||||
*mut_thing = value_thing.clone();
|
||||
}
|
||||
|
||||
fn clone_method_rhs_ref(mut_thing: &mut HasCloneFrom, ref_thing: &HasCloneFrom) {
|
||||
*mut_thing = ref_thing.clone();
|
||||
}
|
||||
|
||||
fn clone_method_lhs_val(mut mut_thing: HasCloneFrom, ref_thing: &HasCloneFrom) {
|
||||
mut_thing = ref_thing.clone();
|
||||
}
|
||||
|
||||
fn clone_function_lhs_mut_ref(mut_thing: &mut HasCloneFrom, ref_thing: &HasCloneFrom) {
|
||||
*mut_thing = Clone::clone(ref_thing);
|
||||
}
|
||||
|
||||
fn clone_function_lhs_val(mut mut_thing: HasCloneFrom, ref_thing: &HasCloneFrom) {
|
||||
mut_thing = Clone::clone(ref_thing);
|
||||
}
|
||||
|
||||
fn clone_function_through_trait(mut_thing: &mut HasCloneFrom, ref_thing: &HasCloneFrom) {
|
||||
*mut_thing = Clone::clone(ref_thing);
|
||||
}
|
||||
|
||||
fn clone_function_through_type(mut_thing: &mut HasCloneFrom, ref_thing: &HasCloneFrom) {
|
||||
*mut_thing = HasCloneFrom::clone(ref_thing);
|
||||
}
|
||||
|
||||
fn clone_function_fully_qualified(mut_thing: &mut HasCloneFrom, ref_thing: &HasCloneFrom) {
|
||||
*mut_thing = <HasCloneFrom as Clone>::clone(ref_thing);
|
||||
}
|
||||
|
||||
fn clone_method_lhs_complex(mut_thing: &mut HasCloneFrom, ref_thing: &HasCloneFrom) {
|
||||
// These parens should be kept as necessary for a receiver
|
||||
*(mut_thing + &mut HasCloneFrom) = ref_thing.clone();
|
||||
}
|
||||
|
||||
fn clone_method_rhs_complex(mut_thing: &mut HasCloneFrom, ref_thing: &HasCloneFrom) {
|
||||
// These parens should be removed since they are not needed in a function argument
|
||||
*mut_thing = (ref_thing + ref_thing).clone();
|
||||
}
|
||||
|
||||
fn assign_to_init_mut_var(b: HasCloneFrom) -> HasCloneFrom {
|
||||
let mut a = HasCloneFrom;
|
||||
for _ in 1..10 {
|
||||
a = b.clone();
|
||||
}
|
||||
a
|
||||
}
|
||||
|
||||
fn assign_to_late_init_mut_var(b: HasCloneFrom) {
|
||||
let mut a;
|
||||
a = HasCloneFrom;
|
||||
a = b.clone();
|
||||
}
|
||||
|
||||
fn assign_to_uninit_var(b: HasCloneFrom) {
|
||||
let a;
|
||||
a = b.clone();
|
||||
}
|
||||
|
||||
fn assign_to_uninit_mut_var(b: HasCloneFrom) {
|
||||
let mut a;
|
||||
a = b.clone();
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct HasDeriveClone;
|
||||
|
||||
fn ignore_derive_clone(a: &mut HasDeriveClone, b: &HasDeriveClone) {
|
||||
// Should not be linted, since the Clone impl is derived
|
||||
*a = b.clone();
|
||||
}
|
||||
|
||||
pub struct HasCloneImpl;
|
||||
|
||||
impl Clone for HasCloneImpl {
|
||||
fn clone(&self) -> Self {
|
||||
Self
|
||||
}
|
||||
}
|
||||
|
||||
fn ignore_missing_clone_from(a: &mut HasCloneImpl, b: &HasCloneImpl) {
|
||||
// Should not be linted, since the Clone impl doesn't override clone_from
|
||||
*a = b.clone();
|
||||
}
|
||||
|
||||
struct FakeClone;
|
||||
|
||||
impl FakeClone {
|
||||
/// This looks just like `Clone::clone`
|
||||
fn clone(&self) -> Self {
|
||||
FakeClone
|
||||
}
|
||||
}
|
||||
|
||||
fn ignore_fake_clone() {
|
||||
let mut a = FakeClone;
|
||||
let b = FakeClone;
|
||||
// Should not be linted, since the Clone impl doesn't come from std
|
||||
a = b.clone();
|
||||
}
|
||||
|
||||
fn ignore_generic_clone<T: Clone>(a: &mut T, b: &T) {
|
||||
// Should not be linted, since we don't know the actual clone impl
|
||||
*a = b.clone();
|
||||
}
|
||||
|
||||
macro_rules! clone_inside {
|
||||
($a:expr, $b: expr) => {
|
||||
$a = $b.clone();
|
||||
};
|
||||
}
|
||||
|
||||
fn clone_inside_macro() {
|
||||
let mut a = String::new();
|
||||
let b = String::new();
|
||||
clone_inside!(a, b);
|
||||
}
|
||||
|
||||
// ToOwned
|
||||
fn owned_method_mut_ref(mut_string: &mut String, ref_str: &str) {
|
||||
*mut_string = ref_str.to_owned();
|
||||
}
|
||||
|
||||
fn owned_method_val(mut mut_string: String, ref_str: &str) {
|
||||
mut_string = ref_str.to_owned();
|
||||
}
|
||||
|
||||
struct HasDeref {
|
||||
a: String,
|
||||
}
|
||||
|
||||
impl Deref for HasDeref {
|
||||
type Target = String;
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.a
|
||||
}
|
||||
}
|
||||
|
||||
impl DerefMut for HasDeref {
|
||||
fn deref_mut(&mut self) -> &mut Self::Target {
|
||||
&mut self.a
|
||||
}
|
||||
}
|
||||
|
||||
fn owned_method_box(mut_box_string: &mut Box<String>, ref_str: &str) {
|
||||
**mut_box_string = ref_str.to_owned();
|
||||
}
|
||||
|
||||
fn owned_method_deref(mut_box_string: &mut HasDeref, ref_str: &str) {
|
||||
**mut_box_string = ref_str.to_owned();
|
||||
}
|
||||
|
||||
fn owned_function_mut_ref(mut_thing: &mut String, ref_str: &str) {
|
||||
*mut_thing = ToOwned::to_owned(ref_str);
|
||||
}
|
||||
|
||||
fn owned_function_val(mut mut_thing: String, ref_str: &str) {
|
||||
mut_thing = ToOwned::to_owned(ref_str);
|
||||
}
|
||||
|
||||
struct FakeToOwned;
|
||||
impl FakeToOwned {
|
||||
/// This looks just like `ToOwned::to_owned`
|
||||
fn to_owned(&self) -> Self {
|
||||
FakeToOwned
|
||||
}
|
||||
}
|
||||
|
||||
fn fake_to_owned() {
|
||||
let mut a = FakeToOwned;
|
||||
let b = FakeToOwned;
|
||||
// Should not be linted, since the ToOwned impl doesn't come from std
|
||||
a = b.to_owned();
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
||||
/// Trait implementation to allow producing a `Thing` with a low-precedence expression.
|
||||
impl Add for HasCloneFrom {
|
||||
type Output = Self;
|
||||
fn add(self, _: HasCloneFrom) -> Self {
|
||||
self
|
||||
}
|
||||
}
|
||||
/// Trait implementation to allow producing a `&Thing` with a low-precedence expression.
|
||||
impl<'a> Add for &'a HasCloneFrom {
|
||||
type Output = Self;
|
||||
fn add(self, _: &'a HasCloneFrom) -> Self {
|
||||
self
|
||||
}
|
||||
}
|
||||
/// Trait implementation to allow producing a `&mut Thing` with a low-precedence expression.
|
||||
impl<'a> Add for &'a mut HasCloneFrom {
|
||||
type Output = Self;
|
||||
fn add(self, _: &'a mut HasCloneFrom) -> Self {
|
||||
self
|
||||
}
|
||||
}
|
||||
107
tests/ui/assigning_clones.stderr
Normal file
107
tests/ui/assigning_clones.stderr
Normal file
|
|
@ -0,0 +1,107 @@
|
|||
error: assigning the result of `Clone::clone()` may be inefficient
|
||||
--> tests/ui/assigning_clones.rs:24:5
|
||||
|
|
||||
LL | *mut_thing = value_thing.clone();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `clone_from()`: `mut_thing.clone_from(&value_thing)`
|
||||
|
|
||||
= note: `-D clippy::assigning-clones` implied by `-D warnings`
|
||||
= help: to override `-D warnings` add `#[allow(clippy::assigning_clones)]`
|
||||
|
||||
error: assigning the result of `Clone::clone()` may be inefficient
|
||||
--> tests/ui/assigning_clones.rs:28:5
|
||||
|
|
||||
LL | *mut_thing = ref_thing.clone();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `clone_from()`: `mut_thing.clone_from(ref_thing)`
|
||||
|
||||
error: assigning the result of `Clone::clone()` may be inefficient
|
||||
--> tests/ui/assigning_clones.rs:32:5
|
||||
|
|
||||
LL | mut_thing = ref_thing.clone();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `clone_from()`: `mut_thing.clone_from(ref_thing)`
|
||||
|
||||
error: assigning the result of `Clone::clone()` may be inefficient
|
||||
--> tests/ui/assigning_clones.rs:36:5
|
||||
|
|
||||
LL | *mut_thing = Clone::clone(ref_thing);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `clone_from()`: `Clone::clone_from(mut_thing, ref_thing)`
|
||||
|
||||
error: assigning the result of `Clone::clone()` may be inefficient
|
||||
--> tests/ui/assigning_clones.rs:40:5
|
||||
|
|
||||
LL | mut_thing = Clone::clone(ref_thing);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `clone_from()`: `Clone::clone_from(&mut mut_thing, ref_thing)`
|
||||
|
||||
error: assigning the result of `Clone::clone()` may be inefficient
|
||||
--> tests/ui/assigning_clones.rs:44:5
|
||||
|
|
||||
LL | *mut_thing = Clone::clone(ref_thing);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `clone_from()`: `Clone::clone_from(mut_thing, ref_thing)`
|
||||
|
||||
error: assigning the result of `Clone::clone()` may be inefficient
|
||||
--> tests/ui/assigning_clones.rs:48:5
|
||||
|
|
||||
LL | *mut_thing = HasCloneFrom::clone(ref_thing);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `clone_from()`: `Clone::clone_from(mut_thing, ref_thing)`
|
||||
|
||||
error: assigning the result of `Clone::clone()` may be inefficient
|
||||
--> tests/ui/assigning_clones.rs:52:5
|
||||
|
|
||||
LL | *mut_thing = <HasCloneFrom as Clone>::clone(ref_thing);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `clone_from()`: `Clone::clone_from(mut_thing, ref_thing)`
|
||||
|
||||
error: assigning the result of `Clone::clone()` may be inefficient
|
||||
--> tests/ui/assigning_clones.rs:57:5
|
||||
|
|
||||
LL | *(mut_thing + &mut HasCloneFrom) = ref_thing.clone();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `clone_from()`: `(mut_thing + &mut HasCloneFrom).clone_from(ref_thing)`
|
||||
|
||||
error: assigning the result of `Clone::clone()` may be inefficient
|
||||
--> tests/ui/assigning_clones.rs:62:5
|
||||
|
|
||||
LL | *mut_thing = (ref_thing + ref_thing).clone();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `clone_from()`: `mut_thing.clone_from(ref_thing + ref_thing)`
|
||||
|
||||
error: assigning the result of `Clone::clone()` may be inefficient
|
||||
--> tests/ui/assigning_clones.rs:68:9
|
||||
|
|
||||
LL | a = b.clone();
|
||||
| ^^^^^^^^^^^^^ help: use `clone_from()`: `a.clone_from(&b)`
|
||||
|
||||
error: assigning the result of `ToOwned::to_owned()` may be inefficient
|
||||
--> tests/ui/assigning_clones.rs:145:5
|
||||
|
|
||||
LL | *mut_string = ref_str.to_owned();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `clone_into()`: `ref_str.clone_into(mut_string)`
|
||||
|
||||
error: assigning the result of `ToOwned::to_owned()` may be inefficient
|
||||
--> tests/ui/assigning_clones.rs:149:5
|
||||
|
|
||||
LL | mut_string = ref_str.to_owned();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `clone_into()`: `ref_str.clone_into(&mut mut_string)`
|
||||
|
||||
error: assigning the result of `ToOwned::to_owned()` may be inefficient
|
||||
--> tests/ui/assigning_clones.rs:170:5
|
||||
|
|
||||
LL | **mut_box_string = ref_str.to_owned();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `clone_into()`: `ref_str.clone_into(&mut (*mut_box_string))`
|
||||
|
||||
error: assigning the result of `ToOwned::to_owned()` may be inefficient
|
||||
--> tests/ui/assigning_clones.rs:174:5
|
||||
|
|
||||
LL | **mut_box_string = ref_str.to_owned();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `clone_into()`: `ref_str.clone_into(&mut (*mut_box_string))`
|
||||
|
||||
error: assigning the result of `ToOwned::to_owned()` may be inefficient
|
||||
--> tests/ui/assigning_clones.rs:178:5
|
||||
|
|
||||
LL | *mut_thing = ToOwned::to_owned(ref_str);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `clone_into()`: `ToOwned::clone_into(ref_str, mut_thing)`
|
||||
|
||||
error: assigning the result of `ToOwned::to_owned()` may be inefficient
|
||||
--> tests/ui/assigning_clones.rs:182:5
|
||||
|
|
||||
LL | mut_thing = ToOwned::to_owned(ref_str);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `clone_into()`: `ToOwned::clone_into(ref_str, &mut mut_thing)`
|
||||
|
||||
error: aborting due to 17 previous errors
|
||||
|
||||
|
|
@ -3,6 +3,6 @@ struct Foo(isize, isize, isize, isize);
|
|||
pub fn main() {
|
||||
let Self::anything_here_kills_it(a, b, ..) = Foo(5, 5, 5, 5);
|
||||
match [5, 5, 5, 5] {
|
||||
[..] => { }
|
||||
[..] => {},
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -153,4 +153,30 @@ pub enum MissingEqNonExhaustive3 {
|
|||
Bar,
|
||||
}
|
||||
|
||||
mod struct_gen {
|
||||
// issue 9413
|
||||
pub trait Group {
|
||||
type Element: Eq + PartialEq;
|
||||
}
|
||||
|
||||
pub trait Suite {
|
||||
type Group: Group;
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Eq)]
|
||||
//~^ ERROR: you are deriving `PartialEq` and can implement `Eq`
|
||||
pub struct Foo<C: Suite>(<C::Group as Group>::Element);
|
||||
|
||||
#[derive(PartialEq, Eq)]
|
||||
pub struct Bar<C: Suite>(i32, <C::Group as Group>::Element);
|
||||
|
||||
// issue 9319
|
||||
#[derive(PartialEq, Eq)]
|
||||
//~^ ERROR: you are deriving `PartialEq` and can implement `Eq`
|
||||
pub struct Oof<T: Fn()>(T);
|
||||
|
||||
#[derive(PartialEq, Eq)]
|
||||
pub struct Rab<T: Fn()>(T);
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -153,4 +153,30 @@ pub enum MissingEqNonExhaustive3 {
|
|||
Bar,
|
||||
}
|
||||
|
||||
mod struct_gen {
|
||||
// issue 9413
|
||||
pub trait Group {
|
||||
type Element: Eq + PartialEq;
|
||||
}
|
||||
|
||||
pub trait Suite {
|
||||
type Group: Group;
|
||||
}
|
||||
|
||||
#[derive(PartialEq)]
|
||||
//~^ ERROR: you are deriving `PartialEq` and can implement `Eq`
|
||||
pub struct Foo<C: Suite>(<C::Group as Group>::Element);
|
||||
|
||||
#[derive(PartialEq, Eq)]
|
||||
pub struct Bar<C: Suite>(i32, <C::Group as Group>::Element);
|
||||
|
||||
// issue 9319
|
||||
#[derive(PartialEq)]
|
||||
//~^ ERROR: you are deriving `PartialEq` and can implement `Eq`
|
||||
pub struct Oof<T: Fn()>(T);
|
||||
|
||||
#[derive(PartialEq, Eq)]
|
||||
pub struct Rab<T: Fn()>(T);
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -67,5 +67,17 @@ error: you are deriving `PartialEq` and can implement `Eq`
|
|||
LL | #[derive(PartialEq)]
|
||||
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
||||
|
||||
error: aborting due to 11 previous errors
|
||||
error: you are deriving `PartialEq` and can implement `Eq`
|
||||
--> tests/ui/derive_partial_eq_without_eq.rs:166:14
|
||||
|
|
||||
LL | #[derive(PartialEq)]
|
||||
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
||||
|
||||
error: you are deriving `PartialEq` and can implement `Eq`
|
||||
--> tests/ui/derive_partial_eq_without_eq.rs:174:14
|
||||
|
|
||||
LL | #[derive(PartialEq)]
|
||||
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
||||
|
||||
error: aborting due to 13 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -230,3 +230,8 @@ fn issue_11568() {}
|
|||
|
||||
/// There is no try (`do()` or `do_not()`).
|
||||
fn parenthesized_word() {}
|
||||
|
||||
/// `ABes`
|
||||
/// OSes
|
||||
/// UXes
|
||||
fn plural_acronym_test() {}
|
||||
|
|
|
|||
|
|
@ -230,3 +230,8 @@ fn issue_11568() {}
|
|||
|
||||
/// There is no try (do() or do_not()).
|
||||
fn parenthesized_word() {}
|
||||
|
||||
/// ABes
|
||||
/// OSes
|
||||
/// UXes
|
||||
fn plural_acronym_test() {}
|
||||
|
|
|
|||
|
|
@ -341,5 +341,16 @@ help: try
|
|||
LL | /// There is no try (do() or `do_not()`).
|
||||
| ~~~~~~~~~~
|
||||
|
||||
error: aborting due to 31 previous errors
|
||||
error: item in documentation is missing backticks
|
||||
--> tests/ui/doc/doc-fixable.rs:234:5
|
||||
|
|
||||
LL | /// ABes
|
||||
| ^^^^
|
||||
|
|
||||
help: try
|
||||
|
|
||||
LL | /// `ABes`
|
||||
| ~~~~~~
|
||||
|
||||
error: aborting due to 32 previous errors
|
||||
|
||||
|
|
|
|||
9
tests/ui/doc/issue_9473.fixed
Normal file
9
tests/ui/doc/issue_9473.fixed
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
#![warn(clippy::doc_markdown)]
|
||||
|
||||
// Should not warn!
|
||||
/// Blah blah blah <code>[FooBar]<[FooBar]></code>.
|
||||
pub struct Foo(u32);
|
||||
|
||||
// Should warn.
|
||||
/// Blah blah blah <code>[FooBar]<[FooBar]></code>[`FooBar`].
|
||||
pub struct FooBar(u32);
|
||||
9
tests/ui/doc/issue_9473.rs
Normal file
9
tests/ui/doc/issue_9473.rs
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
#![warn(clippy::doc_markdown)]
|
||||
|
||||
// Should not warn!
|
||||
/// Blah blah blah <code>[FooBar]<[FooBar]></code>.
|
||||
pub struct Foo(u32);
|
||||
|
||||
// Should warn.
|
||||
/// Blah blah blah <code>[FooBar]<[FooBar]></code>[FooBar].
|
||||
pub struct FooBar(u32);
|
||||
15
tests/ui/doc/issue_9473.stderr
Normal file
15
tests/ui/doc/issue_9473.stderr
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
error: item in documentation is missing backticks
|
||||
--> tests/ui/doc/issue_9473.rs:8:58
|
||||
|
|
||||
LL | /// Blah blah blah <code>[FooBar]<[FooBar]></code>[FooBar].
|
||||
| ^^^^^^
|
||||
|
|
||||
= note: `-D clippy::doc-markdown` implied by `-D warnings`
|
||||
= help: to override `-D warnings` add `#[allow(clippy::doc_markdown)]`
|
||||
help: try
|
||||
|
|
||||
LL | /// Blah blah blah <code>[FooBar]<[FooBar]></code>[`FooBar`].
|
||||
| ~~~~~~~~
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
|
|
@ -1,3 +1,5 @@
|
|||
//@compile-flags: -Zdeduplicate-diagnostics=yes
|
||||
|
||||
#![warn(clippy::all)]
|
||||
#![warn(clippy::else_if_without_else)]
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: `if` expression with an `else if`, but without a final `else`
|
||||
--> tests/ui/else_if_without_else.rs:45:12
|
||||
--> tests/ui/else_if_without_else.rs:47:12
|
||||
|
|
||||
LL | } else if bla2() {
|
||||
| ____________^
|
||||
|
|
@ -13,7 +13,7 @@ LL | | }
|
|||
= help: to override `-D warnings` add `#[allow(clippy::else_if_without_else)]`
|
||||
|
||||
error: `if` expression with an `else if`, but without a final `else`
|
||||
--> tests/ui/else_if_without_else.rs:54:12
|
||||
--> tests/ui/else_if_without_else.rs:56:12
|
||||
|
|
||||
LL | } else if bla3() {
|
||||
| ____________^
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
#![allow(unused)]
|
||||
#![warn(clippy::empty_docs)]
|
||||
#![allow(clippy::mixed_attributes_style)]
|
||||
|
||||
mod outer {
|
||||
//!
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: empty doc comment
|
||||
--> tests/ui/empty_docs.rs:4:5
|
||||
--> tests/ui/empty_docs.rs:6:5
|
||||
|
|
||||
LL | //!
|
||||
| ^^^
|
||||
|
|
@ -9,7 +9,7 @@ LL | //!
|
|||
= help: to override `-D warnings` add `#[allow(clippy::empty_docs)]`
|
||||
|
||||
error: empty doc comment
|
||||
--> tests/ui/empty_docs.rs:12:5
|
||||
--> tests/ui/empty_docs.rs:14:5
|
||||
|
|
||||
LL | ///
|
||||
| ^^^
|
||||
|
|
@ -17,7 +17,7 @@ LL | ///
|
|||
= help: consider removing or filling it
|
||||
|
||||
error: empty doc comment
|
||||
--> tests/ui/empty_docs.rs:14:9
|
||||
--> tests/ui/empty_docs.rs:16:9
|
||||
|
|
||||
LL | ///
|
||||
| ^^^
|
||||
|
|
@ -25,7 +25,7 @@ LL | ///
|
|||
= help: consider removing or filling it
|
||||
|
||||
error: empty doc comment
|
||||
--> tests/ui/empty_docs.rs:25:5
|
||||
--> tests/ui/empty_docs.rs:27:5
|
||||
|
|
||||
LL | #[doc = ""]
|
||||
| ^^^^^^^^^^^
|
||||
|
|
@ -33,7 +33,7 @@ LL | #[doc = ""]
|
|||
= help: consider removing or filling it
|
||||
|
||||
error: empty doc comment
|
||||
--> tests/ui/empty_docs.rs:28:5
|
||||
--> tests/ui/empty_docs.rs:30:5
|
||||
|
|
||||
LL | / #[doc = ""]
|
||||
LL | | #[doc = ""]
|
||||
|
|
@ -42,7 +42,7 @@ LL | | #[doc = ""]
|
|||
= help: consider removing or filling it
|
||||
|
||||
error: empty doc comment
|
||||
--> tests/ui/empty_docs.rs:35:5
|
||||
--> tests/ui/empty_docs.rs:37:5
|
||||
|
|
||||
LL | ///
|
||||
| ^^^
|
||||
|
|
@ -50,7 +50,7 @@ LL | ///
|
|||
= help: consider removing or filling it
|
||||
|
||||
error: empty doc comment
|
||||
--> tests/ui/empty_docs.rs:48:13
|
||||
--> tests/ui/empty_docs.rs:50:13
|
||||
|
|
||||
LL | /*! */
|
||||
| ^^^^^^
|
||||
|
|
@ -58,7 +58,7 @@ LL | /*! */
|
|||
= help: consider removing or filling it
|
||||
|
||||
error: empty doc comment
|
||||
--> tests/ui/empty_docs.rs:56:13
|
||||
--> tests/ui/empty_docs.rs:58:13
|
||||
|
|
||||
LL | ///
|
||||
| ^^^
|
||||
|
|
@ -66,7 +66,7 @@ LL | ///
|
|||
= help: consider removing or filling it
|
||||
|
||||
error: empty doc comment
|
||||
--> tests/ui/empty_docs.rs:64:9
|
||||
--> tests/ui/empty_docs.rs:66:9
|
||||
|
|
||||
LL | ///
|
||||
| ^^^
|
||||
|
|
|
|||
|
|
@ -165,4 +165,15 @@ pub fn issue_10331() {
|
|||
}
|
||||
}
|
||||
|
||||
/// Issue 11935
|
||||
/// Do not suggest using entries if the map is used inside the `insert` expression.
|
||||
pub fn issue_11935() {
|
||||
let mut counts: HashMap<u64, u64> = HashMap::new();
|
||||
if !counts.contains_key(&1) {
|
||||
counts.insert(1, 1);
|
||||
} else {
|
||||
counts.insert(1, counts.get(&1).unwrap() + 1);
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -169,4 +169,15 @@ pub fn issue_10331() {
|
|||
}
|
||||
}
|
||||
|
||||
/// Issue 11935
|
||||
/// Do not suggest using entries if the map is used inside the `insert` expression.
|
||||
pub fn issue_11935() {
|
||||
let mut counts: HashMap<u64, u64> = HashMap::new();
|
||||
if !counts.contains_key(&1) {
|
||||
counts.insert(1, 1);
|
||||
} else {
|
||||
counts.insert(1, counts.get(&1).unwrap() + 1);
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
clippy::deref_addrof,
|
||||
clippy::unnecessary_mut_passed,
|
||||
dead_code,
|
||||
non_local_definitions,
|
||||
non_local_definitions
|
||||
)]
|
||||
|
||||
use core::slice;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
clippy::deref_addrof,
|
||||
clippy::unnecessary_mut_passed,
|
||||
dead_code,
|
||||
non_local_definitions,
|
||||
non_local_definitions
|
||||
)]
|
||||
|
||||
use core::slice;
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
//@aux-build:proc_macros.rs
|
||||
|
||||
#![warn(clippy::field_reassign_with_default)]
|
||||
#![allow(clippy::assigning_clones)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate proc_macro_derive;
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
error: field assignment outside of initializer for an instance created with Default::default()
|
||||
--> tests/ui/field_reassign_with_default.rs:56:5
|
||||
--> tests/ui/field_reassign_with_default.rs:57:5
|
||||
|
|
||||
LL | a.i = 42;
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
note: consider initializing the variable with `main::A { i: 42, ..Default::default() }` and removing relevant reassignments
|
||||
--> tests/ui/field_reassign_with_default.rs:55:5
|
||||
--> tests/ui/field_reassign_with_default.rs:56:5
|
||||
|
|
||||
LL | let mut a: A = Default::default();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -13,121 +13,121 @@ LL | let mut a: A = Default::default();
|
|||
= help: to override `-D warnings` add `#[allow(clippy::field_reassign_with_default)]`
|
||||
|
||||
error: field assignment outside of initializer for an instance created with Default::default()
|
||||
--> tests/ui/field_reassign_with_default.rs:96:5
|
||||
--> tests/ui/field_reassign_with_default.rs:97:5
|
||||
|
|
||||
LL | a.j = 43;
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
note: consider initializing the variable with `main::A { j: 43, i: 42 }` and removing relevant reassignments
|
||||
--> tests/ui/field_reassign_with_default.rs:95:5
|
||||
--> tests/ui/field_reassign_with_default.rs:96:5
|
||||
|
|
||||
LL | let mut a: A = Default::default();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: field assignment outside of initializer for an instance created with Default::default()
|
||||
--> tests/ui/field_reassign_with_default.rs:101:5
|
||||
--> tests/ui/field_reassign_with_default.rs:102:5
|
||||
|
|
||||
LL | a.i = 42;
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
note: consider initializing the variable with `main::A { i: 42, j: 44 }` and removing relevant reassignments
|
||||
--> tests/ui/field_reassign_with_default.rs:100:5
|
||||
--> tests/ui/field_reassign_with_default.rs:101:5
|
||||
|
|
||||
LL | let mut a: A = Default::default();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: field assignment outside of initializer for an instance created with Default::default()
|
||||
--> tests/ui/field_reassign_with_default.rs:107:5
|
||||
--> tests/ui/field_reassign_with_default.rs:108:5
|
||||
|
|
||||
LL | a.i = 42;
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
note: consider initializing the variable with `main::A { i: 42, ..Default::default() }` and removing relevant reassignments
|
||||
--> tests/ui/field_reassign_with_default.rs:106:5
|
||||
--> tests/ui/field_reassign_with_default.rs:107:5
|
||||
|
|
||||
LL | let mut a = A::default();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: field assignment outside of initializer for an instance created with Default::default()
|
||||
--> tests/ui/field_reassign_with_default.rs:117:5
|
||||
--> tests/ui/field_reassign_with_default.rs:118:5
|
||||
|
|
||||
LL | a.i = Default::default();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: consider initializing the variable with `main::A { i: Default::default(), ..Default::default() }` and removing relevant reassignments
|
||||
--> tests/ui/field_reassign_with_default.rs:116:5
|
||||
--> tests/ui/field_reassign_with_default.rs:117:5
|
||||
|
|
||||
LL | let mut a: A = Default::default();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: field assignment outside of initializer for an instance created with Default::default()
|
||||
--> tests/ui/field_reassign_with_default.rs:121:5
|
||||
--> tests/ui/field_reassign_with_default.rs:122:5
|
||||
|
|
||||
LL | a.i = Default::default();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: consider initializing the variable with `main::A { i: Default::default(), j: 45 }` and removing relevant reassignments
|
||||
--> tests/ui/field_reassign_with_default.rs:120:5
|
||||
--> tests/ui/field_reassign_with_default.rs:121:5
|
||||
|
|
||||
LL | let mut a: A = Default::default();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: field assignment outside of initializer for an instance created with Default::default()
|
||||
--> tests/ui/field_reassign_with_default.rs:143:5
|
||||
--> tests/ui/field_reassign_with_default.rs:144:5
|
||||
|
|
||||
LL | a.i = vec![1];
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
|
||||
note: consider initializing the variable with `C { i: vec![1], ..Default::default() }` and removing relevant reassignments
|
||||
--> tests/ui/field_reassign_with_default.rs:142:5
|
||||
--> tests/ui/field_reassign_with_default.rs:143:5
|
||||
|
|
||||
LL | let mut a: C = C::default();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: field assignment outside of initializer for an instance created with Default::default()
|
||||
--> tests/ui/field_reassign_with_default.rs:161:5
|
||||
--> tests/ui/field_reassign_with_default.rs:162:5
|
||||
|
|
||||
LL | a.i = true;
|
||||
| ^^^^^^^^^^^
|
||||
|
|
||||
note: consider initializing the variable with `Wrapper::<bool> { i: true }` and removing relevant reassignments
|
||||
--> tests/ui/field_reassign_with_default.rs:160:5
|
||||
--> tests/ui/field_reassign_with_default.rs:161:5
|
||||
|
|
||||
LL | let mut a: Wrapper<bool> = Default::default();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: field assignment outside of initializer for an instance created with Default::default()
|
||||
--> tests/ui/field_reassign_with_default.rs:164:5
|
||||
--> tests/ui/field_reassign_with_default.rs:165:5
|
||||
|
|
||||
LL | a.i = 42;
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
note: consider initializing the variable with `WrapperMulti::<i32, i64> { i: 42, ..Default::default() }` and removing relevant reassignments
|
||||
--> tests/ui/field_reassign_with_default.rs:163:5
|
||||
--> tests/ui/field_reassign_with_default.rs:164:5
|
||||
|
|
||||
LL | let mut a: WrapperMulti<i32, i64> = Default::default();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: field assignment outside of initializer for an instance created with Default::default()
|
||||
--> tests/ui/field_reassign_with_default.rs:235:13
|
||||
--> tests/ui/field_reassign_with_default.rs:236:13
|
||||
|
|
||||
LL | f.name = name.len();
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: consider initializing the variable with `issue6312::ImplDropAllCopy { name: name.len(), ..Default::default() }` and removing relevant reassignments
|
||||
--> tests/ui/field_reassign_with_default.rs:234:13
|
||||
--> tests/ui/field_reassign_with_default.rs:235:13
|
||||
|
|
||||
LL | let mut f = ImplDropAllCopy::default();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: field assignment outside of initializer for an instance created with Default::default()
|
||||
--> tests/ui/field_reassign_with_default.rs:251:13
|
||||
--> tests/ui/field_reassign_with_default.rs:252:13
|
||||
|
|
||||
LL | f.name = name.len();
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: consider initializing the variable with `issue6312::NoDropAllCopy { name: name.len(), ..Default::default() }` and removing relevant reassignments
|
||||
--> tests/ui/field_reassign_with_default.rs:250:13
|
||||
--> tests/ui/field_reassign_with_default.rs:251:13
|
||||
|
|
||||
LL | let mut f = NoDropAllCopy::default();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
|
|||
|
|
@ -134,7 +134,7 @@ fn main() {
|
|||
//~^ ERROR: this operation has no effect
|
||||
f(if b { 1 } else { 2 } + 3);
|
||||
//~^ ERROR: this operation has no effect
|
||||
|
||||
|
||||
const _: i32 = { 2 * 4 } + 3;
|
||||
//~^ ERROR: this operation has no effect
|
||||
const _: i32 = { 1 + 2 * 3 } + 3;
|
||||
|
|
|
|||
|
|
@ -134,7 +134,7 @@ fn main() {
|
|||
//~^ ERROR: this operation has no effect
|
||||
f(0 + if b { 1 } else { 2 } + 3);
|
||||
//~^ ERROR: this operation has no effect
|
||||
|
||||
|
||||
const _: i32 = { 2 * 4 } + 0 + 3;
|
||||
//~^ ERROR: this operation has no effect
|
||||
const _: i32 = 0 + { 1 + 2 * 3 } + 3;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
//@compile-flags: -Zdeduplicate-diagnostics=yes
|
||||
|
||||
#![feature(inline_const)]
|
||||
#![warn(clippy::indexing_slicing)]
|
||||
// We also check the out_of_bounds_indexing lint here, because it lints similar things and
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: indexing may panic
|
||||
--> tests/ui/indexing_slicing_index.rs:14:20
|
||||
--> tests/ui/indexing_slicing_index.rs:16:20
|
||||
|
|
||||
LL | const REF: &i32 = &ARR[idx()]; // This should be linted, since `suppress-restriction-lint-in-const` default is false.
|
||||
| ^^^^^^^^^^
|
||||
|
|
@ -10,19 +10,19 @@ LL | const REF: &i32 = &ARR[idx()]; // This should be linted, since `suppress-re
|
|||
= help: to override `-D warnings` add `#[allow(clippy::indexing_slicing)]`
|
||||
|
||||
error[E0080]: evaluation of `main::{constant#3}` failed
|
||||
--> tests/ui/indexing_slicing_index.rs:46:14
|
||||
--> tests/ui/indexing_slicing_index.rs:48:14
|
||||
|
|
||||
LL | const { &ARR[idx4()] };
|
||||
| ^^^^^^^^^^^ index out of bounds: the length is 2 but the index is 4
|
||||
|
||||
note: erroneous constant encountered
|
||||
--> tests/ui/indexing_slicing_index.rs:46:5
|
||||
--> tests/ui/indexing_slicing_index.rs:48:5
|
||||
|
|
||||
LL | const { &ARR[idx4()] };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: indexing may panic
|
||||
--> tests/ui/indexing_slicing_index.rs:27:5
|
||||
--> tests/ui/indexing_slicing_index.rs:29:5
|
||||
|
|
||||
LL | x[index];
|
||||
| ^^^^^^^^
|
||||
|
|
@ -30,7 +30,7 @@ LL | x[index];
|
|||
= help: consider using `.get(n)` or `.get_mut(n)` instead
|
||||
|
||||
error: index is out of bounds
|
||||
--> tests/ui/indexing_slicing_index.rs:30:5
|
||||
--> tests/ui/indexing_slicing_index.rs:32:5
|
||||
|
|
||||
LL | x[4];
|
||||
| ^^^^
|
||||
|
|
@ -39,13 +39,13 @@ LL | x[4];
|
|||
= help: to override `-D warnings` add `#[allow(clippy::out_of_bounds_indexing)]`
|
||||
|
||||
error: index is out of bounds
|
||||
--> tests/ui/indexing_slicing_index.rs:32:5
|
||||
--> tests/ui/indexing_slicing_index.rs:34:5
|
||||
|
|
||||
LL | x[1 << 3];
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: indexing may panic
|
||||
--> tests/ui/indexing_slicing_index.rs:43:14
|
||||
--> tests/ui/indexing_slicing_index.rs:45:14
|
||||
|
|
||||
LL | const { &ARR[idx()] };
|
||||
| ^^^^^^^^^^
|
||||
|
|
@ -54,7 +54,7 @@ LL | const { &ARR[idx()] };
|
|||
= note: the suggestion might not be applicable in constant blocks
|
||||
|
||||
error: indexing may panic
|
||||
--> tests/ui/indexing_slicing_index.rs:46:14
|
||||
--> tests/ui/indexing_slicing_index.rs:48:14
|
||||
|
|
||||
LL | const { &ARR[idx4()] };
|
||||
| ^^^^^^^^^^^
|
||||
|
|
@ -63,13 +63,13 @@ LL | const { &ARR[idx4()] };
|
|||
= note: the suggestion might not be applicable in constant blocks
|
||||
|
||||
error: index is out of bounds
|
||||
--> tests/ui/indexing_slicing_index.rs:53:5
|
||||
--> tests/ui/indexing_slicing_index.rs:55:5
|
||||
|
|
||||
LL | y[4];
|
||||
| ^^^^
|
||||
|
||||
error: indexing may panic
|
||||
--> tests/ui/indexing_slicing_index.rs:56:5
|
||||
--> tests/ui/indexing_slicing_index.rs:58:5
|
||||
|
|
||||
LL | v[0];
|
||||
| ^^^^
|
||||
|
|
@ -77,7 +77,7 @@ LL | v[0];
|
|||
= help: consider using `.get(n)` or `.get_mut(n)` instead
|
||||
|
||||
error: indexing may panic
|
||||
--> tests/ui/indexing_slicing_index.rs:58:5
|
||||
--> tests/ui/indexing_slicing_index.rs:60:5
|
||||
|
|
||||
LL | v[10];
|
||||
| ^^^^^
|
||||
|
|
@ -85,7 +85,7 @@ LL | v[10];
|
|||
= help: consider using `.get(n)` or `.get_mut(n)` instead
|
||||
|
||||
error: indexing may panic
|
||||
--> tests/ui/indexing_slicing_index.rs:60:5
|
||||
--> tests/ui/indexing_slicing_index.rs:62:5
|
||||
|
|
||||
LL | v[1 << 3];
|
||||
| ^^^^^^^^^
|
||||
|
|
@ -93,13 +93,13 @@ LL | v[1 << 3];
|
|||
= help: consider using `.get(n)` or `.get_mut(n)` instead
|
||||
|
||||
error: index is out of bounds
|
||||
--> tests/ui/indexing_slicing_index.rs:68:5
|
||||
--> tests/ui/indexing_slicing_index.rs:70:5
|
||||
|
|
||||
LL | x[N];
|
||||
| ^^^^
|
||||
|
||||
error: indexing may panic
|
||||
--> tests/ui/indexing_slicing_index.rs:71:5
|
||||
--> tests/ui/indexing_slicing_index.rs:73:5
|
||||
|
|
||||
LL | v[N];
|
||||
| ^^^^
|
||||
|
|
@ -107,7 +107,7 @@ LL | v[N];
|
|||
= help: consider using `.get(n)` or `.get_mut(n)` instead
|
||||
|
||||
error: indexing may panic
|
||||
--> tests/ui/indexing_slicing_index.rs:73:5
|
||||
--> tests/ui/indexing_slicing_index.rs:75:5
|
||||
|
|
||||
LL | v[M];
|
||||
| ^^^^
|
||||
|
|
@ -115,7 +115,7 @@ LL | v[M];
|
|||
= help: consider using `.get(n)` or `.get_mut(n)` instead
|
||||
|
||||
error: index is out of bounds
|
||||
--> tests/ui/indexing_slicing_index.rs:77:13
|
||||
--> tests/ui/indexing_slicing_index.rs:79:13
|
||||
|
|
||||
LL | let _ = x[4];
|
||||
| ^^^^
|
||||
|
|
|
|||
|
|
@ -73,3 +73,5 @@ fn main() {
|
|||
#[allow(clippy::let_underscore_untyped)]
|
||||
let _ = a();
|
||||
}
|
||||
|
||||
async fn dont_lint_async_prototype(_: u8) {}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
#![feature(try_blocks)]
|
||||
#![allow(unused_braces, unused_variables, dead_code)]
|
||||
#![allow(
|
||||
clippy::collapsible_else_if,
|
||||
|
|
@ -446,3 +447,12 @@ struct U<T> {
|
|||
w: T,
|
||||
x: T,
|
||||
}
|
||||
|
||||
fn issue12337() {
|
||||
// We want to generally silence question_mark lints within try blocks, since `?` has different
|
||||
// behavior to `return`, and question_mark calls into manual_let_else logic, so make sure that
|
||||
// we still emit a lint for manual_let_else
|
||||
let _: Option<()> = try {
|
||||
let v = if let Some(v_some) = g() { v_some } else { return };
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: this could be rewritten as `let...else`
|
||||
--> tests/ui/manual_let_else.rs:27:5
|
||||
--> tests/ui/manual_let_else.rs:28:5
|
||||
|
|
||||
LL | let v = if let Some(v_some) = g() { v_some } else { return };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `let Some(v) = g() else { return };`
|
||||
|
|
@ -8,7 +8,7 @@ LL | let v = if let Some(v_some) = g() { v_some } else { return };
|
|||
= help: to override `-D warnings` add `#[allow(clippy::manual_let_else)]`
|
||||
|
||||
error: this could be rewritten as `let...else`
|
||||
--> tests/ui/manual_let_else.rs:30:5
|
||||
--> tests/ui/manual_let_else.rs:31:5
|
||||
|
|
||||
LL | / let v = if let Some(v_some) = g() {
|
||||
LL | |
|
||||
|
|
@ -26,7 +26,7 @@ LL + };
|
|||
|
|
||||
|
||||
error: this could be rewritten as `let...else`
|
||||
--> tests/ui/manual_let_else.rs:37:5
|
||||
--> tests/ui/manual_let_else.rs:38:5
|
||||
|
|
||||
LL | / let v = if let Some(v) = g() {
|
||||
LL | |
|
||||
|
|
@ -47,25 +47,25 @@ LL + };
|
|||
|
|
||||
|
||||
error: this could be rewritten as `let...else`
|
||||
--> tests/ui/manual_let_else.rs:49:9
|
||||
--> tests/ui/manual_let_else.rs:50:9
|
||||
|
|
||||
LL | let v = if let Some(v_some) = g() { v_some } else { continue };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `let Some(v) = g() else { continue };`
|
||||
|
||||
error: this could be rewritten as `let...else`
|
||||
--> tests/ui/manual_let_else.rs:51:9
|
||||
--> tests/ui/manual_let_else.rs:52:9
|
||||
|
|
||||
LL | let v = if let Some(v_some) = g() { v_some } else { break };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `let Some(v) = g() else { break };`
|
||||
|
||||
error: this could be rewritten as `let...else`
|
||||
--> tests/ui/manual_let_else.rs:56:5
|
||||
--> tests/ui/manual_let_else.rs:57:5
|
||||
|
|
||||
LL | let v = if let Some(v_some) = g() { v_some } else { panic!() };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `let Some(v) = g() else { panic!() };`
|
||||
|
||||
error: this could be rewritten as `let...else`
|
||||
--> tests/ui/manual_let_else.rs:60:5
|
||||
--> tests/ui/manual_let_else.rs:61:5
|
||||
|
|
||||
LL | / let v = if let Some(v_some) = g() {
|
||||
LL | |
|
||||
|
|
@ -83,7 +83,7 @@ LL + };
|
|||
|
|
||||
|
||||
error: this could be rewritten as `let...else`
|
||||
--> tests/ui/manual_let_else.rs:68:5
|
||||
--> tests/ui/manual_let_else.rs:69:5
|
||||
|
|
||||
LL | / let v = if let Some(v_some) = g() {
|
||||
LL | |
|
||||
|
|
@ -101,7 +101,7 @@ LL + };
|
|||
|
|
||||
|
||||
error: this could be rewritten as `let...else`
|
||||
--> tests/ui/manual_let_else.rs:76:5
|
||||
--> tests/ui/manual_let_else.rs:77:5
|
||||
|
|
||||
LL | / let v = if let Some(v_some) = g() {
|
||||
LL | |
|
||||
|
|
@ -121,7 +121,7 @@ LL + };
|
|||
|
|
||||
|
||||
error: this could be rewritten as `let...else`
|
||||
--> tests/ui/manual_let_else.rs:85:5
|
||||
--> tests/ui/manual_let_else.rs:86:5
|
||||
|
|
||||
LL | / let v = if let Some(v_some) = g() {
|
||||
LL | |
|
||||
|
|
@ -141,7 +141,7 @@ LL + };
|
|||
|
|
||||
|
||||
error: this could be rewritten as `let...else`
|
||||
--> tests/ui/manual_let_else.rs:94:5
|
||||
--> tests/ui/manual_let_else.rs:95:5
|
||||
|
|
||||
LL | / let v = if let Some(v_some) = g() {
|
||||
LL | |
|
||||
|
|
@ -168,7 +168,7 @@ LL + };
|
|||
|
|
||||
|
||||
error: this could be rewritten as `let...else`
|
||||
--> tests/ui/manual_let_else.rs:110:5
|
||||
--> tests/ui/manual_let_else.rs:111:5
|
||||
|
|
||||
LL | / let v = if let Some(v_some) = g() {
|
||||
LL | |
|
||||
|
|
@ -190,7 +190,7 @@ LL + };
|
|||
|
|
||||
|
||||
error: this could be rewritten as `let...else`
|
||||
--> tests/ui/manual_let_else.rs:121:5
|
||||
--> tests/ui/manual_let_else.rs:122:5
|
||||
|
|
||||
LL | / let v = if let Some(v_some) = g() {
|
||||
LL | |
|
||||
|
|
@ -217,7 +217,7 @@ LL + };
|
|||
|
|
||||
|
||||
error: this could be rewritten as `let...else`
|
||||
--> tests/ui/manual_let_else.rs:137:5
|
||||
--> tests/ui/manual_let_else.rs:138:5
|
||||
|
|
||||
LL | / let v = if let Some(v_some) = g() {
|
||||
LL | |
|
||||
|
|
@ -239,7 +239,7 @@ LL + };
|
|||
|
|
||||
|
||||
error: this could be rewritten as `let...else`
|
||||
--> tests/ui/manual_let_else.rs:148:5
|
||||
--> tests/ui/manual_let_else.rs:149:5
|
||||
|
|
||||
LL | / let v = if let Some(v_some) = g() {
|
||||
LL | |
|
||||
|
|
@ -257,7 +257,7 @@ LL + };
|
|||
|
|
||||
|
||||
error: this could be rewritten as `let...else`
|
||||
--> tests/ui/manual_let_else.rs:156:5
|
||||
--> tests/ui/manual_let_else.rs:157:5
|
||||
|
|
||||
LL | / let v = if let Some(v_some) = g() {
|
||||
LL | |
|
||||
|
|
@ -278,7 +278,7 @@ LL + };
|
|||
|
|
||||
|
||||
error: this could be rewritten as `let...else`
|
||||
--> tests/ui/manual_let_else.rs:166:5
|
||||
--> tests/ui/manual_let_else.rs:167:5
|
||||
|
|
||||
LL | / let v = if let Some(v_some) = g() {
|
||||
LL | |
|
||||
|
|
@ -299,7 +299,7 @@ LL + } };
|
|||
|
|
||||
|
||||
error: this could be rewritten as `let...else`
|
||||
--> tests/ui/manual_let_else.rs:176:5
|
||||
--> tests/ui/manual_let_else.rs:177:5
|
||||
|
|
||||
LL | / let v = if let Some(v_some) = g() {
|
||||
LL | |
|
||||
|
|
@ -328,7 +328,7 @@ LL + };
|
|||
|
|
||||
|
||||
error: this could be rewritten as `let...else`
|
||||
--> tests/ui/manual_let_else.rs:194:5
|
||||
--> tests/ui/manual_let_else.rs:195:5
|
||||
|
|
||||
LL | / let (v, w) = if let Some(v_some) = g().map(|v| (v, 42)) {
|
||||
LL | |
|
||||
|
|
@ -346,7 +346,7 @@ LL + };
|
|||
|
|
||||
|
||||
error: this could be rewritten as `let...else`
|
||||
--> tests/ui/manual_let_else.rs:202:5
|
||||
--> tests/ui/manual_let_else.rs:203:5
|
||||
|
|
||||
LL | / let (w, S { v }) = if let (Some(v_some), w_some) = (g().map(|_| S { v: 0 }), 0) {
|
||||
LL | |
|
||||
|
|
@ -364,7 +364,7 @@ LL + };
|
|||
|
|
||||
|
||||
error: this could be rewritten as `let...else`
|
||||
--> tests/ui/manual_let_else.rs:212:13
|
||||
--> tests/ui/manual_let_else.rs:213:13
|
||||
|
|
||||
LL | let $n = if let Some(v) = $e { v } else { return };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `let Some($n) = g() else { return };`
|
||||
|
|
@ -375,19 +375,19 @@ LL | create_binding_if_some!(w, g());
|
|||
= note: this error originates in the macro `create_binding_if_some` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: this could be rewritten as `let...else`
|
||||
--> tests/ui/manual_let_else.rs:221:5
|
||||
--> tests/ui/manual_let_else.rs:222:5
|
||||
|
|
||||
LL | let v = if let Variant::A(a, 0) = e() { a } else { return };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `let Variant::A(v, 0) = e() else { return };`
|
||||
|
||||
error: this could be rewritten as `let...else`
|
||||
--> tests/ui/manual_let_else.rs:225:5
|
||||
--> tests/ui/manual_let_else.rs:226:5
|
||||
|
|
||||
LL | let mut v = if let Variant::B(b) = e() { b } else { return };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `let Variant::B(mut v) = e() else { return };`
|
||||
|
||||
error: this could be rewritten as `let...else`
|
||||
--> tests/ui/manual_let_else.rs:230:5
|
||||
--> tests/ui/manual_let_else.rs:231:5
|
||||
|
|
||||
LL | / let v = if let Ok(Some(Variant::B(b))) | Err(Some(Variant::A(b, _))) = nested {
|
||||
LL | |
|
||||
|
|
@ -405,19 +405,19 @@ LL + };
|
|||
|
|
||||
|
||||
error: this could be rewritten as `let...else`
|
||||
--> tests/ui/manual_let_else.rs:237:5
|
||||
--> tests/ui/manual_let_else.rs:238:5
|
||||
|
|
||||
LL | let v = if let Variant::A(.., a) = e() { a } else { return };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `let Variant::A(.., v) = e() else { return };`
|
||||
|
||||
error: this could be rewritten as `let...else`
|
||||
--> tests/ui/manual_let_else.rs:241:5
|
||||
--> tests/ui/manual_let_else.rs:242:5
|
||||
|
|
||||
LL | let w = if let (Some(v), ()) = (g(), ()) { v } else { return };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `let (Some(w), ()) = (g(), ()) else { return };`
|
||||
|
||||
error: this could be rewritten as `let...else`
|
||||
--> tests/ui/manual_let_else.rs:245:5
|
||||
--> tests/ui/manual_let_else.rs:246:5
|
||||
|
|
||||
LL | / let w = if let Some(S { v: x }) = Some(S { v: 0 }) {
|
||||
LL | |
|
||||
|
|
@ -435,7 +435,7 @@ LL + };
|
|||
|
|
||||
|
||||
error: this could be rewritten as `let...else`
|
||||
--> tests/ui/manual_let_else.rs:253:5
|
||||
--> tests/ui/manual_let_else.rs:254:5
|
||||
|
|
||||
LL | / let v = if let Some(S { v: x }) = Some(S { v: 0 }) {
|
||||
LL | |
|
||||
|
|
@ -453,7 +453,7 @@ LL + };
|
|||
|
|
||||
|
||||
error: this could be rewritten as `let...else`
|
||||
--> tests/ui/manual_let_else.rs:261:5
|
||||
--> tests/ui/manual_let_else.rs:262:5
|
||||
|
|
||||
LL | / let (x, S { v }, w) = if let Some(U { v, w, x }) = None::<U<S<()>>> {
|
||||
LL | |
|
||||
|
|
@ -471,7 +471,7 @@ LL + };
|
|||
|
|
||||
|
||||
error: this could be rewritten as `let...else`
|
||||
--> tests/ui/manual_let_else.rs:378:5
|
||||
--> tests/ui/manual_let_else.rs:379:5
|
||||
|
|
||||
LL | / let _ = match ff {
|
||||
LL | |
|
||||
|
|
@ -480,5 +480,11 @@ LL | | _ => macro_call!(),
|
|||
LL | | };
|
||||
| |______^ help: consider writing: `let Some(_) = ff else { macro_call!() };`
|
||||
|
||||
error: aborting due to 30 previous errors
|
||||
error: this could be rewritten as `let...else`
|
||||
--> tests/ui/manual_let_else.rs:456:9
|
||||
|
|
||||
LL | let v = if let Some(v_some) = g() { v_some } else { return };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `let Some(v) = g() else { return };`
|
||||
|
||||
error: aborting due to 31 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#![warn(clippy::needless_range_loop, clippy::manual_memcpy)]
|
||||
#![allow(clippy::useless_vec)]
|
||||
#![warn(clippy::manual_memcpy)]
|
||||
#![allow(clippy::assigning_clones, clippy::useless_vec, clippy::needless_range_loop)]
|
||||
|
||||
//@no-rustfix
|
||||
const LOOP_OFFSET: usize = 5000;
|
||||
|
||||
|
|
@ -158,6 +159,59 @@ pub fn manual_copy(src: &[i32], dst: &mut [i32], dst2: &mut [i32]) {
|
|||
//~^ ERROR: it looks like you're manually copying between slices
|
||||
dst[i] = src[i];
|
||||
}
|
||||
|
||||
// Don't trigger lint for following multi-dimensional arrays
|
||||
let src = [[0; 5]; 5];
|
||||
for i in 0..4 {
|
||||
dst[i] = src[i + 1][i];
|
||||
}
|
||||
for i in 0..5 {
|
||||
dst[i] = src[i][i];
|
||||
}
|
||||
for i in 0..5 {
|
||||
dst[i] = src[i][3];
|
||||
}
|
||||
|
||||
let src = [0; 5];
|
||||
let mut dst = [[0; 5]; 5];
|
||||
for i in 0..5 {
|
||||
dst[i][i] = src[i];
|
||||
}
|
||||
|
||||
let src = [[[0; 5]; 5]; 5];
|
||||
let mut dst = [0; 5];
|
||||
for i in 0..5 {
|
||||
dst[i] = src[i][i][i];
|
||||
}
|
||||
for i in 0..5 {
|
||||
dst[i] = src[i][i][0];
|
||||
}
|
||||
for i in 0..5 {
|
||||
dst[i] = src[i][0][i];
|
||||
}
|
||||
for i in 0..5 {
|
||||
dst[i] = src[0][i][i];
|
||||
}
|
||||
for i in 0..5 {
|
||||
dst[i] = src[0][i][1];
|
||||
}
|
||||
for i in 0..5 {
|
||||
dst[i] = src[i][0][1];
|
||||
}
|
||||
|
||||
// Trigger lint
|
||||
let src = [[0; 5]; 5];
|
||||
let mut dst = [0; 5];
|
||||
for i in 0..5 {
|
||||
//~^ ERROR: it looks like you're manually copying between slices
|
||||
dst[i] = src[0][i];
|
||||
}
|
||||
|
||||
let src = [[[0; 5]; 5]; 5];
|
||||
for i in 0..5 {
|
||||
//~^ ERROR: it looks like you're manually copying between slices
|
||||
dst[i] = src[0][1][i];
|
||||
}
|
||||
}
|
||||
|
||||
#[warn(clippy::needless_range_loop, clippy::manual_memcpy)]
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: it looks like you're manually copying between slices
|
||||
--> tests/ui/manual_memcpy/without_loop_counters.rs:8:5
|
||||
--> tests/ui/manual_memcpy/without_loop_counters.rs:9:5
|
||||
|
|
||||
LL | / for i in 0..src.len() {
|
||||
LL | |
|
||||
|
|
@ -12,7 +12,7 @@ LL | | }
|
|||
= help: to override `-D warnings` add `#[allow(clippy::manual_memcpy)]`
|
||||
|
||||
error: it looks like you're manually copying between slices
|
||||
--> tests/ui/manual_memcpy/without_loop_counters.rs:15:5
|
||||
--> tests/ui/manual_memcpy/without_loop_counters.rs:16:5
|
||||
|
|
||||
LL | / for i in 0..src.len() {
|
||||
LL | |
|
||||
|
|
@ -21,7 +21,7 @@ LL | | }
|
|||
| |_____^ help: try replacing the loop by: `dst[10..(src.len() + 10)].copy_from_slice(&src[..]);`
|
||||
|
||||
error: it looks like you're manually copying between slices
|
||||
--> tests/ui/manual_memcpy/without_loop_counters.rs:21:5
|
||||
--> tests/ui/manual_memcpy/without_loop_counters.rs:22:5
|
||||
|
|
||||
LL | / for i in 0..src.len() {
|
||||
LL | |
|
||||
|
|
@ -30,7 +30,7 @@ LL | | }
|
|||
| |_____^ help: try replacing the loop by: `dst[..src.len()].copy_from_slice(&src[10..(src.len() + 10)]);`
|
||||
|
||||
error: it looks like you're manually copying between slices
|
||||
--> tests/ui/manual_memcpy/without_loop_counters.rs:27:5
|
||||
--> tests/ui/manual_memcpy/without_loop_counters.rs:28:5
|
||||
|
|
||||
LL | / for i in 11..src.len() {
|
||||
LL | |
|
||||
|
|
@ -39,7 +39,7 @@ LL | | }
|
|||
| |_____^ help: try replacing the loop by: `dst[11..src.len()].copy_from_slice(&src[(11 - 10)..(src.len() - 10)]);`
|
||||
|
||||
error: it looks like you're manually copying between slices
|
||||
--> tests/ui/manual_memcpy/without_loop_counters.rs:33:5
|
||||
--> tests/ui/manual_memcpy/without_loop_counters.rs:34:5
|
||||
|
|
||||
LL | / for i in 0..dst.len() {
|
||||
LL | |
|
||||
|
|
@ -48,7 +48,7 @@ LL | | }
|
|||
| |_____^ help: try replacing the loop by: `dst.copy_from_slice(&src[..dst.len()]);`
|
||||
|
||||
error: it looks like you're manually copying between slices
|
||||
--> tests/ui/manual_memcpy/without_loop_counters.rs:47:5
|
||||
--> tests/ui/manual_memcpy/without_loop_counters.rs:48:5
|
||||
|
|
||||
LL | / for i in 10..256 {
|
||||
LL | |
|
||||
|
|
@ -64,7 +64,7 @@ LL + dst2[(10 + 500)..(256 + 500)].copy_from_slice(&src[10..256]);
|
|||
|
|
||||
|
||||
error: it looks like you're manually copying between slices
|
||||
--> tests/ui/manual_memcpy/without_loop_counters.rs:60:5
|
||||
--> tests/ui/manual_memcpy/without_loop_counters.rs:61:5
|
||||
|
|
||||
LL | / for i in 10..LOOP_OFFSET {
|
||||
LL | |
|
||||
|
|
@ -73,7 +73,7 @@ LL | | }
|
|||
| |_____^ help: try replacing the loop by: `dst[(10 + LOOP_OFFSET)..(LOOP_OFFSET + LOOP_OFFSET)].copy_from_slice(&src[(10 - some_var)..(LOOP_OFFSET - some_var)]);`
|
||||
|
||||
error: it looks like you're manually copying between slices
|
||||
--> tests/ui/manual_memcpy/without_loop_counters.rs:74:5
|
||||
--> tests/ui/manual_memcpy/without_loop_counters.rs:75:5
|
||||
|
|
||||
LL | / for i in 0..src_vec.len() {
|
||||
LL | |
|
||||
|
|
@ -82,7 +82,7 @@ LL | | }
|
|||
| |_____^ help: try replacing the loop by: `dst_vec[..src_vec.len()].copy_from_slice(&src_vec[..]);`
|
||||
|
||||
error: it looks like you're manually copying between slices
|
||||
--> tests/ui/manual_memcpy/without_loop_counters.rs:104:5
|
||||
--> tests/ui/manual_memcpy/without_loop_counters.rs:105:5
|
||||
|
|
||||
LL | / for i in from..from + src.len() {
|
||||
LL | |
|
||||
|
|
@ -91,7 +91,7 @@ LL | | }
|
|||
| |_____^ help: try replacing the loop by: `dst[from..(from + src.len())].copy_from_slice(&src[..(from + src.len() - from)]);`
|
||||
|
||||
error: it looks like you're manually copying between slices
|
||||
--> tests/ui/manual_memcpy/without_loop_counters.rs:109:5
|
||||
--> tests/ui/manual_memcpy/without_loop_counters.rs:110:5
|
||||
|
|
||||
LL | / for i in from..from + 3 {
|
||||
LL | |
|
||||
|
|
@ -100,7 +100,7 @@ LL | | }
|
|||
| |_____^ help: try replacing the loop by: `dst[from..(from + 3)].copy_from_slice(&src[..(from + 3 - from)]);`
|
||||
|
||||
error: it looks like you're manually copying between slices
|
||||
--> tests/ui/manual_memcpy/without_loop_counters.rs:115:5
|
||||
--> tests/ui/manual_memcpy/without_loop_counters.rs:116:5
|
||||
|
|
||||
LL | / for i in 0..5 {
|
||||
LL | |
|
||||
|
|
@ -109,7 +109,7 @@ LL | | }
|
|||
| |_____^ help: try replacing the loop by: `dst[..5].copy_from_slice(&src);`
|
||||
|
||||
error: it looks like you're manually copying between slices
|
||||
--> tests/ui/manual_memcpy/without_loop_counters.rs:121:5
|
||||
--> tests/ui/manual_memcpy/without_loop_counters.rs:122:5
|
||||
|
|
||||
LL | / for i in 0..0 {
|
||||
LL | |
|
||||
|
|
@ -118,7 +118,7 @@ LL | | }
|
|||
| |_____^ help: try replacing the loop by: `dst[..0].copy_from_slice(&src[..0]);`
|
||||
|
||||
error: it looks like you're manually copying between slices
|
||||
--> tests/ui/manual_memcpy/without_loop_counters.rs:145:5
|
||||
--> tests/ui/manual_memcpy/without_loop_counters.rs:146:5
|
||||
|
|
||||
LL | / for i in 0..4 {
|
||||
LL | |
|
||||
|
|
@ -127,7 +127,7 @@ LL | | }
|
|||
| |_____^ help: try replacing the loop by: `dst.copy_from_slice(&src[..4]);`
|
||||
|
||||
error: it looks like you're manually copying between slices
|
||||
--> tests/ui/manual_memcpy/without_loop_counters.rs:151:5
|
||||
--> tests/ui/manual_memcpy/without_loop_counters.rs:152:5
|
||||
|
|
||||
LL | / for i in 0..5 {
|
||||
LL | |
|
||||
|
|
@ -136,7 +136,7 @@ LL | | }
|
|||
| |_____^ help: try replacing the loop by: `dst[..5].copy_from_slice(&src);`
|
||||
|
||||
error: it looks like you're manually copying between slices
|
||||
--> tests/ui/manual_memcpy/without_loop_counters.rs:157:5
|
||||
--> tests/ui/manual_memcpy/without_loop_counters.rs:158:5
|
||||
|
|
||||
LL | / for i in 0..5 {
|
||||
LL | |
|
||||
|
|
@ -145,7 +145,25 @@ LL | | }
|
|||
| |_____^ help: try replacing the loop by: `dst.copy_from_slice(&src);`
|
||||
|
||||
error: it looks like you're manually copying between slices
|
||||
--> tests/ui/manual_memcpy/without_loop_counters.rs:165:5
|
||||
--> tests/ui/manual_memcpy/without_loop_counters.rs:205:5
|
||||
|
|
||||
LL | / for i in 0..5 {
|
||||
LL | |
|
||||
LL | | dst[i] = src[0][i];
|
||||
LL | | }
|
||||
| |_____^ help: try replacing the loop by: `dst.copy_from_slice(&src[0]);`
|
||||
|
||||
error: it looks like you're manually copying between slices
|
||||
--> tests/ui/manual_memcpy/without_loop_counters.rs:211:5
|
||||
|
|
||||
LL | / for i in 0..5 {
|
||||
LL | |
|
||||
LL | | dst[i] = src[0][1][i];
|
||||
LL | | }
|
||||
| |_____^ help: try replacing the loop by: `dst.copy_from_slice(&src[0][1]);`
|
||||
|
||||
error: it looks like you're manually copying between slices
|
||||
--> tests/ui/manual_memcpy/without_loop_counters.rs:219:5
|
||||
|
|
||||
LL | / for i in 0..src.len() {
|
||||
LL | |
|
||||
|
|
@ -153,5 +171,5 @@ LL | | dst[i] = src[i].clone();
|
|||
LL | | }
|
||||
| |_____^ help: try replacing the loop by: `dst[..src.len()].clone_from_slice(&src[..]);`
|
||||
|
||||
error: aborting due to 16 previous errors
|
||||
error: aborting due to 18 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
//@compile-flags: -Zdeduplicate-diagnostics=yes
|
||||
|
||||
#![warn(clippy::manual_retain)]
|
||||
#![allow(unused, clippy::redundant_clone)]
|
||||
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
//@compile-flags: -Zdeduplicate-diagnostics=yes
|
||||
|
||||
#![warn(clippy::manual_retain)]
|
||||
#![allow(unused, clippy::redundant_clone)]
|
||||
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: this expression can be written more simply using `.retain()`
|
||||
--> tests/ui/manual_retain.rs:25:5
|
||||
--> tests/ui/manual_retain.rs:27:5
|
||||
|
|
||||
LL | binary_heap = binary_heap.into_iter().filter(|x| x % 2 == 0).collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `binary_heap.retain(|x| x % 2 == 0)`
|
||||
|
|
@ -8,43 +8,43 @@ LL | binary_heap = binary_heap.into_iter().filter(|x| x % 2 == 0).collect();
|
|||
= help: to override `-D warnings` add `#[allow(clippy::manual_retain)]`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> tests/ui/manual_retain.rs:26:5
|
||||
--> tests/ui/manual_retain.rs:28:5
|
||||
|
|
||||
LL | binary_heap = binary_heap.iter().filter(|&x| x % 2 == 0).copied().collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `binary_heap.retain(|x| x % 2 == 0)`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> tests/ui/manual_retain.rs:27:5
|
||||
--> tests/ui/manual_retain.rs:29:5
|
||||
|
|
||||
LL | binary_heap = binary_heap.iter().filter(|&x| x % 2 == 0).cloned().collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `binary_heap.retain(|x| x % 2 == 0)`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> tests/ui/manual_retain.rs:31:5
|
||||
--> tests/ui/manual_retain.rs:33:5
|
||||
|
|
||||
LL | tuples = tuples.iter().filter(|(ref x, ref y)| *x == 0).copied().collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `tuples.retain(|(ref x, ref y)| *x == 0)`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> tests/ui/manual_retain.rs:32:5
|
||||
--> tests/ui/manual_retain.rs:34:5
|
||||
|
|
||||
LL | tuples = tuples.iter().filter(|(x, y)| *x == 0).copied().collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `tuples.retain(|(x, y)| *x == 0)`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> tests/ui/manual_retain.rs:62:5
|
||||
--> tests/ui/manual_retain.rs:64: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)`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> tests/ui/manual_retain.rs:63:5
|
||||
--> tests/ui/manual_retain.rs:65: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()`
|
||||
--> tests/ui/manual_retain.rs:64:5
|
||||
--> tests/ui/manual_retain.rs:66:5
|
||||
|
|
||||
LL | / btree_map = btree_map
|
||||
LL | | .into_iter()
|
||||
|
|
@ -53,49 +53,49 @@ 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()`
|
||||
--> tests/ui/manual_retain.rs:89:5
|
||||
--> tests/ui/manual_retain.rs:91: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()`
|
||||
--> tests/ui/manual_retain.rs:90:5
|
||||
--> tests/ui/manual_retain.rs:92: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()`
|
||||
--> tests/ui/manual_retain.rs:91:5
|
||||
--> tests/ui/manual_retain.rs:93: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()`
|
||||
--> tests/ui/manual_retain.rs:95:5
|
||||
--> tests/ui/manual_retain.rs:97:5
|
||||
|
|
||||
LL | tuples = tuples.iter().filter(|(ref x, ref y)| *x == 0).copied().collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `tuples.retain(|(ref x, ref y)| *x == 0)`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> tests/ui/manual_retain.rs:96:5
|
||||
--> tests/ui/manual_retain.rs:98:5
|
||||
|
|
||||
LL | tuples = tuples.iter().filter(|(x, y)| *x == 0).copied().collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `tuples.retain(|(x, y)| *x == 0)`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> tests/ui/manual_retain.rs:126:5
|
||||
--> tests/ui/manual_retain.rs:128: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()`
|
||||
--> tests/ui/manual_retain.rs:127:5
|
||||
--> tests/ui/manual_retain.rs:129: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()`
|
||||
--> tests/ui/manual_retain.rs:128:5
|
||||
--> tests/ui/manual_retain.rs:130:5
|
||||
|
|
||||
LL | / hash_map = hash_map
|
||||
LL | | .into_iter()
|
||||
|
|
@ -104,133 +104,133 @@ 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()`
|
||||
--> tests/ui/manual_retain.rs:152:5
|
||||
--> tests/ui/manual_retain.rs:154: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()`
|
||||
--> tests/ui/manual_retain.rs:153:5
|
||||
--> tests/ui/manual_retain.rs:155: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()`
|
||||
--> tests/ui/manual_retain.rs:154:5
|
||||
--> tests/ui/manual_retain.rs:156: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()`
|
||||
--> tests/ui/manual_retain.rs:158:5
|
||||
--> tests/ui/manual_retain.rs:160:5
|
||||
|
|
||||
LL | tuples = tuples.iter().filter(|(ref x, ref y)| *x == 0).copied().collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `tuples.retain(|(ref x, ref y)| *x == 0)`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> tests/ui/manual_retain.rs:159:5
|
||||
--> tests/ui/manual_retain.rs:161:5
|
||||
|
|
||||
LL | tuples = tuples.iter().filter(|(x, y)| *x == 0).copied().collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `tuples.retain(|(x, y)| *x == 0)`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> tests/ui/manual_retain.rs:188:5
|
||||
--> tests/ui/manual_retain.rs:190: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()`
|
||||
--> tests/ui/manual_retain.rs:200:5
|
||||
--> tests/ui/manual_retain.rs:202: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()`
|
||||
--> tests/ui/manual_retain.rs:201:5
|
||||
--> tests/ui/manual_retain.rs:203: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()`
|
||||
--> tests/ui/manual_retain.rs:202:5
|
||||
--> tests/ui/manual_retain.rs:204: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()`
|
||||
--> tests/ui/manual_retain.rs:206:5
|
||||
--> tests/ui/manual_retain.rs:208:5
|
||||
|
|
||||
LL | tuples = tuples.iter().filter(|(ref x, ref y)| *x == 0).copied().collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `tuples.retain(|(ref x, ref y)| *x == 0)`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> tests/ui/manual_retain.rs:207:5
|
||||
--> tests/ui/manual_retain.rs:209:5
|
||||
|
|
||||
LL | tuples = tuples.iter().filter(|(x, y)| *x == 0).copied().collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `tuples.retain(|(x, y)| *x == 0)`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> tests/ui/manual_retain.rs:229:5
|
||||
--> tests/ui/manual_retain.rs:231: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()`
|
||||
--> tests/ui/manual_retain.rs:230:5
|
||||
--> tests/ui/manual_retain.rs:232: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()`
|
||||
--> tests/ui/manual_retain.rs:231:5
|
||||
--> tests/ui/manual_retain.rs:233: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)`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> tests/ui/manual_retain.rs:288:5
|
||||
--> tests/ui/manual_retain.rs:290:5
|
||||
|
|
||||
LL | vec = vec.into_iter().filter(|(x, y)| *x == 0).collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec.retain(|(x, y)| *x == 0)`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> tests/ui/manual_retain.rs:292:5
|
||||
--> tests/ui/manual_retain.rs:294:5
|
||||
|
|
||||
LL | tuples = tuples.into_iter().filter(|(_, n)| *n > 0).collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `tuples.retain(|(_, n)| *n > 0)`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> tests/ui/manual_retain.rs:309:5
|
||||
--> tests/ui/manual_retain.rs:311:5
|
||||
|
|
||||
LL | vec = vec.iter().filter(|&&x| x == 0).copied().collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec.retain(|&x| x == 0)`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> tests/ui/manual_retain.rs:310:5
|
||||
--> tests/ui/manual_retain.rs:312:5
|
||||
|
|
||||
LL | vec = vec.iter().filter(|&&x| x == 0).cloned().collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec.retain(|&x| x == 0)`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> tests/ui/manual_retain.rs:311:5
|
||||
--> tests/ui/manual_retain.rs:313:5
|
||||
|
|
||||
LL | vec = vec.into_iter().filter(|&x| x == 0).collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec.retain(|&x| x == 0)`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> tests/ui/manual_retain.rs:314:5
|
||||
--> tests/ui/manual_retain.rs:316:5
|
||||
|
|
||||
LL | vec = vec.iter().filter(|&x| *x == 0).copied().collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec.retain(|x| *x == 0)`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> tests/ui/manual_retain.rs:315:5
|
||||
--> tests/ui/manual_retain.rs:317:5
|
||||
|
|
||||
LL | vec = vec.iter().filter(|&x| *x == 0).cloned().collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec.retain(|x| *x == 0)`
|
||||
|
||||
error: this expression can be written more simply using `.retain()`
|
||||
--> tests/ui/manual_retain.rs:316:5
|
||||
--> tests/ui/manual_retain.rs:318:5
|
||||
|
|
||||
LL | vec = vec.into_iter().filter(|x| *x == 0).collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling `.retain()` instead: `vec.retain(|x| *x == 0)`
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
//@compile-flags: -Zdeduplicate-diagnostics=yes
|
||||
|
||||
#![allow(clippy::too_many_arguments, clippy::diverging_sub_expression)]
|
||||
#![warn(clippy::many_single_char_names)]
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: 5 bindings with single-character names in scope
|
||||
--> tests/ui/many_single_char_names.rs:5:9
|
||||
--> tests/ui/many_single_char_names.rs:7:9
|
||||
|
|
||||
LL | let a: i32;
|
||||
| ^
|
||||
|
|
@ -14,7 +14,7 @@ LL | let e: i32;
|
|||
= help: to override `-D warnings` add `#[allow(clippy::many_single_char_names)]`
|
||||
|
||||
error: 6 bindings with single-character names in scope
|
||||
--> tests/ui/many_single_char_names.rs:5:9
|
||||
--> tests/ui/many_single_char_names.rs:7:9
|
||||
|
|
||||
LL | let a: i32;
|
||||
| ^
|
||||
|
|
@ -28,7 +28,7 @@ LL | let f: i32;
|
|||
| ^
|
||||
|
||||
error: 5 bindings with single-character names in scope
|
||||
--> tests/ui/many_single_char_names.rs:5:9
|
||||
--> tests/ui/many_single_char_names.rs:7:9
|
||||
|
|
||||
LL | let a: i32;
|
||||
| ^
|
||||
|
|
@ -40,13 +40,13 @@ LL | e => panic!(),
|
|||
| ^
|
||||
|
||||
error: 8 bindings with single-character names in scope
|
||||
--> tests/ui/many_single_char_names.rs:34:13
|
||||
--> tests/ui/many_single_char_names.rs:36:13
|
||||
|
|
||||
LL | fn bindings(a: i32, b: i32, c: i32, d: i32, e: i32, f: i32, g: i32, h: i32) {}
|
||||
| ^ ^ ^ ^ ^ ^ ^ ^
|
||||
|
||||
error: 8 bindings with single-character names in scope
|
||||
--> tests/ui/many_single_char_names.rs:38:10
|
||||
--> tests/ui/many_single_char_names.rs:40:10
|
||||
|
|
||||
LL | let (a, b, c, d, e, f, g, h): (bool, bool, bool, bool, bool, bool, bool, bool) = unimplemented!();
|
||||
| ^ ^ ^ ^ ^ ^ ^ ^
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
//@compile-flags: -Zdeduplicate-diagnostics=yes
|
||||
|
||||
#![feature(custom_inner_attributes)]
|
||||
#![clippy::msrv = "invalid.version"]
|
||||
//~^ ERROR: `invalid.version` is not a valid Rust version
|
||||
|
|
|
|||
|
|
@ -1,35 +1,35 @@
|
|||
error: `invalid.version` is not a valid Rust version
|
||||
--> tests/ui/min_rust_version_invalid_attr.rs:2:1
|
||||
--> tests/ui/min_rust_version_invalid_attr.rs:4:1
|
||||
|
|
||||
LL | #![clippy::msrv = "invalid.version"]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: `invalid.version` is not a valid Rust version
|
||||
--> tests/ui/min_rust_version_invalid_attr.rs:7:1
|
||||
--> tests/ui/min_rust_version_invalid_attr.rs:9:1
|
||||
|
|
||||
LL | #[clippy::msrv = "invalid.version"]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: `clippy::msrv` is defined multiple times
|
||||
--> tests/ui/min_rust_version_invalid_attr.rs:14:5
|
||||
--> tests/ui/min_rust_version_invalid_attr.rs:16:5
|
||||
|
|
||||
LL | #![clippy::msrv = "1.10.1"]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: first definition found here
|
||||
--> tests/ui/min_rust_version_invalid_attr.rs:12:5
|
||||
--> tests/ui/min_rust_version_invalid_attr.rs:14:5
|
||||
|
|
||||
LL | #![clippy::msrv = "1.40"]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: `clippy::msrv` is defined multiple times
|
||||
--> tests/ui/min_rust_version_invalid_attr.rs:19:9
|
||||
--> tests/ui/min_rust_version_invalid_attr.rs:21:9
|
||||
|
|
||||
LL | #![clippy::msrv = "1.0.0"]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: first definition found here
|
||||
--> tests/ui/min_rust_version_invalid_attr.rs:18:9
|
||||
--> tests/ui/min_rust_version_invalid_attr.rs:20:9
|
||||
|
|
||||
LL | #![clippy::msrv = "1"]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
|
|||
39
tests/ui/mixed_attributes_style.rs
Normal file
39
tests/ui/mixed_attributes_style.rs
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
#![warn(clippy::mixed_attributes_style)]
|
||||
|
||||
#[allow(unused)] //~ ERROR: item has both inner and outer attributes
|
||||
fn foo1() {
|
||||
#![allow(unused)]
|
||||
}
|
||||
|
||||
#[allow(unused)]
|
||||
#[allow(unused)]
|
||||
fn foo2() {}
|
||||
|
||||
fn foo3() {
|
||||
#![allow(unused)]
|
||||
#![allow(unused)]
|
||||
}
|
||||
|
||||
/// linux
|
||||
//~^ ERROR: item has both inner and outer attributes
|
||||
fn foo4() {
|
||||
//! windows
|
||||
}
|
||||
|
||||
/// linux
|
||||
/// windows
|
||||
fn foo5() {}
|
||||
|
||||
fn foo6() {
|
||||
//! linux
|
||||
//! windows
|
||||
}
|
||||
|
||||
#[allow(unused)] //~ ERROR: item has both inner and outer attributes
|
||||
mod bar {
|
||||
#![allow(unused)]
|
||||
}
|
||||
|
||||
fn main() {
|
||||
// test code goes here
|
||||
}
|
||||
30
tests/ui/mixed_attributes_style.stderr
Normal file
30
tests/ui/mixed_attributes_style.stderr
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
error: item has both inner and outer attributes
|
||||
--> tests/ui/mixed_attributes_style.rs:3:1
|
||||
|
|
||||
LL | / #[allow(unused)]
|
||||
LL | | fn foo1() {
|
||||
LL | | #![allow(unused)]
|
||||
| |_____________________^
|
||||
|
|
||||
= note: `-D clippy::mixed-attributes-style` implied by `-D warnings`
|
||||
= help: to override `-D warnings` add `#[allow(clippy::mixed_attributes_style)]`
|
||||
|
||||
error: item has both inner and outer attributes
|
||||
--> tests/ui/mixed_attributes_style.rs:17:1
|
||||
|
|
||||
LL | / /// linux
|
||||
LL | |
|
||||
LL | | fn foo4() {
|
||||
LL | | //! windows
|
||||
| |_______________^
|
||||
|
||||
error: item has both inner and outer attributes
|
||||
--> tests/ui/mixed_attributes_style.rs:32:1
|
||||
|
|
||||
LL | / #[allow(unused)]
|
||||
LL | | mod bar {
|
||||
LL | | #![allow(unused)]
|
||||
| |_____________________^
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
//@aux-build:proc_macros.rs
|
||||
//@compile-flags: -Zdeduplicate-diagnostics=yes
|
||||
|
||||
#![warn(clippy::mut_mut)]
|
||||
#![allow(unused)]
|
||||
#![allow(
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: generally you want to avoid `&mut &mut _` if possible
|
||||
--> tests/ui/mut_mut.rs:14:11
|
||||
--> tests/ui/mut_mut.rs:16:11
|
||||
|
|
||||
LL | fn fun(x: &mut &mut u32) -> bool {
|
||||
| ^^^^^^^^^^^^^
|
||||
|
|
@ -8,13 +8,13 @@ LL | fn fun(x: &mut &mut u32) -> bool {
|
|||
= help: to override `-D warnings` add `#[allow(clippy::mut_mut)]`
|
||||
|
||||
error: generally you want to avoid `&mut &mut _` if possible
|
||||
--> tests/ui/mut_mut.rs:31:17
|
||||
--> tests/ui/mut_mut.rs:33:17
|
||||
|
|
||||
LL | let mut x = &mut &mut 1u32;
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
||||
error: generally you want to avoid `&mut &mut _` if possible
|
||||
--> tests/ui/mut_mut.rs:46:25
|
||||
--> tests/ui/mut_mut.rs:48:25
|
||||
|
|
||||
LL | let mut z = inline!(&mut $(&mut 3u32));
|
||||
| ^
|
||||
|
|
@ -22,37 +22,37 @@ LL | let mut z = inline!(&mut $(&mut 3u32));
|
|||
= note: this error originates in the macro `__inline_mac_fn_main` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: this expression mutably borrows a mutable reference. Consider reborrowing
|
||||
--> tests/ui/mut_mut.rs:33:21
|
||||
--> tests/ui/mut_mut.rs:35:21
|
||||
|
|
||||
LL | let mut y = &mut x;
|
||||
| ^^^^^^
|
||||
|
||||
error: generally you want to avoid `&mut &mut _` if possible
|
||||
--> tests/ui/mut_mut.rs:37:32
|
||||
--> tests/ui/mut_mut.rs:39:32
|
||||
|
|
||||
LL | let y: &mut &mut u32 = &mut &mut 2;
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error: generally you want to avoid `&mut &mut _` if possible
|
||||
--> tests/ui/mut_mut.rs:37:16
|
||||
--> tests/ui/mut_mut.rs:39:16
|
||||
|
|
||||
LL | let y: &mut &mut u32 = &mut &mut 2;
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: generally you want to avoid `&mut &mut _` if possible
|
||||
--> tests/ui/mut_mut.rs:42:37
|
||||
--> tests/ui/mut_mut.rs:44:37
|
||||
|
|
||||
LL | let y: &mut &mut &mut u32 = &mut &mut &mut 2;
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
error: generally you want to avoid `&mut &mut _` if possible
|
||||
--> tests/ui/mut_mut.rs:42:16
|
||||
--> tests/ui/mut_mut.rs:44:16
|
||||
|
|
||||
LL | let y: &mut &mut &mut u32 = &mut &mut &mut 2;
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: generally you want to avoid `&mut &mut _` if possible
|
||||
--> tests/ui/mut_mut.rs:42:21
|
||||
--> tests/ui/mut_mut.rs:44:21
|
||||
|
|
||||
LL | let y: &mut &mut &mut u32 = &mut &mut &mut 2;
|
||||
| ^^^^^^^^^^^^^
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
//@compile-flags: -Zdeduplicate-diagnostics=yes
|
||||
|
||||
#![warn(clippy::no_effect_replace)]
|
||||
|
||||
fn main() {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: replacing text with itself
|
||||
--> tests/ui/no_effect_replace.rs:4:13
|
||||
--> tests/ui/no_effect_replace.rs:6:13
|
||||
|
|
||||
LL | let _ = "12345".replace('1', "1");
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -8,43 +8,43 @@ LL | let _ = "12345".replace('1', "1");
|
|||
= help: to override `-D warnings` add `#[allow(clippy::no_effect_replace)]`
|
||||
|
||||
error: replacing text with itself
|
||||
--> tests/ui/no_effect_replace.rs:7:13
|
||||
--> tests/ui/no_effect_replace.rs:9:13
|
||||
|
|
||||
LL | let _ = "12345".replace("12", "12");
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: replacing text with itself
|
||||
--> tests/ui/no_effect_replace.rs:9:13
|
||||
--> tests/ui/no_effect_replace.rs:11:13
|
||||
|
|
||||
LL | let _ = String::new().replace("12", "12");
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: replacing text with itself
|
||||
--> tests/ui/no_effect_replace.rs:12:13
|
||||
--> tests/ui/no_effect_replace.rs:14:13
|
||||
|
|
||||
LL | let _ = "12345".replacen('1', "1", 1);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: replacing text with itself
|
||||
--> tests/ui/no_effect_replace.rs:14:13
|
||||
--> tests/ui/no_effect_replace.rs:16:13
|
||||
|
|
||||
LL | let _ = "12345".replacen("12", "12", 1);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: replacing text with itself
|
||||
--> tests/ui/no_effect_replace.rs:16:13
|
||||
--> tests/ui/no_effect_replace.rs:18:13
|
||||
|
|
||||
LL | let _ = String::new().replacen("12", "12", 1);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: replacing text with itself
|
||||
--> tests/ui/no_effect_replace.rs:23:13
|
||||
--> tests/ui/no_effect_replace.rs:25:13
|
||||
|
|
||||
LL | let _ = "hello".replace(&x.f(), &x.f());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: replacing text with itself
|
||||
--> tests/ui/no_effect_replace.rs:27:13
|
||||
--> tests/ui/no_effect_replace.rs:29:13
|
||||
|
|
||||
LL | let _ = "hello".replace(&y(), &y());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
#![allow(clippy::clone_on_copy, unused)]
|
||||
#![allow(clippy::assigning_clones)]
|
||||
#![no_main]
|
||||
|
||||
// lint
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
#![allow(clippy::clone_on_copy, unused)]
|
||||
#![allow(clippy::assigning_clones)]
|
||||
#![no_main]
|
||||
|
||||
// lint
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: non-canonical implementation of `clone` on a `Copy` type
|
||||
--> tests/ui/non_canonical_clone_impl.rs:9:29
|
||||
--> tests/ui/non_canonical_clone_impl.rs:10:29
|
||||
|
|
||||
LL | fn clone(&self) -> Self {
|
||||
| _____________________________^
|
||||
|
|
@ -11,7 +11,7 @@ LL | | }
|
|||
= help: to override `-D warnings` add `#[allow(clippy::non_canonical_clone_impl)]`
|
||||
|
||||
error: unnecessary implementation of `clone_from` on a `Copy` type
|
||||
--> tests/ui/non_canonical_clone_impl.rs:13:5
|
||||
--> tests/ui/non_canonical_clone_impl.rs:14:5
|
||||
|
|
||||
LL | / fn clone_from(&mut self, source: &Self) {
|
||||
LL | | source.clone();
|
||||
|
|
@ -20,7 +20,7 @@ LL | | }
|
|||
| |_____^ help: remove it
|
||||
|
||||
error: non-canonical implementation of `clone` on a `Copy` type
|
||||
--> tests/ui/non_canonical_clone_impl.rs:80:29
|
||||
--> tests/ui/non_canonical_clone_impl.rs:81:29
|
||||
|
|
||||
LL | fn clone(&self) -> Self {
|
||||
| _____________________________^
|
||||
|
|
@ -29,7 +29,7 @@ LL | | }
|
|||
| |_____^ help: change this to: `{ *self }`
|
||||
|
||||
error: unnecessary implementation of `clone_from` on a `Copy` type
|
||||
--> tests/ui/non_canonical_clone_impl.rs:84:5
|
||||
--> tests/ui/non_canonical_clone_impl.rs:85:5
|
||||
|
|
||||
LL | / fn clone_from(&mut self, source: &Self) {
|
||||
LL | | source.clone();
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
//@no-rustfix: overlapping suggestions
|
||||
|
||||
#![feature(lint_reasons)]
|
||||
#![allow(
|
||||
unused,
|
||||
|
|
@ -173,3 +174,8 @@ fn issue_5794() {
|
|||
if !b == !c {} //~ ERROR: this boolean expression can be simplified
|
||||
if !b != !c {} //~ ERROR: this boolean expression can be simplified
|
||||
}
|
||||
|
||||
fn issue_12371(x: usize) -> bool {
|
||||
// Should not warn!
|
||||
!x != 0
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: this boolean expression can be simplified
|
||||
--> tests/ui/nonminimal_bool.rs:18:13
|
||||
--> tests/ui/nonminimal_bool.rs:19:13
|
||||
|
|
||||
LL | let _ = !true;
|
||||
| ^^^^^ help: try: `false`
|
||||
|
|
@ -8,43 +8,43 @@ LL | let _ = !true;
|
|||
= help: to override `-D warnings` add `#[allow(clippy::nonminimal_bool)]`
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> tests/ui/nonminimal_bool.rs:21:13
|
||||
--> tests/ui/nonminimal_bool.rs:22:13
|
||||
|
|
||||
LL | let _ = !false;
|
||||
| ^^^^^^ help: try: `true`
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> tests/ui/nonminimal_bool.rs:23:13
|
||||
--> tests/ui/nonminimal_bool.rs:24:13
|
||||
|
|
||||
LL | let _ = !!a;
|
||||
| ^^^ help: try: `a`
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> tests/ui/nonminimal_bool.rs:25:13
|
||||
--> tests/ui/nonminimal_bool.rs:26:13
|
||||
|
|
||||
LL | let _ = false || a;
|
||||
| ^^^^^^^^^^ help: try: `a`
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> tests/ui/nonminimal_bool.rs:30:13
|
||||
--> tests/ui/nonminimal_bool.rs:31:13
|
||||
|
|
||||
LL | let _ = !(!a && b);
|
||||
| ^^^^^^^^^^ help: try: `a || !b`
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> tests/ui/nonminimal_bool.rs:32:13
|
||||
--> tests/ui/nonminimal_bool.rs:33:13
|
||||
|
|
||||
LL | let _ = !(!a || b);
|
||||
| ^^^^^^^^^^ help: try: `a && !b`
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> tests/ui/nonminimal_bool.rs:34:13
|
||||
--> tests/ui/nonminimal_bool.rs:35:13
|
||||
|
|
||||
LL | let _ = !a && !(b && c);
|
||||
| ^^^^^^^^^^^^^^^ help: try: `!(a || b && c)`
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> tests/ui/nonminimal_bool.rs:43:13
|
||||
--> tests/ui/nonminimal_bool.rs:44:13
|
||||
|
|
||||
LL | let _ = a == b && c == 5 && a == b;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -57,7 +57,7 @@ LL | let _ = a == b && c == 5;
|
|||
| ~~~~~~~~~~~~~~~~
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> tests/ui/nonminimal_bool.rs:45:13
|
||||
--> tests/ui/nonminimal_bool.rs:46:13
|
||||
|
|
||||
LL | let _ = a == b || c == 5 || a == b;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -70,7 +70,7 @@ LL | let _ = a == b || c == 5;
|
|||
| ~~~~~~~~~~~~~~~~
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> tests/ui/nonminimal_bool.rs:47:13
|
||||
--> tests/ui/nonminimal_bool.rs:48:13
|
||||
|
|
||||
LL | let _ = a == b && c == 5 && b == a;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -83,7 +83,7 @@ LL | let _ = a == b && c == 5;
|
|||
| ~~~~~~~~~~~~~~~~
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> tests/ui/nonminimal_bool.rs:49:13
|
||||
--> tests/ui/nonminimal_bool.rs:50:13
|
||||
|
|
||||
LL | let _ = a != b || !(a != b || c == d);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -96,7 +96,7 @@ LL | let _ = a != b || c != d;
|
|||
| ~~~~~~~~~~~~~~~~
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> tests/ui/nonminimal_bool.rs:51:13
|
||||
--> tests/ui/nonminimal_bool.rs:52:13
|
||||
|
|
||||
LL | let _ = a != b && !(a != b && c == d);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -109,43 +109,43 @@ LL | let _ = a != b && c != d;
|
|||
| ~~~~~~~~~~~~~~~~
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> tests/ui/nonminimal_bool.rs:82:8
|
||||
--> tests/ui/nonminimal_bool.rs:83:8
|
||||
|
|
||||
LL | if matches!(true, true) && true {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `matches!(true, true)`
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> tests/ui/nonminimal_bool.rs:162:8
|
||||
--> tests/ui/nonminimal_bool.rs:163:8
|
||||
|
|
||||
LL | if !(12 == a) {}
|
||||
| ^^^^^^^^^^ help: try: `12 != a`
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> tests/ui/nonminimal_bool.rs:163:8
|
||||
--> tests/ui/nonminimal_bool.rs:164:8
|
||||
|
|
||||
LL | if !(a == 12) {}
|
||||
| ^^^^^^^^^^ help: try: `a != 12`
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> tests/ui/nonminimal_bool.rs:164:8
|
||||
--> tests/ui/nonminimal_bool.rs:165:8
|
||||
|
|
||||
LL | if !(12 != a) {}
|
||||
| ^^^^^^^^^^ help: try: `12 == a`
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> tests/ui/nonminimal_bool.rs:165:8
|
||||
--> tests/ui/nonminimal_bool.rs:166:8
|
||||
|
|
||||
LL | if !(a != 12) {}
|
||||
| ^^^^^^^^^^ help: try: `a == 12`
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> tests/ui/nonminimal_bool.rs:169:8
|
||||
--> tests/ui/nonminimal_bool.rs:170:8
|
||||
|
|
||||
LL | if !b == true {}
|
||||
| ^^^^^^^^^^ help: try: `b != true`
|
||||
|
||||
error: this comparison might be written more concisely
|
||||
--> tests/ui/nonminimal_bool.rs:169:8
|
||||
--> tests/ui/nonminimal_bool.rs:170:8
|
||||
|
|
||||
LL | if !b == true {}
|
||||
| ^^^^^^^^^^ help: try simplifying it as shown: `b != true`
|
||||
|
|
@ -154,61 +154,61 @@ LL | if !b == true {}
|
|||
= help: to override `-D warnings` add `#[allow(clippy::bool_comparison)]`
|
||||
|
||||
error: equality checks against true are unnecessary
|
||||
--> tests/ui/nonminimal_bool.rs:169:8
|
||||
--> tests/ui/nonminimal_bool.rs:170:8
|
||||
|
|
||||
LL | if !b == true {}
|
||||
| ^^^^^^^^^^ help: try simplifying it as shown: `!b`
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> tests/ui/nonminimal_bool.rs:170:8
|
||||
--> tests/ui/nonminimal_bool.rs:171:8
|
||||
|
|
||||
LL | if !b != true {}
|
||||
| ^^^^^^^^^^ help: try: `b == true`
|
||||
|
||||
error: inequality checks against true can be replaced by a negation
|
||||
--> tests/ui/nonminimal_bool.rs:170:8
|
||||
--> tests/ui/nonminimal_bool.rs:171:8
|
||||
|
|
||||
LL | if !b != true {}
|
||||
| ^^^^^^^^^^ help: try simplifying it as shown: `!(!b)`
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> tests/ui/nonminimal_bool.rs:171:8
|
||||
--> tests/ui/nonminimal_bool.rs:172:8
|
||||
|
|
||||
LL | if true == !b {}
|
||||
| ^^^^^^^^^^ help: try: `true != b`
|
||||
|
||||
error: this comparison might be written more concisely
|
||||
--> tests/ui/nonminimal_bool.rs:171:8
|
||||
--> tests/ui/nonminimal_bool.rs:172:8
|
||||
|
|
||||
LL | if true == !b {}
|
||||
| ^^^^^^^^^^ help: try simplifying it as shown: `true != b`
|
||||
|
||||
error: equality checks against true are unnecessary
|
||||
--> tests/ui/nonminimal_bool.rs:171:8
|
||||
--> tests/ui/nonminimal_bool.rs:172:8
|
||||
|
|
||||
LL | if true == !b {}
|
||||
| ^^^^^^^^^^ help: try simplifying it as shown: `!b`
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> tests/ui/nonminimal_bool.rs:172:8
|
||||
--> tests/ui/nonminimal_bool.rs:173:8
|
||||
|
|
||||
LL | if true != !b {}
|
||||
| ^^^^^^^^^^ help: try: `true == b`
|
||||
|
||||
error: inequality checks against true can be replaced by a negation
|
||||
--> tests/ui/nonminimal_bool.rs:172:8
|
||||
--> tests/ui/nonminimal_bool.rs:173:8
|
||||
|
|
||||
LL | if true != !b {}
|
||||
| ^^^^^^^^^^ help: try simplifying it as shown: `!(!b)`
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> tests/ui/nonminimal_bool.rs:173:8
|
||||
--> tests/ui/nonminimal_bool.rs:174:8
|
||||
|
|
||||
LL | if !b == !c {}
|
||||
| ^^^^^^^^ help: try: `b == c`
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> tests/ui/nonminimal_bool.rs:174:8
|
||||
--> tests/ui/nonminimal_bool.rs:175:8
|
||||
|
|
||||
LL | if !b != !c {}
|
||||
| ^^^^^^^^ help: try: `b != c`
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
//@compile-flags: -Zdeduplicate-diagnostics=yes
|
||||
|
||||
#![allow(unused, clippy::diverging_sub_expression, clippy::needless_if)]
|
||||
#![warn(clippy::nonminimal_bool)]
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
//@compile-flags: -Zdeduplicate-diagnostics=yes
|
||||
|
||||
#![allow(unused, clippy::diverging_sub_expression, clippy::needless_if)]
|
||||
#![warn(clippy::nonminimal_bool)]
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: this boolean expression can be simplified
|
||||
--> tests/ui/nonminimal_bool_methods.rs:8:13
|
||||
--> tests/ui/nonminimal_bool_methods.rs:10:13
|
||||
|
|
||||
LL | let _ = !a.is_some();
|
||||
| ^^^^^^^^^^^^ help: try: `a.is_none()`
|
||||
|
|
@ -8,73 +8,73 @@ LL | let _ = !a.is_some();
|
|||
= help: to override `-D warnings` add `#[allow(clippy::nonminimal_bool)]`
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> tests/ui/nonminimal_bool_methods.rs:10:13
|
||||
--> tests/ui/nonminimal_bool_methods.rs:12:13
|
||||
|
|
||||
LL | let _ = !a.is_none();
|
||||
| ^^^^^^^^^^^^ help: try: `a.is_some()`
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> tests/ui/nonminimal_bool_methods.rs:12:13
|
||||
--> tests/ui/nonminimal_bool_methods.rs:14:13
|
||||
|
|
||||
LL | let _ = !b.is_err();
|
||||
| ^^^^^^^^^^^ help: try: `b.is_ok()`
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> tests/ui/nonminimal_bool_methods.rs:14:13
|
||||
--> tests/ui/nonminimal_bool_methods.rs:16:13
|
||||
|
|
||||
LL | let _ = !b.is_ok();
|
||||
| ^^^^^^^^^^ help: try: `b.is_err()`
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> tests/ui/nonminimal_bool_methods.rs:16:13
|
||||
--> tests/ui/nonminimal_bool_methods.rs:18:13
|
||||
|
|
||||
LL | let _ = !(a.is_some() && !c);
|
||||
| ^^^^^^^^^^^^^^^^^^^^ help: try: `a.is_none() || c`
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> tests/ui/nonminimal_bool_methods.rs:17:13
|
||||
--> tests/ui/nonminimal_bool_methods.rs:19:13
|
||||
|
|
||||
LL | let _ = !(a.is_some() || !c);
|
||||
| ^^^^^^^^^^^^^^^^^^^^ help: try: `a.is_none() && c`
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> tests/ui/nonminimal_bool_methods.rs:18:26
|
||||
--> tests/ui/nonminimal_bool_methods.rs:20:26
|
||||
|
|
||||
LL | let _ = !(!c ^ c) || !a.is_some();
|
||||
| ^^^^^^^^^^^^ help: try: `a.is_none()`
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> tests/ui/nonminimal_bool_methods.rs:19:25
|
||||
--> tests/ui/nonminimal_bool_methods.rs:21:25
|
||||
|
|
||||
LL | let _ = (!c ^ c) || !a.is_some();
|
||||
| ^^^^^^^^^^^^ help: try: `a.is_none()`
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> tests/ui/nonminimal_bool_methods.rs:20:23
|
||||
--> tests/ui/nonminimal_bool_methods.rs:22:23
|
||||
|
|
||||
LL | let _ = !c ^ c || !a.is_some();
|
||||
| ^^^^^^^^^^^^ help: try: `a.is_none()`
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> tests/ui/nonminimal_bool_methods.rs:92:8
|
||||
--> tests/ui/nonminimal_bool_methods.rs:94:8
|
||||
|
|
||||
LL | if !res.is_ok() {}
|
||||
| ^^^^^^^^^^^^ help: try: `res.is_err()`
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> tests/ui/nonminimal_bool_methods.rs:93:8
|
||||
--> tests/ui/nonminimal_bool_methods.rs:95:8
|
||||
|
|
||||
LL | if !res.is_err() {}
|
||||
| ^^^^^^^^^^^^^ help: try: `res.is_ok()`
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> tests/ui/nonminimal_bool_methods.rs:96:8
|
||||
--> tests/ui/nonminimal_bool_methods.rs:98:8
|
||||
|
|
||||
LL | if !res.is_some() {}
|
||||
| ^^^^^^^^^^^^^^ help: try: `res.is_none()`
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> tests/ui/nonminimal_bool_methods.rs:97:8
|
||||
--> tests/ui/nonminimal_bool_methods.rs:99:8
|
||||
|
|
||||
LL | if !res.is_none() {}
|
||||
| ^^^^^^^^^^^^^^ help: try: `res.is_some()`
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
//@compile-flags: -Zdeduplicate-diagnostics=yes
|
||||
|
||||
#![deny(clippy::option_option)]
|
||||
#![allow(clippy::unnecessary_wraps)]
|
||||
|
||||
|
|
|
|||
|
|
@ -1,77 +1,77 @@
|
|||
error: consider using `Option<T>` instead of `Option<Option<T>>` or a custom enum if you need to distinguish all 3 cases
|
||||
--> tests/ui/option_option.rs:4:10
|
||||
--> tests/ui/option_option.rs:6:10
|
||||
|
|
||||
LL | const C: Option<Option<i32>> = None;
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> tests/ui/option_option.rs:1:9
|
||||
--> tests/ui/option_option.rs:3:9
|
||||
|
|
||||
LL | #![deny(clippy::option_option)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: consider using `Option<T>` instead of `Option<Option<T>>` or a custom enum if you need to distinguish all 3 cases
|
||||
--> tests/ui/option_option.rs:6:11
|
||||
--> tests/ui/option_option.rs:8:11
|
||||
|
|
||||
LL | static S: Option<Option<i32>> = None;
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: consider using `Option<T>` instead of `Option<Option<T>>` or a custom enum if you need to distinguish all 3 cases
|
||||
--> tests/ui/option_option.rs:9:13
|
||||
--> tests/ui/option_option.rs:11:13
|
||||
|
|
||||
LL | fn input(_: Option<Option<u8>>) {}
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: consider using `Option<T>` instead of `Option<Option<T>>` or a custom enum if you need to distinguish all 3 cases
|
||||
--> tests/ui/option_option.rs:12:16
|
||||
--> tests/ui/option_option.rs:14:16
|
||||
|
|
||||
LL | fn output() -> Option<Option<u8>> {
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: consider using `Option<T>` instead of `Option<Option<T>>` or a custom enum if you need to distinguish all 3 cases
|
||||
--> tests/ui/option_option.rs:17:27
|
||||
--> tests/ui/option_option.rs:19:27
|
||||
|
|
||||
LL | fn output_nested() -> Vec<Option<Option<u8>>> {
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: consider using `Option<T>` instead of `Option<Option<T>>` or a custom enum if you need to distinguish all 3 cases
|
||||
--> tests/ui/option_option.rs:23:30
|
||||
--> tests/ui/option_option.rs:25:30
|
||||
|
|
||||
LL | fn output_nested_nested() -> Option<Option<Option<u8>>> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: consider using `Option<T>` instead of `Option<Option<T>>` or a custom enum if you need to distinguish all 3 cases
|
||||
--> tests/ui/option_option.rs:29:8
|
||||
--> tests/ui/option_option.rs:31:8
|
||||
|
|
||||
LL | x: Option<Option<u8>>,
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: consider using `Option<T>` instead of `Option<Option<T>>` or a custom enum if you need to distinguish all 3 cases
|
||||
--> tests/ui/option_option.rs:34:23
|
||||
--> tests/ui/option_option.rs:36:23
|
||||
|
|
||||
LL | fn struct_fn() -> Option<Option<u8>> {
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: consider using `Option<T>` instead of `Option<Option<T>>` or a custom enum if you need to distinguish all 3 cases
|
||||
--> tests/ui/option_option.rs:41:22
|
||||
--> tests/ui/option_option.rs:43:22
|
||||
|
|
||||
LL | fn trait_fn() -> Option<Option<u8>>;
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: consider using `Option<T>` instead of `Option<Option<T>>` or a custom enum if you need to distinguish all 3 cases
|
||||
--> tests/ui/option_option.rs:46:11
|
||||
--> tests/ui/option_option.rs:48:11
|
||||
|
|
||||
LL | Tuple(Option<Option<u8>>),
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: consider using `Option<T>` instead of `Option<Option<T>>` or a custom enum if you need to distinguish all 3 cases
|
||||
--> tests/ui/option_option.rs:48:17
|
||||
--> tests/ui/option_option.rs:50:17
|
||||
|
|
||||
LL | Struct { x: Option<Option<u8>> },
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: consider using `Option<T>` instead of `Option<Option<T>>` or a custom enum if you need to distinguish all 3 cases
|
||||
--> tests/ui/option_option.rs:90:14
|
||||
--> tests/ui/option_option.rs:92:14
|
||||
|
|
||||
LL | foo: Option<Option<Cow<'a, str>>>,
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
//@aux-build:proc_macros.rs
|
||||
//@compile-flags: -Zdeduplicate-diagnostics=yes
|
||||
|
||||
#![warn(clippy::ptr_as_ptr)]
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
//@aux-build:proc_macros.rs
|
||||
//@compile-flags: -Zdeduplicate-diagnostics=yes
|
||||
|
||||
#![warn(clippy::ptr_as_ptr)]
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: `as` casting between raw pointers without changing its mutability
|
||||
--> tests/ui/ptr_as_ptr.rs:18:33
|
||||
--> tests/ui/ptr_as_ptr.rs:19:33
|
||||
|
|
||||
LL | *unsafe { Box::from_raw(Box::into_raw(Box::new(o)) as *mut super::issue_11278_a::T<String>) }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try `pointer::cast`, a safer alternative: `Box::into_raw(Box::new(o)).cast::<super::issue_11278_a::T<String>>()`
|
||||
|
|
@ -8,37 +8,37 @@ LL | *unsafe { Box::from_raw(Box::into_raw(Box::new(o)) as *mut super::i
|
|||
= help: to override `-D warnings` add `#[allow(clippy::ptr_as_ptr)]`
|
||||
|
||||
error: `as` casting between raw pointers without changing its mutability
|
||||
--> tests/ui/ptr_as_ptr.rs:27:13
|
||||
--> tests/ui/ptr_as_ptr.rs:28: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
|
||||
--> tests/ui/ptr_as_ptr.rs:28:13
|
||||
--> tests/ui/ptr_as_ptr.rs:29: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
|
||||
--> tests/ui/ptr_as_ptr.rs:33:17
|
||||
--> tests/ui/ptr_as_ptr.rs:34: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
|
||||
--> tests/ui/ptr_as_ptr.rs:46:25
|
||||
--> tests/ui/ptr_as_ptr.rs:47: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
|
||||
--> tests/ui/ptr_as_ptr.rs:47:23
|
||||
--> tests/ui/ptr_as_ptr.rs:48: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
|
||||
--> tests/ui/ptr_as_ptr.rs:50:21
|
||||
--> tests/ui/ptr_as_ptr.rs:51:21
|
||||
|
|
||||
LL | let _ = inline!($ptr as *const i32);
|
||||
| ^^^^^^^^^^^^^^^^^^ help: try `pointer::cast`, a safer alternative: `$ptr.cast::<i32>()`
|
||||
|
|
@ -46,157 +46,157 @@ LL | let _ = inline!($ptr as *const i32);
|
|||
= note: this error originates in the macro `__inline_mac_fn_main` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: `as` casting between raw pointers without changing its mutability
|
||||
--> tests/ui/ptr_as_ptr.rs:71:13
|
||||
--> tests/ui/ptr_as_ptr.rs:72: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
|
||||
--> tests/ui/ptr_as_ptr.rs:72:13
|
||||
--> tests/ui/ptr_as_ptr.rs:73: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
|
||||
--> tests/ui/ptr_as_ptr.rs:79:9
|
||||
--> tests/ui/ptr_as_ptr.rs:80:9
|
||||
|
|
||||
LL | ptr::null_mut() as *mut u32
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `ptr::null_mut::<u32>()`
|
||||
|
||||
error: `as` casting between raw pointers without changing its mutability
|
||||
--> tests/ui/ptr_as_ptr.rs:83:9
|
||||
--> tests/ui/ptr_as_ptr.rs:84:9
|
||||
|
|
||||
LL | std::ptr::null_mut() as *mut u32
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `std::ptr::null_mut::<u32>()`
|
||||
|
||||
error: `as` casting between raw pointers without changing its mutability
|
||||
--> tests/ui/ptr_as_ptr.rs:88:9
|
||||
--> tests/ui/ptr_as_ptr.rs:89:9
|
||||
|
|
||||
LL | ptr::null_mut() as *mut u32
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `ptr::null_mut::<u32>()`
|
||||
|
||||
error: `as` casting between raw pointers without changing its mutability
|
||||
--> tests/ui/ptr_as_ptr.rs:92:9
|
||||
--> tests/ui/ptr_as_ptr.rs:93:9
|
||||
|
|
||||
LL | core::ptr::null_mut() as *mut u32
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `core::ptr::null_mut::<u32>()`
|
||||
|
||||
error: `as` casting between raw pointers without changing its mutability
|
||||
--> tests/ui/ptr_as_ptr.rs:97:9
|
||||
--> tests/ui/ptr_as_ptr.rs:98:9
|
||||
|
|
||||
LL | ptr::null() as *const u32
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `ptr::null::<u32>()`
|
||||
|
||||
error: `as` casting between raw pointers without changing its mutability
|
||||
--> tests/ui/ptr_as_ptr.rs:101:9
|
||||
--> tests/ui/ptr_as_ptr.rs:102:9
|
||||
|
|
||||
LL | std::ptr::null() as *const u32
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `std::ptr::null::<u32>()`
|
||||
|
||||
error: `as` casting between raw pointers without changing its mutability
|
||||
--> tests/ui/ptr_as_ptr.rs:106:9
|
||||
--> tests/ui/ptr_as_ptr.rs:107:9
|
||||
|
|
||||
LL | ptr::null() as *const u32
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `ptr::null::<u32>()`
|
||||
|
||||
error: `as` casting between raw pointers without changing its mutability
|
||||
--> tests/ui/ptr_as_ptr.rs:110:9
|
||||
--> tests/ui/ptr_as_ptr.rs:111:9
|
||||
|
|
||||
LL | core::ptr::null() as *const u32
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `core::ptr::null::<u32>()`
|
||||
|
||||
error: `as` casting between raw pointers without changing its mutability
|
||||
--> tests/ui/ptr_as_ptr.rs:117:9
|
||||
--> tests/ui/ptr_as_ptr.rs:118:9
|
||||
|
|
||||
LL | ptr::null_mut() as *mut _
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `ptr::null_mut()`
|
||||
|
||||
error: `as` casting between raw pointers without changing its mutability
|
||||
--> tests/ui/ptr_as_ptr.rs:121:9
|
||||
--> tests/ui/ptr_as_ptr.rs:122:9
|
||||
|
|
||||
LL | std::ptr::null_mut() as *mut _
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `std::ptr::null_mut()`
|
||||
|
||||
error: `as` casting between raw pointers without changing its mutability
|
||||
--> tests/ui/ptr_as_ptr.rs:126:9
|
||||
--> tests/ui/ptr_as_ptr.rs:127:9
|
||||
|
|
||||
LL | ptr::null_mut() as *mut _
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `ptr::null_mut()`
|
||||
|
||||
error: `as` casting between raw pointers without changing its mutability
|
||||
--> tests/ui/ptr_as_ptr.rs:130:9
|
||||
--> tests/ui/ptr_as_ptr.rs:131:9
|
||||
|
|
||||
LL | core::ptr::null_mut() as *mut _
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `core::ptr::null_mut()`
|
||||
|
||||
error: `as` casting between raw pointers without changing its mutability
|
||||
--> tests/ui/ptr_as_ptr.rs:135:9
|
||||
--> tests/ui/ptr_as_ptr.rs:136:9
|
||||
|
|
||||
LL | ptr::null() as *const _
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `ptr::null()`
|
||||
|
||||
error: `as` casting between raw pointers without changing its mutability
|
||||
--> tests/ui/ptr_as_ptr.rs:139:9
|
||||
--> tests/ui/ptr_as_ptr.rs:140:9
|
||||
|
|
||||
LL | std::ptr::null() as *const _
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `std::ptr::null()`
|
||||
|
||||
error: `as` casting between raw pointers without changing its mutability
|
||||
--> tests/ui/ptr_as_ptr.rs:144:9
|
||||
--> tests/ui/ptr_as_ptr.rs:145:9
|
||||
|
|
||||
LL | ptr::null() as *const _
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `ptr::null()`
|
||||
|
||||
error: `as` casting between raw pointers without changing its mutability
|
||||
--> tests/ui/ptr_as_ptr.rs:148:9
|
||||
--> tests/ui/ptr_as_ptr.rs:149:9
|
||||
|
|
||||
LL | core::ptr::null() as *const _
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `core::ptr::null()`
|
||||
|
||||
error: `as` casting between raw pointers without changing its mutability
|
||||
--> tests/ui/ptr_as_ptr.rs:155:9
|
||||
--> tests/ui/ptr_as_ptr.rs:156:9
|
||||
|
|
||||
LL | ptr::null_mut() as _
|
||||
| ^^^^^^^^^^^^^^^^^^^^ help: try call directly: `ptr::null_mut()`
|
||||
|
||||
error: `as` casting between raw pointers without changing its mutability
|
||||
--> tests/ui/ptr_as_ptr.rs:159:9
|
||||
--> tests/ui/ptr_as_ptr.rs:160:9
|
||||
|
|
||||
LL | std::ptr::null_mut() as _
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `std::ptr::null_mut()`
|
||||
|
||||
error: `as` casting between raw pointers without changing its mutability
|
||||
--> tests/ui/ptr_as_ptr.rs:164:9
|
||||
--> tests/ui/ptr_as_ptr.rs:165:9
|
||||
|
|
||||
LL | ptr::null_mut() as _
|
||||
| ^^^^^^^^^^^^^^^^^^^^ help: try call directly: `ptr::null_mut()`
|
||||
|
||||
error: `as` casting between raw pointers without changing its mutability
|
||||
--> tests/ui/ptr_as_ptr.rs:168:9
|
||||
--> tests/ui/ptr_as_ptr.rs:169:9
|
||||
|
|
||||
LL | core::ptr::null_mut() as _
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `core::ptr::null_mut()`
|
||||
|
||||
error: `as` casting between raw pointers without changing its mutability
|
||||
--> tests/ui/ptr_as_ptr.rs:173:9
|
||||
--> tests/ui/ptr_as_ptr.rs:174:9
|
||||
|
|
||||
LL | ptr::null() as _
|
||||
| ^^^^^^^^^^^^^^^^ help: try call directly: `ptr::null()`
|
||||
|
||||
error: `as` casting between raw pointers without changing its mutability
|
||||
--> tests/ui/ptr_as_ptr.rs:177:9
|
||||
--> tests/ui/ptr_as_ptr.rs:178:9
|
||||
|
|
||||
LL | std::ptr::null() as _
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `std::ptr::null()`
|
||||
|
||||
error: `as` casting between raw pointers without changing its mutability
|
||||
--> tests/ui/ptr_as_ptr.rs:182:9
|
||||
--> tests/ui/ptr_as_ptr.rs:183:9
|
||||
|
|
||||
LL | ptr::null() as _
|
||||
| ^^^^^^^^^^^^^^^^ help: try call directly: `ptr::null()`
|
||||
|
||||
error: `as` casting between raw pointers without changing its mutability
|
||||
--> tests/ui/ptr_as_ptr.rs:186:9
|
||||
--> tests/ui/ptr_as_ptr.rs:187:9
|
||||
|
|
||||
LL | core::ptr::null() as _
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `core::ptr::null()`
|
||||
|
|
|
|||
|
|
@ -273,3 +273,13 @@ const fn issue9175(option: Option<()>) -> Option<()> {
|
|||
//stuff
|
||||
Some(())
|
||||
}
|
||||
|
||||
fn issue12337() -> Option<i32> {
|
||||
let _: Option<i32> = try {
|
||||
let Some(_) = Some(42) else {
|
||||
return None;
|
||||
};
|
||||
123
|
||||
};
|
||||
Some(42)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -313,3 +313,13 @@ const fn issue9175(option: Option<()>) -> Option<()> {
|
|||
//stuff
|
||||
Some(())
|
||||
}
|
||||
|
||||
fn issue12337() -> Option<i32> {
|
||||
let _: Option<i32> = try {
|
||||
let Some(_) = Some(42) else {
|
||||
return None;
|
||||
};
|
||||
123
|
||||
};
|
||||
Some(42)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -111,3 +111,20 @@ fn fp_11274() {
|
|||
}
|
||||
m!(|x| println!("{x}"));
|
||||
}
|
||||
|
||||
// Issue #12358: When a macro expands into a closure, immediately calling the expanded closure
|
||||
// triggers the lint.
|
||||
fn issue_12358() {
|
||||
macro_rules! make_closure {
|
||||
() => {
|
||||
(|| || {})
|
||||
};
|
||||
(x) => {
|
||||
make_closure!()()
|
||||
};
|
||||
}
|
||||
|
||||
// The lint would suggest to alter the line below to `make_closure!(x)`, which is semantically
|
||||
// different.
|
||||
make_closure!(x)();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -111,3 +111,20 @@ fn fp_11274() {
|
|||
}
|
||||
m!(|x| println!("{x}"));
|
||||
}
|
||||
|
||||
// Issue #12358: When a macro expands into a closure, immediately calling the expanded closure
|
||||
// triggers the lint.
|
||||
fn issue_12358() {
|
||||
macro_rules! make_closure {
|
||||
() => {
|
||||
(|| || {})
|
||||
};
|
||||
(x) => {
|
||||
make_closure!()()
|
||||
};
|
||||
}
|
||||
|
||||
// The lint would suggest to alter the line below to `make_closure!(x)`, which is semantically
|
||||
// different.
|
||||
make_closure!(x)();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ struct Person {
|
|||
}
|
||||
|
||||
pub struct S {
|
||||
v: String,
|
||||
v: usize,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
@ -59,11 +59,22 @@ fn main() {
|
|||
let _ = RangeToInclusive { end };
|
||||
|
||||
external! {
|
||||
let v = String::new();
|
||||
let v = 1;
|
||||
let _ = S {
|
||||
v: v
|
||||
};
|
||||
}
|
||||
|
||||
let v = 2;
|
||||
macro_rules! internal {
|
||||
($i:ident) => {
|
||||
let _ = S { v };
|
||||
let _ = S { $i: v };
|
||||
let _ = S { v: $i };
|
||||
let _ = S { $i: $i };
|
||||
};
|
||||
}
|
||||
internal!(v);
|
||||
}
|
||||
|
||||
fn issue_3476() {
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ struct Person {
|
|||
}
|
||||
|
||||
pub struct S {
|
||||
v: String,
|
||||
v: usize,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
@ -59,11 +59,22 @@ fn main() {
|
|||
let _ = RangeToInclusive { end: end };
|
||||
|
||||
external! {
|
||||
let v = String::new();
|
||||
let v = 1;
|
||||
let _ = S {
|
||||
v: v
|
||||
};
|
||||
}
|
||||
|
||||
let v = 2;
|
||||
macro_rules! internal {
|
||||
($i:ident) => {
|
||||
let _ = S { v: v };
|
||||
let _ = S { $i: v };
|
||||
let _ = S { v: $i };
|
||||
let _ = S { $i: $i };
|
||||
};
|
||||
}
|
||||
internal!(v);
|
||||
}
|
||||
|
||||
fn issue_3476() {
|
||||
|
|
|
|||
|
|
@ -44,10 +44,21 @@ LL | let _ = RangeToInclusive { end: end };
|
|||
| ^^^^^^^^ help: replace it with: `end`
|
||||
|
||||
error: redundant field names in struct initialization
|
||||
--> tests/ui/redundant_field_names.rs:88:25
|
||||
--> tests/ui/redundant_field_names.rs:71:25
|
||||
|
|
||||
LL | let _ = S { v: v };
|
||||
| ^^^^ help: replace it with: `v`
|
||||
...
|
||||
LL | internal!(v);
|
||||
| ------------ in this macro invocation
|
||||
|
|
||||
= note: this error originates in the macro `internal` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: redundant field names in struct initialization
|
||||
--> tests/ui/redundant_field_names.rs:99:25
|
||||
|
|
||||
LL | let _ = RangeFrom { start: start };
|
||||
| ^^^^^^^^^^^^ help: replace it with: `start`
|
||||
|
||||
error: aborting due to 8 previous errors
|
||||
error: aborting due to 9 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -1,2 +1,4 @@
|
|||
//@compile-flags: -Zdeduplicate-diagnostics=yes
|
||||
|
||||
#[clippy::cognitive_complexity = "1"]
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,2 +1,4 @@
|
|||
//@compile-flags: -Zdeduplicate-diagnostics=yes
|
||||
|
||||
#[clippy::cyclomatic_complexity = "1"]
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: usage of deprecated attribute
|
||||
--> tests/ui/renamed_builtin_attr.rs:1:11
|
||||
--> tests/ui/renamed_builtin_attr.rs:3:11
|
||||
|
|
||||
LL | #[clippy::cyclomatic_complexity = "1"]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ help: consider using: `cognitive_complexity`
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
//@compile-flags: -Zdeduplicate-diagnostics=yes
|
||||
|
||||
#![warn(clippy::single_match)]
|
||||
#![allow(
|
||||
unused,
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
//@compile-flags: -Zdeduplicate-diagnostics=yes
|
||||
|
||||
#![warn(clippy::single_match)]
|
||||
#![allow(
|
||||
unused,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
|
||||
--> tests/ui/single_match.rs:14:5
|
||||
--> tests/ui/single_match.rs:16:5
|
||||
|
|
||||
LL | / match x {
|
||||
LL | | Some(y) => {
|
||||
|
|
@ -19,7 +19,7 @@ LL ~ };
|
|||
|
|
||||
|
||||
error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
|
||||
--> tests/ui/single_match.rs:22:5
|
||||
--> tests/ui/single_match.rs:24:5
|
||||
|
|
||||
LL | / match x {
|
||||
LL | | // Note the missing block braces.
|
||||
|
|
@ -31,7 +31,7 @@ LL | | }
|
|||
| |_____^ help: try: `if let Some(y) = x { println!("{:?}", y) }`
|
||||
|
||||
error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
|
||||
--> tests/ui/single_match.rs:31:5
|
||||
--> tests/ui/single_match.rs:33:5
|
||||
|
|
||||
LL | / match z {
|
||||
LL | | (2..=3, 7..=9) => dummy(),
|
||||
|
|
@ -40,7 +40,7 @@ LL | | };
|
|||
| |_____^ help: try: `if let (2..=3, 7..=9) = z { dummy() }`
|
||||
|
||||
error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
|
||||
--> tests/ui/single_match.rs:60:5
|
||||
--> tests/ui/single_match.rs:62:5
|
||||
|
|
||||
LL | / match x {
|
||||
LL | | Some(y) => dummy(),
|
||||
|
|
@ -49,7 +49,7 @@ LL | | };
|
|||
| |_____^ help: try: `if let Some(y) = x { dummy() }`
|
||||
|
||||
error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
|
||||
--> tests/ui/single_match.rs:65:5
|
||||
--> tests/ui/single_match.rs:67:5
|
||||
|
|
||||
LL | / match y {
|
||||
LL | | Ok(y) => dummy(),
|
||||
|
|
@ -58,7 +58,7 @@ LL | | };
|
|||
| |_____^ help: try: `if let Ok(y) = y { dummy() }`
|
||||
|
||||
error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
|
||||
--> tests/ui/single_match.rs:72:5
|
||||
--> tests/ui/single_match.rs:74:5
|
||||
|
|
||||
LL | / match c {
|
||||
LL | | Cow::Borrowed(..) => dummy(),
|
||||
|
|
@ -67,7 +67,7 @@ LL | | };
|
|||
| |_____^ help: try: `if let Cow::Borrowed(..) = c { dummy() }`
|
||||
|
||||
error: you seem to be trying to use `match` for an equality check. Consider using `if`
|
||||
--> tests/ui/single_match.rs:93:5
|
||||
--> tests/ui/single_match.rs:95:5
|
||||
|
|
||||
LL | / match x {
|
||||
LL | | "test" => println!(),
|
||||
|
|
@ -76,7 +76,7 @@ LL | | }
|
|||
| |_____^ help: try: `if x == "test" { println!() }`
|
||||
|
||||
error: you seem to be trying to use `match` for an equality check. Consider using `if`
|
||||
--> tests/ui/single_match.rs:106:5
|
||||
--> tests/ui/single_match.rs:108:5
|
||||
|
|
||||
LL | / match x {
|
||||
LL | | Foo::A => println!(),
|
||||
|
|
@ -85,7 +85,7 @@ LL | | }
|
|||
| |_____^ help: try: `if x == Foo::A { println!() }`
|
||||
|
||||
error: you seem to be trying to use `match` for an equality check. Consider using `if`
|
||||
--> tests/ui/single_match.rs:112:5
|
||||
--> tests/ui/single_match.rs:114:5
|
||||
|
|
||||
LL | / match x {
|
||||
LL | | FOO_C => println!(),
|
||||
|
|
@ -94,7 +94,7 @@ LL | | }
|
|||
| |_____^ help: try: `if x == FOO_C { println!() }`
|
||||
|
||||
error: you seem to be trying to use `match` for an equality check. Consider using `if`
|
||||
--> tests/ui/single_match.rs:117:5
|
||||
--> tests/ui/single_match.rs:119:5
|
||||
|
|
||||
LL | / match &&x {
|
||||
LL | | Foo::A => println!(),
|
||||
|
|
@ -103,7 +103,7 @@ LL | | }
|
|||
| |_____^ help: try: `if x == Foo::A { println!() }`
|
||||
|
||||
error: you seem to be trying to use `match` for an equality check. Consider using `if`
|
||||
--> tests/ui/single_match.rs:123:5
|
||||
--> tests/ui/single_match.rs:125:5
|
||||
|
|
||||
LL | / match &x {
|
||||
LL | | Foo::A => println!(),
|
||||
|
|
@ -112,7 +112,7 @@ LL | | }
|
|||
| |_____^ help: try: `if x == &Foo::A { println!() }`
|
||||
|
||||
error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
|
||||
--> tests/ui/single_match.rs:140:5
|
||||
--> tests/ui/single_match.rs:142:5
|
||||
|
|
||||
LL | / match x {
|
||||
LL | | Bar::A => println!(),
|
||||
|
|
@ -121,7 +121,7 @@ LL | | }
|
|||
| |_____^ help: try: `if let Bar::A = x { println!() }`
|
||||
|
||||
error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
|
||||
--> tests/ui/single_match.rs:148:5
|
||||
--> tests/ui/single_match.rs:150:5
|
||||
|
|
||||
LL | / match x {
|
||||
LL | | None => println!(),
|
||||
|
|
@ -130,7 +130,7 @@ LL | | };
|
|||
| |_____^ help: try: `if let None = x { println!() }`
|
||||
|
||||
error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
|
||||
--> tests/ui/single_match.rs:170:5
|
||||
--> tests/ui/single_match.rs:172:5
|
||||
|
|
||||
LL | / match x {
|
||||
LL | | (Some(_), _) => {},
|
||||
|
|
@ -139,7 +139,7 @@ LL | | }
|
|||
| |_____^ help: try: `if let (Some(_), _) = x {}`
|
||||
|
||||
error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
|
||||
--> tests/ui/single_match.rs:176:5
|
||||
--> tests/ui/single_match.rs:178:5
|
||||
|
|
||||
LL | / match x {
|
||||
LL | | (Some(E::V), _) => todo!(),
|
||||
|
|
@ -148,7 +148,7 @@ LL | | }
|
|||
| |_____^ help: try: `if let (Some(E::V), _) = x { todo!() }`
|
||||
|
||||
error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
|
||||
--> tests/ui/single_match.rs:182:5
|
||||
--> tests/ui/single_match.rs:184:5
|
||||
|
|
||||
LL | / match (Some(42), Some(E::V), Some(42)) {
|
||||
LL | | (.., Some(E::V), _) => {},
|
||||
|
|
@ -157,7 +157,7 @@ LL | | }
|
|||
| |_____^ help: try: `if let (.., Some(E::V), _) = (Some(42), Some(E::V), Some(42)) {}`
|
||||
|
||||
error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
|
||||
--> tests/ui/single_match.rs:254:5
|
||||
--> tests/ui/single_match.rs:256:5
|
||||
|
|
||||
LL | / match bar {
|
||||
LL | | Some(v) => unsafe {
|
||||
|
|
@ -177,7 +177,7 @@ LL + } }
|
|||
|
|
||||
|
||||
error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
|
||||
--> tests/ui/single_match.rs:262:5
|
||||
--> tests/ui/single_match.rs:264:5
|
||||
|
|
||||
LL | / match bar {
|
||||
LL | | #[rustfmt::skip]
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
//@aux-build: proc_macros.rs
|
||||
//@compile-flags: -Zdeduplicate-diagnostics=yes
|
||||
|
||||
#![warn(clippy::single_match_else)]
|
||||
#![allow(unused, clippy::needless_return, clippy::no_effect, clippy::uninlined_format_args)]
|
||||
extern crate proc_macros;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
//@aux-build: proc_macros.rs
|
||||
//@compile-flags: -Zdeduplicate-diagnostics=yes
|
||||
|
||||
#![warn(clippy::single_match_else)]
|
||||
#![allow(unused, clippy::needless_return, clippy::no_effect, clippy::uninlined_format_args)]
|
||||
extern crate proc_macros;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
|
||||
--> tests/ui/single_match_else.rs:16:13
|
||||
--> tests/ui/single_match_else.rs:18:13
|
||||
|
|
||||
LL | let _ = match ExprNode::Butterflies {
|
||||
| _____________^
|
||||
|
|
@ -22,7 +22,7 @@ LL ~ };
|
|||
|
|
||||
|
||||
error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
|
||||
--> tests/ui/single_match_else.rs:81:5
|
||||
--> tests/ui/single_match_else.rs:83:5
|
||||
|
|
||||
LL | / match Some(1) {
|
||||
LL | | Some(a) => println!("${:?}", a),
|
||||
|
|
@ -42,7 +42,7 @@ LL + }
|
|||
|
|
||||
|
||||
error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
|
||||
--> tests/ui/single_match_else.rs:90:5
|
||||
--> tests/ui/single_match_else.rs:92:5
|
||||
|
|
||||
LL | / match Some(1) {
|
||||
LL | | Some(a) => println!("${:?}", a),
|
||||
|
|
@ -62,7 +62,7 @@ LL + }
|
|||
|
|
||||
|
||||
error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
|
||||
--> tests/ui/single_match_else.rs:100:5
|
||||
--> tests/ui/single_match_else.rs:102:5
|
||||
|
|
||||
LL | / match Result::<i32, Infallible>::Ok(1) {
|
||||
LL | | Ok(a) => println!("${:?}", a),
|
||||
|
|
@ -82,7 +82,7 @@ LL + }
|
|||
|
|
||||
|
||||
error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
|
||||
--> tests/ui/single_match_else.rs:109:5
|
||||
--> tests/ui/single_match_else.rs:111:5
|
||||
|
|
||||
LL | / match Cow::from("moo") {
|
||||
LL | | Cow::Owned(a) => println!("${:?}", a),
|
||||
|
|
@ -102,7 +102,7 @@ LL + }
|
|||
|
|
||||
|
||||
error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
|
||||
--> tests/ui/single_match_else.rs:119:5
|
||||
--> tests/ui/single_match_else.rs:121:5
|
||||
|
|
||||
LL | / match bar {
|
||||
LL | | Some(v) => unsafe {
|
||||
|
|
@ -125,7 +125,7 @@ LL + }
|
|||
|
|
||||
|
||||
error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
|
||||
--> tests/ui/single_match_else.rs:130:5
|
||||
--> tests/ui/single_match_else.rs:132:5
|
||||
|
|
||||
LL | / match bar {
|
||||
LL | | Some(v) => {
|
||||
|
|
@ -149,7 +149,7 @@ LL + } }
|
|||
|
|
||||
|
||||
error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
|
||||
--> tests/ui/single_match_else.rs:142:5
|
||||
--> tests/ui/single_match_else.rs:144:5
|
||||
|
|
||||
LL | / match bar {
|
||||
LL | | Some(v) => unsafe {
|
||||
|
|
@ -173,7 +173,7 @@ LL + } }
|
|||
|
|
||||
|
||||
error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
|
||||
--> tests/ui/single_match_else.rs:154:5
|
||||
--> tests/ui/single_match_else.rs:156:5
|
||||
|
|
||||
LL | / match bar {
|
||||
LL | | #[rustfmt::skip]
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
//@aux-build:proc_macro_derive.rs
|
||||
|
||||
#![warn(clippy::std_instead_of_core)]
|
||||
#![allow(unused_imports)]
|
||||
|
||||
|
|
@ -16,12 +17,20 @@ fn std_instead_of_core() {
|
|||
use ::core::hash::Hash;
|
||||
//~^ ERROR: used import from `std` instead of `core`
|
||||
// Don't lint on `env` macro
|
||||
use std::env;
|
||||
use core::env;
|
||||
|
||||
// Multiple imports
|
||||
use core::fmt::{Debug, Result};
|
||||
//~^ ERROR: used import from `std` instead of `core`
|
||||
|
||||
// Multiple imports multiline
|
||||
#[rustfmt::skip]
|
||||
use core::{
|
||||
//~^ ERROR: used import from `std` instead of `core`
|
||||
fmt::Write as _,
|
||||
ptr::read_unaligned,
|
||||
};
|
||||
|
||||
// Function calls
|
||||
let ptr = core::ptr::null::<u32>();
|
||||
//~^ ERROR: used import from `std` instead of `core`
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
//@aux-build:proc_macro_derive.rs
|
||||
|
||||
#![warn(clippy::std_instead_of_core)]
|
||||
#![allow(unused_imports)]
|
||||
|
||||
|
|
@ -22,6 +23,14 @@ fn std_instead_of_core() {
|
|||
use std::fmt::{Debug, Result};
|
||||
//~^ ERROR: used import from `std` instead of `core`
|
||||
|
||||
// Multiple imports multiline
|
||||
#[rustfmt::skip]
|
||||
use std::{
|
||||
//~^ ERROR: used import from `std` instead of `core`
|
||||
fmt::Write as _,
|
||||
ptr::read_unaligned,
|
||||
};
|
||||
|
||||
// Function calls
|
||||
let ptr = std::ptr::null::<u32>();
|
||||
//~^ ERROR: used import from `std` instead of `core`
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: used import from `std` instead of `core`
|
||||
--> tests/ui/std_instead_of_core.rs:13:9
|
||||
--> tests/ui/std_instead_of_core.rs:14:9
|
||||
|
|
||||
LL | use std::hash::Hasher;
|
||||
| ^^^ help: consider importing the item from `core`: `core`
|
||||
|
|
@ -8,49 +8,61 @@ LL | use std::hash::Hasher;
|
|||
= help: to override `-D warnings` add `#[allow(clippy::std_instead_of_core)]`
|
||||
|
||||
error: used import from `std` instead of `core`
|
||||
--> tests/ui/std_instead_of_core.rs:16:11
|
||||
--> tests/ui/std_instead_of_core.rs:17:11
|
||||
|
|
||||
LL | use ::std::hash::Hash;
|
||||
| ^^^ help: consider importing the item from `core`: `core`
|
||||
|
||||
error: used import from `std` instead of `core`
|
||||
--> tests/ui/std_instead_of_core.rs:22:9
|
||||
--> tests/ui/std_instead_of_core.rs:20:9
|
||||
|
|
||||
LL | use std::env;
|
||||
| ^^^ help: consider importing the item from `core`: `core`
|
||||
|
||||
error: used import from `std` instead of `core`
|
||||
--> tests/ui/std_instead_of_core.rs:23:9
|
||||
|
|
||||
LL | use std::fmt::{Debug, Result};
|
||||
| ^^^ help: consider importing the item from `core`: `core`
|
||||
|
||||
error: used import from `std` instead of `core`
|
||||
--> tests/ui/std_instead_of_core.rs:26:15
|
||||
--> tests/ui/std_instead_of_core.rs:28:9
|
||||
|
|
||||
LL | use std::{
|
||||
| ^^^ help: consider importing the item from `core`: `core`
|
||||
|
||||
error: used import from `std` instead of `core`
|
||||
--> tests/ui/std_instead_of_core.rs:35:15
|
||||
|
|
||||
LL | let ptr = std::ptr::null::<u32>();
|
||||
| ^^^ help: consider importing the item from `core`: `core`
|
||||
|
||||
error: used import from `std` instead of `core`
|
||||
--> tests/ui/std_instead_of_core.rs:28:21
|
||||
--> tests/ui/std_instead_of_core.rs:37:21
|
||||
|
|
||||
LL | let ptr_mut = ::std::ptr::null_mut::<usize>();
|
||||
| ^^^ help: consider importing the item from `core`: `core`
|
||||
|
||||
error: used import from `std` instead of `core`
|
||||
--> tests/ui/std_instead_of_core.rs:32:16
|
||||
--> tests/ui/std_instead_of_core.rs:41:16
|
||||
|
|
||||
LL | let cell = std::cell::Cell::new(8u32);
|
||||
| ^^^ help: consider importing the item from `core`: `core`
|
||||
|
||||
error: used import from `std` instead of `core`
|
||||
--> tests/ui/std_instead_of_core.rs:34:27
|
||||
--> tests/ui/std_instead_of_core.rs:43:27
|
||||
|
|
||||
LL | let cell_absolute = ::std::cell::Cell::new(8u32);
|
||||
| ^^^ help: consider importing the item from `core`: `core`
|
||||
|
||||
error: used import from `std` instead of `core`
|
||||
--> tests/ui/std_instead_of_core.rs:43:9
|
||||
--> tests/ui/std_instead_of_core.rs:52:9
|
||||
|
|
||||
LL | use std::iter::Iterator;
|
||||
| ^^^ help: consider importing the item from `core`: `core`
|
||||
|
||||
error: used import from `std` instead of `alloc`
|
||||
--> tests/ui/std_instead_of_core.rs:50:9
|
||||
--> tests/ui/std_instead_of_core.rs:59:9
|
||||
|
|
||||
LL | use std::vec;
|
||||
| ^^^ help: consider importing the item from `alloc`: `alloc`
|
||||
|
|
@ -59,13 +71,13 @@ LL | use std::vec;
|
|||
= help: to override `-D warnings` add `#[allow(clippy::std_instead_of_alloc)]`
|
||||
|
||||
error: used import from `std` instead of `alloc`
|
||||
--> tests/ui/std_instead_of_core.rs:52:9
|
||||
--> tests/ui/std_instead_of_core.rs:61:9
|
||||
|
|
||||
LL | use std::vec::Vec;
|
||||
| ^^^ help: consider importing the item from `alloc`: `alloc`
|
||||
|
||||
error: used import from `alloc` instead of `core`
|
||||
--> tests/ui/std_instead_of_core.rs:58:9
|
||||
--> tests/ui/std_instead_of_core.rs:67:9
|
||||
|
|
||||
LL | use alloc::slice::from_ref;
|
||||
| ^^^^^ help: consider importing the item from `core`: `core`
|
||||
|
|
@ -73,5 +85,5 @@ LL | use alloc::slice::from_ref;
|
|||
= note: `-D clippy::alloc-instead-of-core` implied by `-D warnings`
|
||||
= help: to override `-D warnings` add `#[allow(clippy::alloc_instead_of_core)]`
|
||||
|
||||
error: aborting due to 11 previous errors
|
||||
error: aborting due to 13 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
//@compile-flags: -Zdeduplicate-diagnostics=yes
|
||||
|
||||
#![warn(clippy::suspicious_operation_groupings)]
|
||||
#![allow(dead_code, unused_parens, clippy::eq_op)]
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
//@compile-flags: -Zdeduplicate-diagnostics=yes
|
||||
|
||||
#![warn(clippy::suspicious_operation_groupings)]
|
||||
#![allow(dead_code, unused_parens, clippy::eq_op)]
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: this sequence of operators looks suspiciously like a bug
|
||||
--> tests/ui/suspicious_operation_groupings.rs:15:9
|
||||
--> tests/ui/suspicious_operation_groupings.rs:17:9
|
||||
|
|
||||
LL | self.x == other.y && self.y == other.y && self.z == other.z
|
||||
| ^^^^^^^^^^^^^^^^^ help: did you mean: `self.x == other.x`
|
||||
|
|
@ -8,151 +8,151 @@ LL | self.x == other.y && self.y == other.y && self.z == other.z
|
|||
= help: to override `-D warnings` add `#[allow(clippy::suspicious_operation_groupings)]`
|
||||
|
||||
error: this sequence of operators looks suspiciously like a bug
|
||||
--> tests/ui/suspicious_operation_groupings.rs:28:20
|
||||
--> tests/ui/suspicious_operation_groupings.rs:30:20
|
||||
|
|
||||
LL | s1.a < s2.a && s1.a < s2.b
|
||||
| ^^^^^^^^^^^ help: did you mean: `s1.b < s2.b`
|
||||
|
||||
error: this sequence of operators looks suspiciously like a bug
|
||||
--> tests/ui/suspicious_operation_groupings.rs:76:33
|
||||
--> tests/ui/suspicious_operation_groupings.rs:78:33
|
||||
|
|
||||
LL | s1.a * s2.a + s1.b * s2.b + s1.c * s2.b + s1.d * s2.d
|
||||
| ^^^^^^^^^^^ help: did you mean: `s1.c * s2.c`
|
||||
|
||||
error: this sequence of operators looks suspiciously like a bug
|
||||
--> tests/ui/suspicious_operation_groupings.rs:81:19
|
||||
--> tests/ui/suspicious_operation_groupings.rs:83:19
|
||||
|
|
||||
LL | s1.a * s2.a + s1.b * s2.c + s1.c * s2.c
|
||||
| ^^^^^^^^^^^ help: did you mean: `s1.b * s2.b`
|
||||
|
||||
error: this sequence of operators looks suspiciously like a bug
|
||||
--> tests/ui/suspicious_operation_groupings.rs:81:19
|
||||
--> tests/ui/suspicious_operation_groupings.rs:83:19
|
||||
|
|
||||
LL | s1.a * s2.a + s1.b * s2.c + s1.c * s2.c
|
||||
| ^^^^^^^^^^^ help: did you mean: `s1.b * s2.b`
|
||||
|
||||
error: this sequence of operators looks suspiciously like a bug
|
||||
--> tests/ui/suspicious_operation_groupings.rs:86:19
|
||||
--> tests/ui/suspicious_operation_groupings.rs:88:19
|
||||
|
|
||||
LL | s1.a * s2.a + s2.b * s2.b + s1.c * s2.c
|
||||
| ^^^^^^^^^^^ help: did you mean: `s1.b * s2.b`
|
||||
|
||||
error: this sequence of operators looks suspiciously like a bug
|
||||
--> tests/ui/suspicious_operation_groupings.rs:91:19
|
||||
--> tests/ui/suspicious_operation_groupings.rs:93:19
|
||||
|
|
||||
LL | s1.a * s2.a + s1.b * s1.b + s1.c * s2.c
|
||||
| ^^^^^^^^^^^ help: did you mean: `s1.b * s2.b`
|
||||
|
||||
error: this sequence of operators looks suspiciously like a bug
|
||||
--> tests/ui/suspicious_operation_groupings.rs:96:5
|
||||
--> tests/ui/suspicious_operation_groupings.rs:98:5
|
||||
|
|
||||
LL | s1.a * s1.a + s1.b * s2.b + s1.c * s2.c
|
||||
| ^^^^^^^^^^^ help: did you mean: `s1.a * s2.a`
|
||||
|
||||
error: this sequence of operators looks suspiciously like a bug
|
||||
--> tests/ui/suspicious_operation_groupings.rs:101:33
|
||||
--> tests/ui/suspicious_operation_groupings.rs:103:33
|
||||
|
|
||||
LL | s1.a * s2.a + s1.b * s2.b + s1.c * s1.c
|
||||
| ^^^^^^^^^^^ help: did you mean: `s1.c * s2.c`
|
||||
|
||||
error: this sequence of operators looks suspiciously like a bug
|
||||
--> tests/ui/suspicious_operation_groupings.rs:114:20
|
||||
--> tests/ui/suspicious_operation_groupings.rs:116:20
|
||||
|
|
||||
LL | (s1.a * s2.a + s1.b * s1.b)
|
||||
| ^^^^^^^^^^^ help: did you mean: `s1.b * s2.b`
|
||||
|
||||
error: this sequence of operators looks suspiciously like a bug
|
||||
--> tests/ui/suspicious_operation_groupings.rs:119:34
|
||||
--> tests/ui/suspicious_operation_groupings.rs:121:34
|
||||
|
|
||||
LL | (s1.a * s2.a + s1.b * s2.b + s1.c * s2.b + s1.d * s2.d)
|
||||
| ^^^^^^^^^^^ help: did you mean: `s1.c * s2.c`
|
||||
|
||||
error: this sequence of operators looks suspiciously like a bug
|
||||
--> tests/ui/suspicious_operation_groupings.rs:124:38
|
||||
--> tests/ui/suspicious_operation_groupings.rs:126:38
|
||||
|
|
||||
LL | (s1.a * s2.a) + (s1.b * s2.b) + (s1.c * s2.b) + (s1.d * s2.d)
|
||||
| ^^^^^^^^^^^ help: did you mean: `s1.c * s2.c`
|
||||
|
||||
error: this sequence of operators looks suspiciously like a bug
|
||||
--> tests/ui/suspicious_operation_groupings.rs:129:39
|
||||
--> tests/ui/suspicious_operation_groupings.rs:131:39
|
||||
|
|
||||
LL | ((s1.a * s2.a) + (s1.b * s2.b) + (s1.c * s2.b) + (s1.d * s2.d))
|
||||
| ^^^^^^^^^^^ help: did you mean: `s1.c * s2.c`
|
||||
|
||||
error: this sequence of operators looks suspiciously like a bug
|
||||
--> tests/ui/suspicious_operation_groupings.rs:134:42
|
||||
--> tests/ui/suspicious_operation_groupings.rs:136:42
|
||||
|
|
||||
LL | (((s1.a * s2.a) + (s1.b * s2.b)) + ((s1.c * s2.b) + (s1.d * s2.d)))
|
||||
| ^^^^^^^^^^^ help: did you mean: `s1.c * s2.c`
|
||||
|
||||
error: this sequence of operators looks suspiciously like a bug
|
||||
--> tests/ui/suspicious_operation_groupings.rs:134:42
|
||||
--> tests/ui/suspicious_operation_groupings.rs:136:42
|
||||
|
|
||||
LL | (((s1.a * s2.a) + (s1.b * s2.b)) + ((s1.c * s2.b) + (s1.d * s2.d)))
|
||||
| ^^^^^^^^^^^ help: did you mean: `s1.c * s2.c`
|
||||
|
||||
error: this sequence of operators looks suspiciously like a bug
|
||||
--> tests/ui/suspicious_operation_groupings.rs:139:40
|
||||
--> tests/ui/suspicious_operation_groupings.rs:141:40
|
||||
|
|
||||
LL | (((s1.a * s2.a) + (s1.b * s2.b) + (s1.c * s2.b)) + (s1.d * s2.d))
|
||||
| ^^^^^^^^^^^ help: did you mean: `s1.c * s2.c`
|
||||
|
||||
error: this sequence of operators looks suspiciously like a bug
|
||||
--> tests/ui/suspicious_operation_groupings.rs:144:40
|
||||
--> tests/ui/suspicious_operation_groupings.rs:146:40
|
||||
|
|
||||
LL | ((s1.a * s2.a) + ((s1.b * s2.b) + (s1.c * s2.b) + (s1.d * s2.d)))
|
||||
| ^^^^^^^^^^^ help: did you mean: `s1.c * s2.c`
|
||||
|
||||
error: this sequence of operators looks suspiciously like a bug
|
||||
--> tests/ui/suspicious_operation_groupings.rs:149:20
|
||||
--> tests/ui/suspicious_operation_groupings.rs:151:20
|
||||
|
|
||||
LL | (s1.a * s2.a + s2.b * s2.b) / 2
|
||||
| ^^^^^^^^^^^ help: did you mean: `s1.b * s2.b`
|
||||
|
||||
error: this sequence of operators looks suspiciously like a bug
|
||||
--> tests/ui/suspicious_operation_groupings.rs:154:35
|
||||
--> tests/ui/suspicious_operation_groupings.rs:156:35
|
||||
|
|
||||
LL | i32::swap_bytes(s1.a * s2.a + s2.b * s2.b)
|
||||
| ^^^^^^^^^^^ help: did you mean: `s1.b * s2.b`
|
||||
|
||||
error: this sequence of operators looks suspiciously like a bug
|
||||
--> tests/ui/suspicious_operation_groupings.rs:159:29
|
||||
--> tests/ui/suspicious_operation_groupings.rs:161:29
|
||||
|
|
||||
LL | s1.a > 0 && s1.b > 0 && s1.d == s2.c && s1.d == s2.d
|
||||
| ^^^^^^^^^^^^ help: did you mean: `s1.c == s2.c`
|
||||
|
||||
error: this sequence of operators looks suspiciously like a bug
|
||||
--> tests/ui/suspicious_operation_groupings.rs:164:17
|
||||
--> tests/ui/suspicious_operation_groupings.rs:166:17
|
||||
|
|
||||
LL | s1.a > 0 && s1.d == s2.c && s1.b > 0 && s1.d == s2.d
|
||||
| ^^^^^^^^^^^^ help: did you mean: `s1.c == s2.c`
|
||||
|
||||
error: this sequence of operators looks suspiciously like a bug
|
||||
--> tests/ui/suspicious_operation_groupings.rs:173:77
|
||||
--> tests/ui/suspicious_operation_groupings.rs:175:77
|
||||
|
|
||||
LL | (n1.inner.0).0 == (n2.inner.0).0 && (n1.inner.1).0 == (n2.inner.1).0 && (n1.inner.2).0 == (n2.inner.1).0
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: did you mean: `(n1.inner.2).0 == (n2.inner.2).0`
|
||||
|
||||
error: this sequence of operators looks suspiciously like a bug
|
||||
--> tests/ui/suspicious_operation_groupings.rs:187:25
|
||||
--> tests/ui/suspicious_operation_groupings.rs:189:25
|
||||
|
|
||||
LL | s1.a <= s2.a && s1.a <= s2.b
|
||||
| ^^^^^^^^^^^^ help: did you mean: `s1.b <= s2.b`
|
||||
|
||||
error: this sequence of operators looks suspiciously like a bug
|
||||
--> tests/ui/suspicious_operation_groupings.rs:193:23
|
||||
--> tests/ui/suspicious_operation_groupings.rs:195:23
|
||||
|
|
||||
LL | if s1.a < s2.a && s1.a < s2.b {
|
||||
| ^^^^^^^^^^^ help: did you mean: `s1.b < s2.b`
|
||||
|
||||
error: this sequence of operators looks suspiciously like a bug
|
||||
--> tests/ui/suspicious_operation_groupings.rs:200:48
|
||||
--> tests/ui/suspicious_operation_groupings.rs:202:48
|
||||
|
|
||||
LL | -(-(-s1.a * -s2.a) + (-(-s1.b * -s2.b) + -(-s1.c * -s2.b) + -(-s1.d * -s2.d)))
|
||||
| ^^^^^^^^^^^^^ help: did you mean: `-s1.c * -s2.c`
|
||||
|
||||
error: this sequence of operators looks suspiciously like a bug
|
||||
--> tests/ui/suspicious_operation_groupings.rs:205:27
|
||||
--> tests/ui/suspicious_operation_groupings.rs:207:27
|
||||
|
|
||||
LL | -(if -s1.a < -s2.a && -s1.a < -s2.b { s1.c } else { s2.a })
|
||||
| ^^^^^^^^^^^^^ help: did you mean: `-s1.b < -s2.b`
|
||||
|
|
|
|||
|
|
@ -27,4 +27,18 @@ fn main() {
|
|||
}
|
||||
//~^^^^ ERROR: initializer for `thread_local` value can be made `const`
|
||||
//~^^^ ERROR: initializer for `thread_local` value can be made `const`
|
||||
|
||||
thread_local! {
|
||||
static PEEL_ME: i32 = const { 1 };
|
||||
//~^ ERROR: initializer for `thread_local` value can be made `const`
|
||||
static PEEL_ME_MANY: i32 = const { { let x = 1; x * x } };
|
||||
//~^ ERROR: initializer for `thread_local` value can be made `const`
|
||||
}
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.58"]
|
||||
fn f() {
|
||||
thread_local! {
|
||||
static TLS: i32 = 1;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,4 +27,18 @@ fn main() {
|
|||
}
|
||||
//~^^^^ ERROR: initializer for `thread_local` value can be made `const`
|
||||
//~^^^ ERROR: initializer for `thread_local` value can be made `const`
|
||||
|
||||
thread_local! {
|
||||
static PEEL_ME: i32 = { 1 };
|
||||
//~^ ERROR: initializer for `thread_local` value can be made `const`
|
||||
static PEEL_ME_MANY: i32 = { let x = 1; x * x };
|
||||
//~^ ERROR: initializer for `thread_local` value can be made `const`
|
||||
}
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.58"]
|
||||
fn f() {
|
||||
thread_local! {
|
||||
static TLS: i32 = 1;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,5 +25,17 @@ error: initializer for `thread_local` value can be made `const`
|
|||
LL | static BUF_4_CAN_BE_MADE_CONST: RefCell<String> = RefCell::new(String::new());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `const { RefCell::new(String::new()) }`
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
error: initializer for `thread_local` value can be made `const`
|
||||
--> tests/ui/thread_local_initializer_can_be_made_const.rs:32:31
|
||||
|
|
||||
LL | static PEEL_ME: i32 = { 1 };
|
||||
| ^^^^^ help: replace with: `const { 1 }`
|
||||
|
||||
error: initializer for `thread_local` value can be made `const`
|
||||
--> tests/ui/thread_local_initializer_can_be_made_const.rs:34:36
|
||||
|
|
||||
LL | static PEEL_ME_MANY: i32 = { let x = 1; x * x };
|
||||
| ^^^^^^^^^^^^^^^^^^^^ help: replace with: `const { { let x = 1; x * x } }`
|
||||
|
||||
error: aborting due to 6 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -82,3 +82,10 @@ fn issue_10449() {
|
|||
|
||||
let _x: u8 = unsafe { *(f as *const u8) };
|
||||
}
|
||||
|
||||
// Pointers cannot be cast to integers in const contexts
|
||||
const fn issue_12402<P>(ptr: *const P) {
|
||||
unsafe { transmute::<*const i32, usize>(&42i32) };
|
||||
unsafe { transmute::<fn(*const P), usize>(issue_12402) };
|
||||
let _ = unsafe { transmute::<_, usize>(ptr) };
|
||||
}
|
||||
|
|
|
|||
|
|
@ -82,3 +82,10 @@ fn issue_10449() {
|
|||
|
||||
let _x: u8 = unsafe { *std::mem::transmute::<fn(), *const u8>(f) };
|
||||
}
|
||||
|
||||
// Pointers cannot be cast to integers in const contexts
|
||||
const fn issue_12402<P>(ptr: *const P) {
|
||||
unsafe { transmute::<*const i32, usize>(&42i32) };
|
||||
unsafe { transmute::<fn(*const P), usize>(issue_12402) };
|
||||
let _ = unsafe { transmute::<_, usize>(ptr) };
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
//@compile-flags: -Zdeduplicate-diagnostics=yes
|
||||
|
||||
#![warn(clippy::all)]
|
||||
#![allow(unused, clippy::needless_pass_by_value, clippy::vec_box, clippy::useless_vec)]
|
||||
#![feature(associated_type_defaults)]
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: very complex type used. Consider factoring parts into `type` definitions
|
||||
--> tests/ui/type_complexity.rs:7:12
|
||||
--> tests/ui/type_complexity.rs:9:12
|
||||
|
|
||||
LL | const CST: (u32, (u32, (u32, (u32, u32)))) = (0, (0, (0, (0, 0))));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -8,85 +8,85 @@ LL | const CST: (u32, (u32, (u32, (u32, u32)))) = (0, (0, (0, (0, 0))));
|
|||
= help: to override `-D warnings` add `#[allow(clippy::type_complexity)]`
|
||||
|
||||
error: very complex type used. Consider factoring parts into `type` definitions
|
||||
--> tests/ui/type_complexity.rs:10:12
|
||||
--> tests/ui/type_complexity.rs:12:12
|
||||
|
|
||||
LL | static ST: (u32, (u32, (u32, (u32, u32)))) = (0, (0, (0, (0, 0))));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: very complex type used. Consider factoring parts into `type` definitions
|
||||
--> tests/ui/type_complexity.rs:14:8
|
||||
--> tests/ui/type_complexity.rs:16:8
|
||||
|
|
||||
LL | f: Vec<Vec<Box<(u32, u32, u32, u32)>>>,
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: very complex type used. Consider factoring parts into `type` definitions
|
||||
--> tests/ui/type_complexity.rs:18:11
|
||||
--> tests/ui/type_complexity.rs:20:11
|
||||
|
|
||||
LL | struct Ts(Vec<Vec<Box<(u32, u32, u32, u32)>>>);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: very complex type used. Consider factoring parts into `type` definitions
|
||||
--> tests/ui/type_complexity.rs:22:11
|
||||
--> tests/ui/type_complexity.rs:24:11
|
||||
|
|
||||
LL | Tuple(Vec<Vec<Box<(u32, u32, u32, u32)>>>),
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: very complex type used. Consider factoring parts into `type` definitions
|
||||
--> tests/ui/type_complexity.rs:24:17
|
||||
--> tests/ui/type_complexity.rs:26:17
|
||||
|
|
||||
LL | Struct { f: Vec<Vec<Box<(u32, u32, u32, u32)>>> },
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: very complex type used. Consider factoring parts into `type` definitions
|
||||
--> tests/ui/type_complexity.rs:29:14
|
||||
--> tests/ui/type_complexity.rs:31:14
|
||||
|
|
||||
LL | const A: (u32, (u32, (u32, (u32, u32)))) = (0, (0, (0, (0, 0))));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: very complex type used. Consider factoring parts into `type` definitions
|
||||
--> tests/ui/type_complexity.rs:31:30
|
||||
--> tests/ui/type_complexity.rs:33:30
|
||||
|
|
||||
LL | fn impl_method(&self, p: Vec<Vec<Box<(u32, u32, u32, u32)>>>) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: very complex type used. Consider factoring parts into `type` definitions
|
||||
--> tests/ui/type_complexity.rs:36:14
|
||||
--> tests/ui/type_complexity.rs:38:14
|
||||
|
|
||||
LL | const A: Vec<Vec<Box<(u32, u32, u32, u32)>>>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: very complex type used. Consider factoring parts into `type` definitions
|
||||
--> tests/ui/type_complexity.rs:38:14
|
||||
--> tests/ui/type_complexity.rs:40:14
|
||||
|
|
||||
LL | type B = Vec<Vec<Box<(u32, u32, u32, u32)>>>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: very complex type used. Consider factoring parts into `type` definitions
|
||||
--> tests/ui/type_complexity.rs:40:25
|
||||
--> tests/ui/type_complexity.rs:42:25
|
||||
|
|
||||
LL | fn method(&self, p: Vec<Vec<Box<(u32, u32, u32, u32)>>>);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: very complex type used. Consider factoring parts into `type` definitions
|
||||
--> tests/ui/type_complexity.rs:42:29
|
||||
--> tests/ui/type_complexity.rs:44:29
|
||||
|
|
||||
LL | fn def_method(&self, p: Vec<Vec<Box<(u32, u32, u32, u32)>>>) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: very complex type used. Consider factoring parts into `type` definitions
|
||||
--> tests/ui/type_complexity.rs:55:15
|
||||
--> tests/ui/type_complexity.rs:57:15
|
||||
|
|
||||
LL | fn test1() -> Vec<Vec<Box<(u32, u32, u32, u32)>>> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: very complex type used. Consider factoring parts into `type` definitions
|
||||
--> tests/ui/type_complexity.rs:60:14
|
||||
--> tests/ui/type_complexity.rs:62:14
|
||||
|
|
||||
LL | fn test2(_x: Vec<Vec<Box<(u32, u32, u32, u32)>>>) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: very complex type used. Consider factoring parts into `type` definitions
|
||||
--> tests/ui/type_complexity.rs:64:13
|
||||
--> tests/ui/type_complexity.rs:66:13
|
||||
|
|
||||
LL | let _y: Vec<Vec<Box<(u32, u32, u32, u32)>>> = vec![];
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
//@compile-flags: -Zdeduplicate-diagnostics=yes
|
||||
|
||||
#[clippy::unknown]
|
||||
//~^ ERROR: usage of unknown attribute
|
||||
#[clippy::cognitive_complexity = "1"]
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: usage of unknown attribute
|
||||
--> tests/ui/unknown_attribute.rs:1:11
|
||||
--> tests/ui/unknown_attribute.rs:3:11
|
||||
|
|
||||
LL | #[clippy::unknown]
|
||||
| ^^^^^^^
|
||||
|
|
|
|||
|
|
@ -221,4 +221,10 @@ mod fixable {
|
|||
fn issue_9603() {
|
||||
let _: f32 = -0x400 as f32;
|
||||
}
|
||||
|
||||
// Issue #11968: The suggestion for this lint removes the parentheses and leave the code as
|
||||
// `*x.pow(2)` which tries to dereference the return value rather than `x`.
|
||||
fn issue_11968(x: &usize) -> usize {
|
||||
{ *x }.pow(2)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -221,4 +221,10 @@ mod fixable {
|
|||
fn issue_9603() {
|
||||
let _: f32 = -0x400 as f32;
|
||||
}
|
||||
|
||||
// Issue #11968: The suggestion for this lint removes the parentheses and leave the code as
|
||||
// `*x.pow(2)` which tries to dereference the return value rather than `x`.
|
||||
fn issue_11968(x: &usize) -> usize {
|
||||
(*x as usize).pow(2)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -241,5 +241,11 @@ error: casting to the same type is unnecessary (`f32` -> `f32`)
|
|||
LL | let _num = foo() as f32;
|
||||
| ^^^^^^^^^^^^ help: try: `foo()`
|
||||
|
||||
error: aborting due to 40 previous errors
|
||||
error: casting to the same type is unnecessary (`usize` -> `usize`)
|
||||
--> tests/ui/unnecessary_cast.rs:228:9
|
||||
|
|
||||
LL | (*x as usize).pow(2)
|
||||
| ^^^^^^^^^^^^^ help: try: `{ *x }`
|
||||
|
||||
error: aborting due to 41 previous errors
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue