Merge branch 'master' into fix-4727
This commit is contained in:
commit
9c48a2c39a
55 changed files with 417 additions and 330 deletions
|
|
@ -16,7 +16,7 @@ pub fn derive(_: TokenStream) -> TokenStream {
|
|||
let output = quote! {
|
||||
// Should not trigger `useless_attribute`
|
||||
#[allow(dead_code)]
|
||||
extern crate clippy_lints;
|
||||
extern crate rustc;
|
||||
};
|
||||
output
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,9 +10,11 @@ error[E0308]: mismatched types
|
|||
--> $DIR/builtin-type-shadow.rs:5:5
|
||||
|
|
||||
LL | fn foo<u32>(a: u32) -> u32 {
|
||||
| --- expected `u32` because of return type
|
||||
| --- --- expected `u32` because of return type
|
||||
| |
|
||||
| this type parameter
|
||||
LL | 42
|
||||
| ^^ expected type parameter, found integer
|
||||
| ^^ expected type parameter `u32`, found integer
|
||||
|
|
||||
= note: expected type `u32`
|
||||
found type `{integer}`
|
||||
|
|
|
|||
10
tests/ui/crashes/ice-4760.rs
Normal file
10
tests/ui/crashes/ice-4760.rs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
// run-pass
|
||||
const COUNT: usize = 2;
|
||||
struct Thing;
|
||||
trait Dummy {}
|
||||
|
||||
const _: () = {
|
||||
impl Dummy for Thing where [i32; COUNT]: Sized {}
|
||||
};
|
||||
|
||||
fn main() {}
|
||||
|
|
@ -5,5 +5,6 @@
|
|||
#[warn(clippy::misaligned_transmute)]
|
||||
#[warn(clippy::unused_collect)]
|
||||
#[warn(clippy::invalid_ref)]
|
||||
#[warn(clippy::into_iter_on_array)]
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -42,11 +42,17 @@ error: lint `clippy::invalid_ref` has been removed: `superseded by rustc lint `i
|
|||
LL | #[warn(clippy::invalid_ref)]
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: lint `clippy::into_iter_on_array` has been removed: `this lint has been uplifted to rustc and is now called `array_into_iter``
|
||||
--> $DIR/deprecated.rs:8:8
|
||||
|
|
||||
LL | #[warn(clippy::into_iter_on_array)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: lint `clippy::str_to_string` has been removed: `using `str::to_string` is common even today and specialization will likely happen soon`
|
||||
--> $DIR/deprecated.rs:1:8
|
||||
|
|
||||
LL | #[warn(clippy::str_to_string)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 8 previous errors
|
||||
error: aborting due to 9 previous errors
|
||||
|
||||
|
|
|
|||
15
tests/ui/exit1.rs
Normal file
15
tests/ui/exit1.rs
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
#[warn(clippy::exit)]
|
||||
|
||||
fn not_main() {
|
||||
if true {
|
||||
std::process::exit(4);
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
if true {
|
||||
std::process::exit(2);
|
||||
};
|
||||
not_main();
|
||||
std::process::exit(1);
|
||||
}
|
||||
10
tests/ui/exit1.stderr
Normal file
10
tests/ui/exit1.stderr
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
error: usage of `process::exit`
|
||||
--> $DIR/exit1.rs:5:9
|
||||
|
|
||||
LL | std::process::exit(4);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: `-D clippy::exit` implied by `-D warnings`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
13
tests/ui/exit2.rs
Normal file
13
tests/ui/exit2.rs
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
#[warn(clippy::exit)]
|
||||
|
||||
fn also_not_main() {
|
||||
std::process::exit(3);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
if true {
|
||||
std::process::exit(2);
|
||||
};
|
||||
also_not_main();
|
||||
std::process::exit(1);
|
||||
}
|
||||
10
tests/ui/exit2.stderr
Normal file
10
tests/ui/exit2.stderr
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
error: usage of `process::exit`
|
||||
--> $DIR/exit2.rs:4:5
|
||||
|
|
||||
LL | std::process::exit(3);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: `-D clippy::exit` implied by `-D warnings`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
8
tests/ui/exit3.rs
Normal file
8
tests/ui/exit3.rs
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
#[warn(clippy::exit)]
|
||||
|
||||
fn main() {
|
||||
if true {
|
||||
std::process::exit(2);
|
||||
};
|
||||
std::process::exit(1);
|
||||
}
|
||||
|
|
@ -31,7 +31,7 @@ impl Unrelated {
|
|||
clippy::cognitive_complexity,
|
||||
clippy::similar_names
|
||||
)]
|
||||
#[allow(clippy::many_single_char_names, unused_variables, clippy::into_iter_on_array)]
|
||||
#[allow(clippy::many_single_char_names, unused_variables)]
|
||||
fn main() {
|
||||
const MAX_LEN: usize = 42;
|
||||
let mut vec = vec![1, 2, 3, 4];
|
||||
|
|
@ -102,9 +102,6 @@ fn main() {
|
|||
let out_vec = vec![1, 2, 3];
|
||||
for _v in out_vec {}
|
||||
|
||||
let array = [1, 2, 3];
|
||||
for _v in &array {}
|
||||
|
||||
for _v in &vec {} // these are fine
|
||||
for _v in &mut vec {} // these are fine
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ impl Unrelated {
|
|||
clippy::cognitive_complexity,
|
||||
clippy::similar_names
|
||||
)]
|
||||
#[allow(clippy::many_single_char_names, unused_variables, clippy::into_iter_on_array)]
|
||||
#[allow(clippy::many_single_char_names, unused_variables)]
|
||||
fn main() {
|
||||
const MAX_LEN: usize = 42;
|
||||
let mut vec = vec![1, 2, 3, 4];
|
||||
|
|
@ -102,9 +102,6 @@ fn main() {
|
|||
let out_vec = vec![1, 2, 3];
|
||||
for _v in out_vec.into_iter() {}
|
||||
|
||||
let array = [1, 2, 3];
|
||||
for _v in array.into_iter() {}
|
||||
|
||||
for _v in &vec {} // these are fine
|
||||
for _v in &mut vec {} // these are fine
|
||||
|
||||
|
|
|
|||
|
|
@ -77,64 +77,58 @@ LL | for _v in out_vec.into_iter() {}
|
|||
= note: `-D clippy::explicit-into-iter-loop` implied by `-D warnings`
|
||||
|
||||
error: it is more concise to loop over references to containers instead of using explicit iteration methods
|
||||
--> $DIR/for_loop_fixable.rs:106:15
|
||||
|
|
||||
LL | for _v in array.into_iter() {}
|
||||
| ^^^^^^^^^^^^^^^^^ help: to write this more concisely, try: `&array`
|
||||
|
||||
error: it is more concise to loop over references to containers instead of using explicit iteration methods
|
||||
--> $DIR/for_loop_fixable.rs:111:15
|
||||
--> $DIR/for_loop_fixable.rs:108:15
|
||||
|
|
||||
LL | for _v in [1, 2, 3].iter() {}
|
||||
| ^^^^^^^^^^^^^^^^ help: to write this more concisely, try: `&[1, 2, 3]`
|
||||
|
||||
error: it is more concise to loop over references to containers instead of using explicit iteration methods
|
||||
--> $DIR/for_loop_fixable.rs:115:15
|
||||
--> $DIR/for_loop_fixable.rs:112:15
|
||||
|
|
||||
LL | for _v in [0; 32].iter() {}
|
||||
| ^^^^^^^^^^^^^^ help: to write this more concisely, try: `&[0; 32]`
|
||||
|
||||
error: it is more concise to loop over references to containers instead of using explicit iteration methods
|
||||
--> $DIR/for_loop_fixable.rs:120:15
|
||||
--> $DIR/for_loop_fixable.rs:117:15
|
||||
|
|
||||
LL | for _v in ll.iter() {}
|
||||
| ^^^^^^^^^ help: to write this more concisely, try: `&ll`
|
||||
|
||||
error: it is more concise to loop over references to containers instead of using explicit iteration methods
|
||||
--> $DIR/for_loop_fixable.rs:123:15
|
||||
--> $DIR/for_loop_fixable.rs:120:15
|
||||
|
|
||||
LL | for _v in vd.iter() {}
|
||||
| ^^^^^^^^^ help: to write this more concisely, try: `&vd`
|
||||
|
||||
error: it is more concise to loop over references to containers instead of using explicit iteration methods
|
||||
--> $DIR/for_loop_fixable.rs:126:15
|
||||
--> $DIR/for_loop_fixable.rs:123:15
|
||||
|
|
||||
LL | for _v in bh.iter() {}
|
||||
| ^^^^^^^^^ help: to write this more concisely, try: `&bh`
|
||||
|
||||
error: it is more concise to loop over references to containers instead of using explicit iteration methods
|
||||
--> $DIR/for_loop_fixable.rs:129:15
|
||||
--> $DIR/for_loop_fixable.rs:126:15
|
||||
|
|
||||
LL | for _v in hm.iter() {}
|
||||
| ^^^^^^^^^ help: to write this more concisely, try: `&hm`
|
||||
|
||||
error: it is more concise to loop over references to containers instead of using explicit iteration methods
|
||||
--> $DIR/for_loop_fixable.rs:132:15
|
||||
--> $DIR/for_loop_fixable.rs:129:15
|
||||
|
|
||||
LL | for _v in bt.iter() {}
|
||||
| ^^^^^^^^^ help: to write this more concisely, try: `&bt`
|
||||
|
||||
error: it is more concise to loop over references to containers instead of using explicit iteration methods
|
||||
--> $DIR/for_loop_fixable.rs:135:15
|
||||
--> $DIR/for_loop_fixable.rs:132:15
|
||||
|
|
||||
LL | for _v in hs.iter() {}
|
||||
| ^^^^^^^^^ help: to write this more concisely, try: `&hs`
|
||||
|
||||
error: it is more concise to loop over references to containers instead of using explicit iteration methods
|
||||
--> $DIR/for_loop_fixable.rs:138:15
|
||||
--> $DIR/for_loop_fixable.rs:135:15
|
||||
|
|
||||
LL | for _v in bs.iter() {}
|
||||
| ^^^^^^^^^ help: to write this more concisely, try: `&bs`
|
||||
|
||||
error: aborting due to 18 previous errors
|
||||
error: aborting due to 17 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
unused,
|
||||
dead_code
|
||||
)]
|
||||
#[allow(clippy::many_single_char_names, unused_variables, clippy::into_iter_on_array)]
|
||||
#[allow(clippy::many_single_char_names, unused_variables)]
|
||||
fn main() {
|
||||
for i in 5..5 {
|
||||
println!("{}", i);
|
||||
|
|
|
|||
|
|
@ -31,12 +31,12 @@ fn bad_multiline(
|
|||
extern "C" fn extern_fn(
|
||||
_one: u32,
|
||||
_two: u32,
|
||||
_three: &str,
|
||||
_three: *const u8,
|
||||
_four: bool,
|
||||
_five: f32,
|
||||
_six: f32,
|
||||
_seven: bool,
|
||||
_eight: (),
|
||||
_eight: *const std::ffi::c_void,
|
||||
) {
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
// run-rustfix
|
||||
#![allow(clippy::useless_vec)]
|
||||
#![warn(clippy::into_iter_on_ref)]
|
||||
#![deny(clippy::into_iter_on_array)]
|
||||
|
||||
struct X;
|
||||
use std::collections::*;
|
||||
|
|
@ -10,9 +9,7 @@ fn main() {
|
|||
for _ in &[1, 2, 3] {}
|
||||
for _ in vec![X, X] {}
|
||||
for _ in &vec![X, X] {}
|
||||
for _ in [1, 2, 3].iter() {} //~ ERROR equivalent to .iter()
|
||||
|
||||
let _ = [1, 2, 3].iter(); //~ ERROR equivalent to .iter()
|
||||
let _ = vec![1, 2, 3].into_iter();
|
||||
let _ = (&vec![1, 2, 3]).iter(); //~ WARN equivalent to .iter()
|
||||
let _ = vec![1, 2, 3].into_boxed_slice().iter(); //~ WARN equivalent to .iter()
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
// run-rustfix
|
||||
#![allow(clippy::useless_vec)]
|
||||
#![warn(clippy::into_iter_on_ref)]
|
||||
#![deny(clippy::into_iter_on_array)]
|
||||
|
||||
struct X;
|
||||
use std::collections::*;
|
||||
|
|
@ -10,9 +9,7 @@ fn main() {
|
|||
for _ in &[1, 2, 3] {}
|
||||
for _ in vec![X, X] {}
|
||||
for _ in &vec![X, X] {}
|
||||
for _ in [1, 2, 3].into_iter() {} //~ ERROR equivalent to .iter()
|
||||
|
||||
let _ = [1, 2, 3].into_iter(); //~ ERROR equivalent to .iter()
|
||||
let _ = vec![1, 2, 3].into_iter();
|
||||
let _ = (&vec![1, 2, 3]).into_iter(); //~ WARN equivalent to .iter()
|
||||
let _ = vec![1, 2, 3].into_boxed_slice().into_iter(); //~ WARN equivalent to .iter()
|
||||
|
|
|
|||
|
|
@ -1,23 +1,5 @@
|
|||
error: this .into_iter() call is equivalent to .iter() and will not move the array
|
||||
--> $DIR/into_iter_on_ref.rs:13:24
|
||||
|
|
||||
LL | for _ in [1, 2, 3].into_iter() {} //~ ERROR equivalent to .iter()
|
||||
| ^^^^^^^^^ help: call directly: `iter`
|
||||
|
|
||||
note: lint level defined here
|
||||
--> $DIR/into_iter_on_ref.rs:4:9
|
||||
|
|
||||
LL | #![deny(clippy::into_iter_on_array)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: this .into_iter() call is equivalent to .iter() and will not move the array
|
||||
--> $DIR/into_iter_on_ref.rs:15:23
|
||||
|
|
||||
LL | let _ = [1, 2, 3].into_iter(); //~ ERROR equivalent to .iter()
|
||||
| ^^^^^^^^^ help: call directly: `iter`
|
||||
|
||||
error: this .into_iter() call is equivalent to .iter() and will not move the Vec
|
||||
--> $DIR/into_iter_on_ref.rs:17:30
|
||||
--> $DIR/into_iter_on_ref.rs:14:30
|
||||
|
|
||||
LL | let _ = (&vec![1, 2, 3]).into_iter(); //~ WARN equivalent to .iter()
|
||||
| ^^^^^^^^^ help: call directly: `iter`
|
||||
|
|
@ -25,154 +7,154 @@ LL | let _ = (&vec![1, 2, 3]).into_iter(); //~ WARN equivalent to .iter()
|
|||
= note: `-D clippy::into-iter-on-ref` implied by `-D warnings`
|
||||
|
||||
error: this .into_iter() call is equivalent to .iter() and will not move the slice
|
||||
--> $DIR/into_iter_on_ref.rs:18:46
|
||||
--> $DIR/into_iter_on_ref.rs:15:46
|
||||
|
|
||||
LL | let _ = vec![1, 2, 3].into_boxed_slice().into_iter(); //~ WARN equivalent to .iter()
|
||||
| ^^^^^^^^^ help: call directly: `iter`
|
||||
|
||||
error: this .into_iter() call is equivalent to .iter() and will not move the slice
|
||||
--> $DIR/into_iter_on_ref.rs:19:41
|
||||
--> $DIR/into_iter_on_ref.rs:16:41
|
||||
|
|
||||
LL | let _ = std::rc::Rc::from(&[X][..]).into_iter(); //~ WARN equivalent to .iter()
|
||||
| ^^^^^^^^^ help: call directly: `iter`
|
||||
|
||||
error: this .into_iter() call is equivalent to .iter() and will not move the slice
|
||||
--> $DIR/into_iter_on_ref.rs:20:44
|
||||
--> $DIR/into_iter_on_ref.rs:17:44
|
||||
|
|
||||
LL | let _ = std::sync::Arc::from(&[X][..]).into_iter(); //~ WARN equivalent to .iter()
|
||||
| ^^^^^^^^^ help: call directly: `iter`
|
||||
|
||||
error: this .into_iter() call is equivalent to .iter() and will not move the array
|
||||
--> $DIR/into_iter_on_ref.rs:22:32
|
||||
--> $DIR/into_iter_on_ref.rs:19:32
|
||||
|
|
||||
LL | let _ = (&&&&&&&[1, 2, 3]).into_iter(); //~ ERROR equivalent to .iter()
|
||||
| ^^^^^^^^^ help: call directly: `iter`
|
||||
|
||||
error: this .into_iter() call is equivalent to .iter() and will not move the array
|
||||
--> $DIR/into_iter_on_ref.rs:23:36
|
||||
--> $DIR/into_iter_on_ref.rs:20:36
|
||||
|
|
||||
LL | let _ = (&&&&mut &&&[1, 2, 3]).into_iter(); //~ ERROR equivalent to .iter()
|
||||
| ^^^^^^^^^ help: call directly: `iter`
|
||||
|
||||
error: this .into_iter() call is equivalent to .iter_mut() and will not move the array
|
||||
--> $DIR/into_iter_on_ref.rs:24:40
|
||||
--> $DIR/into_iter_on_ref.rs:21:40
|
||||
|
|
||||
LL | let _ = (&mut &mut &mut [1, 2, 3]).into_iter(); //~ ERROR equivalent to .iter_mut()
|
||||
| ^^^^^^^^^ help: call directly: `iter_mut`
|
||||
|
||||
error: this .into_iter() call is equivalent to .iter() and will not move the Option
|
||||
--> $DIR/into_iter_on_ref.rs:26:24
|
||||
--> $DIR/into_iter_on_ref.rs:23:24
|
||||
|
|
||||
LL | let _ = (&Some(4)).into_iter(); //~ WARN equivalent to .iter()
|
||||
| ^^^^^^^^^ help: call directly: `iter`
|
||||
|
||||
error: this .into_iter() call is equivalent to .iter_mut() and will not move the Option
|
||||
--> $DIR/into_iter_on_ref.rs:27:28
|
||||
--> $DIR/into_iter_on_ref.rs:24:28
|
||||
|
|
||||
LL | let _ = (&mut Some(5)).into_iter(); //~ WARN equivalent to .iter_mut()
|
||||
| ^^^^^^^^^ help: call directly: `iter_mut`
|
||||
|
||||
error: this .into_iter() call is equivalent to .iter() and will not move the Result
|
||||
--> $DIR/into_iter_on_ref.rs:28:32
|
||||
--> $DIR/into_iter_on_ref.rs:25:32
|
||||
|
|
||||
LL | let _ = (&Ok::<_, i32>(6)).into_iter(); //~ WARN equivalent to .iter()
|
||||
| ^^^^^^^^^ help: call directly: `iter`
|
||||
|
||||
error: this .into_iter() call is equivalent to .iter_mut() and will not move the Result
|
||||
--> $DIR/into_iter_on_ref.rs:29:37
|
||||
--> $DIR/into_iter_on_ref.rs:26:37
|
||||
|
|
||||
LL | let _ = (&mut Err::<i32, _>(7)).into_iter(); //~ WARN equivalent to .iter_mut()
|
||||
| ^^^^^^^^^ help: call directly: `iter_mut`
|
||||
|
||||
error: this .into_iter() call is equivalent to .iter() and will not move the Vec
|
||||
--> $DIR/into_iter_on_ref.rs:30:34
|
||||
--> $DIR/into_iter_on_ref.rs:27:34
|
||||
|
|
||||
LL | let _ = (&Vec::<i32>::new()).into_iter(); //~ WARN equivalent to .iter()
|
||||
| ^^^^^^^^^ help: call directly: `iter`
|
||||
|
||||
error: this .into_iter() call is equivalent to .iter_mut() and will not move the Vec
|
||||
--> $DIR/into_iter_on_ref.rs:31:38
|
||||
--> $DIR/into_iter_on_ref.rs:28:38
|
||||
|
|
||||
LL | let _ = (&mut Vec::<i32>::new()).into_iter(); //~ WARN equivalent to .iter_mut()
|
||||
| ^^^^^^^^^ help: call directly: `iter_mut`
|
||||
|
||||
error: this .into_iter() call is equivalent to .iter() and will not move the BTreeMap
|
||||
--> $DIR/into_iter_on_ref.rs:32:44
|
||||
--> $DIR/into_iter_on_ref.rs:29:44
|
||||
|
|
||||
LL | let _ = (&BTreeMap::<i32, u64>::new()).into_iter(); //~ WARN equivalent to .iter()
|
||||
| ^^^^^^^^^ help: call directly: `iter`
|
||||
|
||||
error: this .into_iter() call is equivalent to .iter_mut() and will not move the BTreeMap
|
||||
--> $DIR/into_iter_on_ref.rs:33:48
|
||||
--> $DIR/into_iter_on_ref.rs:30:48
|
||||
|
|
||||
LL | let _ = (&mut BTreeMap::<i32, u64>::new()).into_iter(); //~ WARN equivalent to .iter_mut()
|
||||
| ^^^^^^^^^ help: call directly: `iter_mut`
|
||||
|
||||
error: this .into_iter() call is equivalent to .iter() and will not move the VecDeque
|
||||
--> $DIR/into_iter_on_ref.rs:34:39
|
||||
--> $DIR/into_iter_on_ref.rs:31:39
|
||||
|
|
||||
LL | let _ = (&VecDeque::<i32>::new()).into_iter(); //~ WARN equivalent to .iter()
|
||||
| ^^^^^^^^^ help: call directly: `iter`
|
||||
|
||||
error: this .into_iter() call is equivalent to .iter_mut() and will not move the VecDeque
|
||||
--> $DIR/into_iter_on_ref.rs:35:43
|
||||
--> $DIR/into_iter_on_ref.rs:32:43
|
||||
|
|
||||
LL | let _ = (&mut VecDeque::<i32>::new()).into_iter(); //~ WARN equivalent to .iter_mut()
|
||||
| ^^^^^^^^^ help: call directly: `iter_mut`
|
||||
|
||||
error: this .into_iter() call is equivalent to .iter() and will not move the LinkedList
|
||||
--> $DIR/into_iter_on_ref.rs:36:41
|
||||
--> $DIR/into_iter_on_ref.rs:33:41
|
||||
|
|
||||
LL | let _ = (&LinkedList::<i32>::new()).into_iter(); //~ WARN equivalent to .iter()
|
||||
| ^^^^^^^^^ help: call directly: `iter`
|
||||
|
||||
error: this .into_iter() call is equivalent to .iter_mut() and will not move the LinkedList
|
||||
--> $DIR/into_iter_on_ref.rs:37:45
|
||||
--> $DIR/into_iter_on_ref.rs:34:45
|
||||
|
|
||||
LL | let _ = (&mut LinkedList::<i32>::new()).into_iter(); //~ WARN equivalent to .iter_mut()
|
||||
| ^^^^^^^^^ help: call directly: `iter_mut`
|
||||
|
||||
error: this .into_iter() call is equivalent to .iter() and will not move the HashMap
|
||||
--> $DIR/into_iter_on_ref.rs:38:43
|
||||
--> $DIR/into_iter_on_ref.rs:35:43
|
||||
|
|
||||
LL | let _ = (&HashMap::<i32, u64>::new()).into_iter(); //~ WARN equivalent to .iter()
|
||||
| ^^^^^^^^^ help: call directly: `iter`
|
||||
|
||||
error: this .into_iter() call is equivalent to .iter_mut() and will not move the HashMap
|
||||
--> $DIR/into_iter_on_ref.rs:39:47
|
||||
--> $DIR/into_iter_on_ref.rs:36:47
|
||||
|
|
||||
LL | let _ = (&mut HashMap::<i32, u64>::new()).into_iter(); //~ WARN equivalent to .iter_mut()
|
||||
| ^^^^^^^^^ help: call directly: `iter_mut`
|
||||
|
||||
error: this .into_iter() call is equivalent to .iter() and will not move the BTreeSet
|
||||
--> $DIR/into_iter_on_ref.rs:41:39
|
||||
--> $DIR/into_iter_on_ref.rs:38:39
|
||||
|
|
||||
LL | let _ = (&BTreeSet::<i32>::new()).into_iter(); //~ WARN equivalent to .iter()
|
||||
| ^^^^^^^^^ help: call directly: `iter`
|
||||
|
||||
error: this .into_iter() call is equivalent to .iter() and will not move the BinaryHeap
|
||||
--> $DIR/into_iter_on_ref.rs:42:41
|
||||
--> $DIR/into_iter_on_ref.rs:39:41
|
||||
|
|
||||
LL | let _ = (&BinaryHeap::<i32>::new()).into_iter(); //~ WARN equivalent to .iter()
|
||||
| ^^^^^^^^^ help: call directly: `iter`
|
||||
|
||||
error: this .into_iter() call is equivalent to .iter() and will not move the HashSet
|
||||
--> $DIR/into_iter_on_ref.rs:43:38
|
||||
--> $DIR/into_iter_on_ref.rs:40:38
|
||||
|
|
||||
LL | let _ = (&HashSet::<i32>::new()).into_iter(); //~ WARN equivalent to .iter()
|
||||
| ^^^^^^^^^ help: call directly: `iter`
|
||||
|
||||
error: this .into_iter() call is equivalent to .iter() and will not move the Path
|
||||
--> $DIR/into_iter_on_ref.rs:44:43
|
||||
--> $DIR/into_iter_on_ref.rs:41:43
|
||||
|
|
||||
LL | let _ = std::path::Path::new("12/34").into_iter(); //~ WARN equivalent to .iter()
|
||||
| ^^^^^^^^^ help: call directly: `iter`
|
||||
|
||||
error: this .into_iter() call is equivalent to .iter() and will not move the PathBuf
|
||||
--> $DIR/into_iter_on_ref.rs:45:47
|
||||
--> $DIR/into_iter_on_ref.rs:42:47
|
||||
|
|
||||
LL | let _ = std::path::PathBuf::from("12/34").into_iter(); //~ ERROR equivalent to .iter()
|
||||
| ^^^^^^^^^ help: call directly: `iter`
|
||||
|
||||
error: aborting due to 28 previous errors
|
||||
error: aborting due to 26 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -5,25 +5,25 @@
|
|||
extern crate rustc;
|
||||
use rustc::lint::{LintArray, LintPass};
|
||||
|
||||
#[macro_use]
|
||||
extern crate clippy_lints;
|
||||
|
||||
declare_clippy_lint! {
|
||||
pub TEST_LINT,
|
||||
correctness,
|
||||
""
|
||||
declare_tool_lint! {
|
||||
pub clippy::TEST_LINT,
|
||||
Warn,
|
||||
"",
|
||||
report_in_external_macro: true
|
||||
}
|
||||
|
||||
declare_clippy_lint! {
|
||||
pub TEST_LINT_REGISTERED,
|
||||
correctness,
|
||||
""
|
||||
declare_tool_lint! {
|
||||
pub clippy::TEST_LINT_REGISTERED,
|
||||
Warn,
|
||||
"",
|
||||
report_in_external_macro: true
|
||||
}
|
||||
|
||||
declare_clippy_lint! {
|
||||
pub TEST_LINT_REGISTERED_ONLY_IMPL,
|
||||
correctness,
|
||||
""
|
||||
declare_tool_lint! {
|
||||
pub clippy::TEST_LINT_REGISTERED_ONLY_IMPL,
|
||||
Warn,
|
||||
"",
|
||||
report_in_external_macro: true
|
||||
}
|
||||
|
||||
pub struct Pass;
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
error: the lint `TEST_LINT` is not added to any `LintPass`
|
||||
--> $DIR/lint_without_lint_pass.rs:11:1
|
||||
--> $DIR/lint_without_lint_pass.rs:8:1
|
||||
|
|
||||
LL | / declare_clippy_lint! {
|
||||
LL | | pub TEST_LINT,
|
||||
LL | | correctness,
|
||||
LL | | ""
|
||||
LL | / declare_tool_lint! {
|
||||
LL | | pub clippy::TEST_LINT,
|
||||
LL | | Warn,
|
||||
LL | | "",
|
||||
LL | | report_in_external_macro: true
|
||||
LL | | }
|
||||
| |_^
|
||||
|
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
use std::borrow::Borrow;
|
||||
use std::collections::HashSet;
|
||||
use std::convert::AsRef;
|
||||
use std::mem::MaybeUninit;
|
||||
|
||||
// `v` should be warned
|
||||
// `w`, `x` and `y` are allowed (moved or mutated)
|
||||
|
|
@ -111,8 +112,8 @@ trait FalsePositive {
|
|||
}
|
||||
|
||||
// shouldn't warn on extern funcs
|
||||
extern "C" fn ext(x: String) -> usize {
|
||||
x.len()
|
||||
extern "C" fn ext(x: MaybeUninit<usize>) -> usize {
|
||||
unsafe { x.assume_init() }
|
||||
}
|
||||
|
||||
// whitelist RangeArgument
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: this argument is passed by value, but not consumed in the function body
|
||||
--> $DIR/needless_pass_by_value.rs:17:23
|
||||
--> $DIR/needless_pass_by_value.rs:18:23
|
||||
|
|
||||
LL | fn foo<T: Default>(v: Vec<T>, w: Vec<T>, mut x: Vec<T>, y: Vec<T>) -> Vec<T> {
|
||||
| ^^^^^^ help: consider changing the type to: `&[T]`
|
||||
|
|
@ -7,55 +7,55 @@ LL | fn foo<T: Default>(v: Vec<T>, w: Vec<T>, mut x: Vec<T>, y: Vec<T>) -> Vec<T
|
|||
= note: `-D clippy::needless-pass-by-value` implied by `-D warnings`
|
||||
|
||||
error: this argument is passed by value, but not consumed in the function body
|
||||
--> $DIR/needless_pass_by_value.rs:31:11
|
||||
--> $DIR/needless_pass_by_value.rs:32:11
|
||||
|
|
||||
LL | fn bar(x: String, y: Wrapper) {
|
||||
| ^^^^^^ help: consider changing the type to: `&str`
|
||||
|
||||
error: this argument is passed by value, but not consumed in the function body
|
||||
--> $DIR/needless_pass_by_value.rs:31:22
|
||||
--> $DIR/needless_pass_by_value.rs:32:22
|
||||
|
|
||||
LL | fn bar(x: String, y: Wrapper) {
|
||||
| ^^^^^^^ help: consider taking a reference instead: `&Wrapper`
|
||||
|
||||
error: this argument is passed by value, but not consumed in the function body
|
||||
--> $DIR/needless_pass_by_value.rs:37:71
|
||||
--> $DIR/needless_pass_by_value.rs:38:71
|
||||
|
|
||||
LL | fn test_borrow_trait<T: Borrow<str>, U: AsRef<str>, V>(t: T, u: U, v: V) {
|
||||
| ^ help: consider taking a reference instead: `&V`
|
||||
|
||||
error: this argument is passed by value, but not consumed in the function body
|
||||
--> $DIR/needless_pass_by_value.rs:49:18
|
||||
--> $DIR/needless_pass_by_value.rs:50:18
|
||||
|
|
||||
LL | fn test_match(x: Option<Option<String>>, y: Option<Option<String>>) {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ help: consider taking a reference instead: `&Option<Option<String>>`
|
||||
|
||||
error: this argument is passed by value, but not consumed in the function body
|
||||
--> $DIR/needless_pass_by_value.rs:62:24
|
||||
--> $DIR/needless_pass_by_value.rs:63:24
|
||||
|
|
||||
LL | fn test_destructure(x: Wrapper, y: Wrapper, z: Wrapper) {
|
||||
| ^^^^^^^ help: consider taking a reference instead: `&Wrapper`
|
||||
|
||||
error: this argument is passed by value, but not consumed in the function body
|
||||
--> $DIR/needless_pass_by_value.rs:62:36
|
||||
--> $DIR/needless_pass_by_value.rs:63:36
|
||||
|
|
||||
LL | fn test_destructure(x: Wrapper, y: Wrapper, z: Wrapper) {
|
||||
| ^^^^^^^ help: consider taking a reference instead: `&Wrapper`
|
||||
|
||||
error: this argument is passed by value, but not consumed in the function body
|
||||
--> $DIR/needless_pass_by_value.rs:78:49
|
||||
--> $DIR/needless_pass_by_value.rs:79:49
|
||||
|
|
||||
LL | fn test_blanket_ref<T: Foo, S: Serialize>(_foo: T, _serializable: S) {}
|
||||
| ^ help: consider taking a reference instead: `&T`
|
||||
|
||||
error: this argument is passed by value, but not consumed in the function body
|
||||
--> $DIR/needless_pass_by_value.rs:80:18
|
||||
--> $DIR/needless_pass_by_value.rs:81:18
|
||||
|
|
||||
LL | fn issue_2114(s: String, t: String, u: Vec<i32>, v: Vec<i32>) {
|
||||
| ^^^^^^ help: consider taking a reference instead: `&String`
|
||||
|
||||
error: this argument is passed by value, but not consumed in the function body
|
||||
--> $DIR/needless_pass_by_value.rs:80:29
|
||||
--> $DIR/needless_pass_by_value.rs:81:29
|
||||
|
|
||||
LL | fn issue_2114(s: String, t: String, u: Vec<i32>, v: Vec<i32>) {
|
||||
| ^^^^^^
|
||||
|
|
@ -70,13 +70,13 @@ LL | let _ = t.to_string();
|
|||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: this argument is passed by value, but not consumed in the function body
|
||||
--> $DIR/needless_pass_by_value.rs:80:40
|
||||
--> $DIR/needless_pass_by_value.rs:81:40
|
||||
|
|
||||
LL | fn issue_2114(s: String, t: String, u: Vec<i32>, v: Vec<i32>) {
|
||||
| ^^^^^^^^ help: consider taking a reference instead: `&Vec<i32>`
|
||||
|
||||
error: this argument is passed by value, but not consumed in the function body
|
||||
--> $DIR/needless_pass_by_value.rs:80:53
|
||||
--> $DIR/needless_pass_by_value.rs:81:53
|
||||
|
|
||||
LL | fn issue_2114(s: String, t: String, u: Vec<i32>, v: Vec<i32>) {
|
||||
| ^^^^^^^^
|
||||
|
|
@ -91,85 +91,85 @@ LL | let _ = v.to_owned();
|
|||
| ^^^^^^^^^^^^
|
||||
|
||||
error: this argument is passed by value, but not consumed in the function body
|
||||
--> $DIR/needless_pass_by_value.rs:93:12
|
||||
--> $DIR/needless_pass_by_value.rs:94:12
|
||||
|
|
||||
LL | s: String,
|
||||
| ^^^^^^ help: consider changing the type to: `&str`
|
||||
|
||||
error: this argument is passed by value, but not consumed in the function body
|
||||
--> $DIR/needless_pass_by_value.rs:94:12
|
||||
--> $DIR/needless_pass_by_value.rs:95:12
|
||||
|
|
||||
LL | t: String,
|
||||
| ^^^^^^ help: consider taking a reference instead: `&String`
|
||||
|
||||
error: this argument is passed by value, but not consumed in the function body
|
||||
--> $DIR/needless_pass_by_value.rs:103:23
|
||||
--> $DIR/needless_pass_by_value.rs:104:23
|
||||
|
|
||||
LL | fn baz(&self, _u: U, _s: Self) {}
|
||||
| ^ help: consider taking a reference instead: `&U`
|
||||
|
||||
error: this argument is passed by value, but not consumed in the function body
|
||||
--> $DIR/needless_pass_by_value.rs:103:30
|
||||
--> $DIR/needless_pass_by_value.rs:104:30
|
||||
|
|
||||
LL | fn baz(&self, _u: U, _s: Self) {}
|
||||
| ^^^^ help: consider taking a reference instead: `&Self`
|
||||
|
||||
error: this argument is passed by value, but not consumed in the function body
|
||||
--> $DIR/needless_pass_by_value.rs:125:24
|
||||
--> $DIR/needless_pass_by_value.rs:126:24
|
||||
|
|
||||
LL | fn bar_copy(x: u32, y: CopyWrapper) {
|
||||
| ^^^^^^^^^^^ help: consider taking a reference instead: `&CopyWrapper`
|
||||
|
|
||||
help: consider marking this type as Copy
|
||||
--> $DIR/needless_pass_by_value.rs:123:1
|
||||
--> $DIR/needless_pass_by_value.rs:124:1
|
||||
|
|
||||
LL | struct CopyWrapper(u32);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: this argument is passed by value, but not consumed in the function body
|
||||
--> $DIR/needless_pass_by_value.rs:131:29
|
||||
--> $DIR/needless_pass_by_value.rs:132:29
|
||||
|
|
||||
LL | fn test_destructure_copy(x: CopyWrapper, y: CopyWrapper, z: CopyWrapper) {
|
||||
| ^^^^^^^^^^^ help: consider taking a reference instead: `&CopyWrapper`
|
||||
|
|
||||
help: consider marking this type as Copy
|
||||
--> $DIR/needless_pass_by_value.rs:123:1
|
||||
--> $DIR/needless_pass_by_value.rs:124:1
|
||||
|
|
||||
LL | struct CopyWrapper(u32);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: this argument is passed by value, but not consumed in the function body
|
||||
--> $DIR/needless_pass_by_value.rs:131:45
|
||||
--> $DIR/needless_pass_by_value.rs:132:45
|
||||
|
|
||||
LL | fn test_destructure_copy(x: CopyWrapper, y: CopyWrapper, z: CopyWrapper) {
|
||||
| ^^^^^^^^^^^ help: consider taking a reference instead: `&CopyWrapper`
|
||||
|
|
||||
help: consider marking this type as Copy
|
||||
--> $DIR/needless_pass_by_value.rs:123:1
|
||||
--> $DIR/needless_pass_by_value.rs:124:1
|
||||
|
|
||||
LL | struct CopyWrapper(u32);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: this argument is passed by value, but not consumed in the function body
|
||||
--> $DIR/needless_pass_by_value.rs:131:61
|
||||
--> $DIR/needless_pass_by_value.rs:132:61
|
||||
|
|
||||
LL | fn test_destructure_copy(x: CopyWrapper, y: CopyWrapper, z: CopyWrapper) {
|
||||
| ^^^^^^^^^^^ help: consider taking a reference instead: `&CopyWrapper`
|
||||
|
|
||||
help: consider marking this type as Copy
|
||||
--> $DIR/needless_pass_by_value.rs:123:1
|
||||
--> $DIR/needless_pass_by_value.rs:124:1
|
||||
|
|
||||
LL | struct CopyWrapper(u32);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: this argument is passed by value, but not consumed in the function body
|
||||
--> $DIR/needless_pass_by_value.rs:143:40
|
||||
--> $DIR/needless_pass_by_value.rs:144:40
|
||||
|
|
||||
LL | fn some_fun<'b, S: Bar<'b, ()>>(_item: S) {}
|
||||
| ^ help: consider taking a reference instead: `&S`
|
||||
|
||||
error: this argument is passed by value, but not consumed in the function body
|
||||
--> $DIR/needless_pass_by_value.rs:148:20
|
||||
--> $DIR/needless_pass_by_value.rs:149:20
|
||||
|
|
||||
LL | fn more_fun(_item: impl Club<'static, i32>) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ help: consider taking a reference instead: `&impl Club<'static, i32>`
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
// aux-build:proc_macro_derive.rs
|
||||
|
||||
#![feature(rustc_private)]
|
||||
#![warn(clippy::all)]
|
||||
#![allow(clippy::blacklisted_name)]
|
||||
#![warn(clippy::used_underscore_binding)]
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: used binding `_foo` which is prefixed with an underscore. A leading underscore signals that a binding will not be used.
|
||||
--> $DIR/used_underscore_binding.rs:24:5
|
||||
--> $DIR/used_underscore_binding.rs:25:5
|
||||
|
|
||||
LL | _foo + 1
|
||||
| ^^^^
|
||||
|
|
@ -7,25 +7,25 @@ LL | _foo + 1
|
|||
= note: `-D clippy::used-underscore-binding` implied by `-D warnings`
|
||||
|
||||
error: used binding `_foo` which is prefixed with an underscore. A leading underscore signals that a binding will not be used.
|
||||
--> $DIR/used_underscore_binding.rs:29:20
|
||||
--> $DIR/used_underscore_binding.rs:30:20
|
||||
|
|
||||
LL | println!("{}", _foo);
|
||||
| ^^^^
|
||||
|
||||
error: used binding `_foo` which is prefixed with an underscore. A leading underscore signals that a binding will not be used.
|
||||
--> $DIR/used_underscore_binding.rs:30:16
|
||||
--> $DIR/used_underscore_binding.rs:31:16
|
||||
|
|
||||
LL | assert_eq!(_foo, _foo);
|
||||
| ^^^^
|
||||
|
||||
error: used binding `_foo` which is prefixed with an underscore. A leading underscore signals that a binding will not be used.
|
||||
--> $DIR/used_underscore_binding.rs:30:22
|
||||
--> $DIR/used_underscore_binding.rs:31:22
|
||||
|
|
||||
LL | assert_eq!(_foo, _foo);
|
||||
| ^^^^
|
||||
|
||||
error: used binding `_underscore_field` which is prefixed with an underscore. A leading underscore signals that a binding will not be used.
|
||||
--> $DIR/used_underscore_binding.rs:43:5
|
||||
--> $DIR/used_underscore_binding.rs:44:5
|
||||
|
|
||||
LL | s._underscore_field += 1;
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
|
|
|||
|
|
@ -2,16 +2,15 @@
|
|||
|
||||
#![warn(clippy::useless_attribute)]
|
||||
#![warn(unreachable_pub)]
|
||||
#![feature(rustc_private)]
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[cfg_attr(feature = "cargo-clippy", allow(dead_code))]
|
||||
#[rustfmt::skip]
|
||||
#[cfg_attr(feature = "cargo-clippy",
|
||||
allow(dead_code))]
|
||||
#[allow(unused_imports)]
|
||||
#[allow(unused_extern_crates)]
|
||||
#[macro_use]
|
||||
extern crate clippy_lints;
|
||||
extern crate rustc;
|
||||
|
||||
#[macro_use]
|
||||
extern crate proc_macro_derive;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: useless lint attribute
|
||||
--> $DIR/useless_attribute.rs:6:1
|
||||
--> $DIR/useless_attribute.rs:7:1
|
||||
|
|
||||
LL | #[allow(dead_code)]
|
||||
| ^^^^^^^^^^^^^^^^^^^ help: if you just forgot a `!`, use: `#![allow(dead_code)]`
|
||||
|
|
@ -7,7 +7,7 @@ LL | #[allow(dead_code)]
|
|||
= note: `-D clippy::useless-attribute` implied by `-D warnings`
|
||||
|
||||
error: useless lint attribute
|
||||
--> $DIR/useless_attribute.rs:7:1
|
||||
--> $DIR/useless_attribute.rs:8:1
|
||||
|
|
||||
LL | #[cfg_attr(feature = "cargo-clippy", allow(dead_code))]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: if you just forgot a `!`, use: `#![cfg_attr(feature = "cargo-clippy", allow(dead_code)`
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue