diff --git a/clippy_dev/src/fmt.rs b/clippy_dev/src/fmt.rs index 9f0b68baf9db..69cd046a855e 100644 --- a/clippy_dev/src/fmt.rs +++ b/clippy_dev/src/fmt.rs @@ -100,10 +100,7 @@ pub fn run(check: bool, verbose: bool) { } fn format_command(program: impl AsRef, dir: impl AsRef, args: &[impl AsRef]) -> String { - let arg_display: Vec<_> = args - .iter() - .map(|a| escape(a.as_ref().to_string_lossy()).to_owned()) - .collect(); + let arg_display: Vec<_> = args.iter().map(|a| escape(a.as_ref().to_string_lossy())).collect(); format!( "cd {} && {} {}", diff --git a/tests/compile-test.rs b/tests/compile-test.rs index e0b1ebf4b8b8..e65a4a9a40ac 100644 --- a/tests/compile-test.rs +++ b/tests/compile-test.rs @@ -38,8 +38,7 @@ fn config(mode: &str, dir: PathBuf) -> compiletest::Config { let cfg_mode = mode.parse().expect("Invalid mode"); if let Ok(name) = var::<&str>("TESTNAME") { - let s: String = name.to_owned(); - config.filter = Some(s) + config.filter = Some(name) } if rustc_test_suite().is_some() { diff --git a/tests/ui/crashes/auxiliary/proc_macro_crash.rs b/tests/ui/crashes/auxiliary/proc_macro_crash.rs index 71b10ed4db4d..086548e58ed6 100644 --- a/tests/ui/crashes/auxiliary/proc_macro_crash.rs +++ b/tests/ui/crashes/auxiliary/proc_macro_crash.rs @@ -30,7 +30,7 @@ pub fn macro_test(input_stream: TokenStream) -> TokenStream { TokenTree::Ident(Ident::new("true", Span::call_site())), TokenTree::Group(clause.clone()), TokenTree::Ident(Ident::new("else", Span::call_site())), - TokenTree::Group(clause.clone()), + TokenTree::Group(clause), ]) })), ]) diff --git a/tests/ui/escape_analysis.rs b/tests/ui/escape_analysis.rs index 78d332c7a31c..d435484d3e3d 100644 --- a/tests/ui/escape_analysis.rs +++ b/tests/ui/escape_analysis.rs @@ -1,5 +1,10 @@ #![feature(box_syntax)] -#![allow(clippy::borrowed_box, clippy::needless_pass_by_value, clippy::unused_unit)] +#![allow( + clippy::borrowed_box, + clippy::needless_pass_by_value, + clippy::unused_unit, + clippy::redundant_clone +)] #![warn(clippy::boxed_local)] #[derive(Clone)] diff --git a/tests/ui/escape_analysis.stderr b/tests/ui/escape_analysis.stderr index 3944acd87f28..73fa9bfe19b5 100644 --- a/tests/ui/escape_analysis.stderr +++ b/tests/ui/escape_analysis.stderr @@ -1,5 +1,5 @@ error: local variable doesn't need to be boxed here - --> $DIR/escape_analysis.rs:34:13 + --> $DIR/escape_analysis.rs:39:13 | LL | fn warn_arg(x: Box) { | ^ @@ -7,13 +7,13 @@ LL | fn warn_arg(x: Box) { = note: `-D clippy::boxed-local` implied by `-D warnings` error: local variable doesn't need to be boxed here - --> $DIR/escape_analysis.rs:125:12 + --> $DIR/escape_analysis.rs:130:12 | LL | pub fn new(_needs_name: Box>) -> () {} | ^^^^^^^^^^^ error: local variable doesn't need to be boxed here - --> $DIR/escape_analysis.rs:165:23 + --> $DIR/escape_analysis.rs:170:23 | LL | fn closure_borrow(x: Box) { | ^ diff --git a/tests/ui/map_clone.fixed b/tests/ui/map_clone.fixed index c8b9bc049440..2029c81d0d5a 100644 --- a/tests/ui/map_clone.fixed +++ b/tests/ui/map_clone.fixed @@ -1,7 +1,7 @@ // run-rustfix #![warn(clippy::all, clippy::pedantic)] #![allow(clippy::iter_cloned_collect)] -#![allow(clippy::clone_on_copy)] +#![allow(clippy::clone_on_copy, clippy::redundant_clone)] #![allow(clippy::missing_docs_in_private_items)] #![allow(clippy::redundant_closure_for_method_calls)] diff --git a/tests/ui/map_clone.rs b/tests/ui/map_clone.rs index 5f216823eb4a..495c18f311f5 100644 --- a/tests/ui/map_clone.rs +++ b/tests/ui/map_clone.rs @@ -1,7 +1,7 @@ // run-rustfix #![warn(clippy::all, clippy::pedantic)] #![allow(clippy::iter_cloned_collect)] -#![allow(clippy::clone_on_copy)] +#![allow(clippy::clone_on_copy, clippy::redundant_clone)] #![allow(clippy::missing_docs_in_private_items)] #![allow(clippy::redundant_closure_for_method_calls)] diff --git a/tests/ui/needless_pass_by_value.rs b/tests/ui/needless_pass_by_value.rs index f031dd105c25..ca94daa24e84 100644 --- a/tests/ui/needless_pass_by_value.rs +++ b/tests/ui/needless_pass_by_value.rs @@ -4,7 +4,8 @@ clippy::single_match, clippy::redundant_pattern_matching, clippy::many_single_char_names, - clippy::option_option + clippy::option_option, + clippy::redundant_clone )] use std::borrow::Borrow; diff --git a/tests/ui/needless_pass_by_value.stderr b/tests/ui/needless_pass_by_value.stderr index ad0e6461c22f..5efeea0685c6 100644 --- a/tests/ui/needless_pass_by_value.stderr +++ b/tests/ui/needless_pass_by_value.stderr @@ -1,5 +1,5 @@ error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:16:23 + --> $DIR/needless_pass_by_value.rs:17:23 | LL | fn foo(v: Vec, w: Vec, mut x: Vec, y: Vec) -> Vec { | ^^^^^^ help: consider changing the type to: `&[T]` @@ -7,25 +7,25 @@ LL | fn foo(v: Vec, w: Vec, mut x: Vec, y: Vec) -> Vec $DIR/needless_pass_by_value.rs:30:11 + --> $DIR/needless_pass_by_value.rs:31: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:30:22 + --> $DIR/needless_pass_by_value.rs:31: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:36:71 + --> $DIR/needless_pass_by_value.rs:37:71 | LL | fn test_borrow_trait, U: AsRef, 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:48:18 + --> $DIR/needless_pass_by_value.rs:49:18 | LL | fn test_match(x: Option>, y: Option>) { | ^^^^^^^^^^^^^^^^^^^^^^ @@ -36,13 +36,13 @@ LL | match *x { | error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:61:24 + --> $DIR/needless_pass_by_value.rs:62: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:61:36 + --> $DIR/needless_pass_by_value.rs:62:36 | LL | fn test_destructure(x: Wrapper, y: Wrapper, z: Wrapper) { | ^^^^^^^ @@ -55,19 +55,19 @@ LL | let Wrapper(_) = *y; // still not moved | error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:77:49 + --> $DIR/needless_pass_by_value.rs:78:49 | LL | fn test_blanket_ref(_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:79:18 + --> $DIR/needless_pass_by_value.rs:80:18 | LL | fn issue_2114(s: String, t: String, u: Vec, v: Vec) { | ^^^^^^ 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:79:29 + --> $DIR/needless_pass_by_value.rs:80:29 | LL | fn issue_2114(s: String, t: String, u: Vec, v: Vec) { | ^^^^^^ @@ -81,13 +81,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:79:40 + --> $DIR/needless_pass_by_value.rs:80:40 | LL | fn issue_2114(s: String, t: String, u: Vec, v: Vec) { | ^^^^^^^^ help: consider taking a reference instead: `&Vec` error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:79:53 + --> $DIR/needless_pass_by_value.rs:80:53 | LL | fn issue_2114(s: String, t: String, u: Vec, v: Vec) { | ^^^^^^^^ @@ -101,61 +101,61 @@ 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:92:12 + --> $DIR/needless_pass_by_value.rs:93: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:93:12 + --> $DIR/needless_pass_by_value.rs:94: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:102:23 + --> $DIR/needless_pass_by_value.rs:103: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:102:30 + --> $DIR/needless_pass_by_value.rs:103: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:124:24 + --> $DIR/needless_pass_by_value.rs:125: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:122:1 + --> $DIR/needless_pass_by_value.rs:123: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:130:29 + --> $DIR/needless_pass_by_value.rs:131: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:122:1 + --> $DIR/needless_pass_by_value.rs:123: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:130:45 + --> $DIR/needless_pass_by_value.rs:131:45 | LL | fn test_destructure_copy(x: CopyWrapper, y: CopyWrapper, z: CopyWrapper) { | ^^^^^^^^^^^ | help: consider marking this type as Copy - --> $DIR/needless_pass_by_value.rs:122:1 + --> $DIR/needless_pass_by_value.rs:123:1 | LL | struct CopyWrapper(u32); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -168,13 +168,13 @@ LL | let CopyWrapper(_) = *y; // still not moved | error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:130:61 + --> $DIR/needless_pass_by_value.rs:131:61 | LL | fn test_destructure_copy(x: CopyWrapper, y: CopyWrapper, z: CopyWrapper) { | ^^^^^^^^^^^ | help: consider marking this type as Copy - --> $DIR/needless_pass_by_value.rs:122:1 + --> $DIR/needless_pass_by_value.rs:123:1 | LL | struct CopyWrapper(u32); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -185,13 +185,13 @@ LL | let CopyWrapper(s) = *z; // moved | error: this argument is passed by value, but not consumed in the function body - --> $DIR/needless_pass_by_value.rs:142:40 + --> $DIR/needless_pass_by_value.rs:143: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:147:20 + --> $DIR/needless_pass_by_value.rs:148:20 | LL | fn more_fun(_item: impl Club<'static, i32>) {} | ^^^^^^^^^^^^^^^^^^^^^^^ help: consider taking a reference instead: `&impl Club<'static, i32>` diff --git a/tests/ui/ptr_arg.rs b/tests/ui/ptr_arg.rs index 1ce6081bf940..30f39e9b0639 100644 --- a/tests/ui/ptr_arg.rs +++ b/tests/ui/ptr_arg.rs @@ -1,4 +1,4 @@ -#![allow(unused, clippy::many_single_char_names)] +#![allow(unused, clippy::many_single_char_names, clippy::redundant_clone)] #![warn(clippy::ptr_arg)] use std::borrow::Cow; diff --git a/tests/ui/question_mark.rs b/tests/ui/question_mark.rs index 56ccf1d432fc..57237c52e8c9 100644 --- a/tests/ui/question_mark.rs +++ b/tests/ui/question_mark.rs @@ -104,7 +104,7 @@ fn main() { }; move_struct.ref_func(); move_struct.clone().mov_func_reuse(); - move_struct.clone().mov_func_no_use(); + move_struct.mov_func_no_use(); let so = SeemsOption::Some(45); returns_something_similar_to_option(so); diff --git a/tests/ui/swap.rs b/tests/ui/swap.rs index 093cd7fd04af..b508c1ee0096 100644 --- a/tests/ui/swap.rs +++ b/tests/ui/swap.rs @@ -1,5 +1,11 @@ #![warn(clippy::all)] -#![allow(clippy::blacklisted_name, clippy::no_effect, redundant_semicolon, unused_assignments)] +#![allow( + clippy::blacklisted_name, + clippy::no_effect, + clippy::redundant_clone, + redundant_semicolon, + unused_assignments +)] struct Foo(u32); diff --git a/tests/ui/swap.stderr b/tests/ui/swap.stderr index bda0a0bf38b7..b45187b58050 100644 --- a/tests/ui/swap.stderr +++ b/tests/ui/swap.stderr @@ -1,5 +1,5 @@ error: this looks like you are swapping elements of `foo` manually - --> $DIR/swap.rs:27:5 + --> $DIR/swap.rs:33:5 | LL | / let temp = foo[0]; LL | | foo[0] = foo[1]; @@ -9,7 +9,7 @@ LL | | foo[1] = temp; = note: `-D clippy::manual-swap` implied by `-D warnings` error: this looks like you are swapping elements of `foo` manually - --> $DIR/swap.rs:36:5 + --> $DIR/swap.rs:42:5 | LL | / let temp = foo[0]; LL | | foo[0] = foo[1]; @@ -17,7 +17,7 @@ LL | | foo[1] = temp; | |_________________^ help: try: `foo.swap(0, 1)` error: this looks like you are swapping elements of `foo` manually - --> $DIR/swap.rs:45:5 + --> $DIR/swap.rs:51:5 | LL | / let temp = foo[0]; LL | | foo[0] = foo[1]; @@ -25,7 +25,7 @@ LL | | foo[1] = temp; | |_________________^ help: try: `foo.swap(0, 1)` error: this looks like you are swapping `a` and `b` manually - --> $DIR/swap.rs:65:7 + --> $DIR/swap.rs:71:7 | LL | ; let t = a; | _______^ @@ -36,7 +36,7 @@ LL | | b = t; = note: or maybe you should use `std::mem::replace`? error: this looks like you are swapping `c.0` and `a` manually - --> $DIR/swap.rs:74:7 + --> $DIR/swap.rs:80:7 | LL | ; let t = c.0; | _______^ @@ -47,7 +47,7 @@ LL | | a = t; = note: or maybe you should use `std::mem::replace`? error: this looks like you are trying to swap `a` and `b` - --> $DIR/swap.rs:62:5 + --> $DIR/swap.rs:68:5 | LL | / a = b; LL | | b = a; @@ -57,7 +57,7 @@ LL | | b = a; = note: or maybe you should use `std::mem::replace`? error: this looks like you are trying to swap `c.0` and `a` - --> $DIR/swap.rs:71:5 + --> $DIR/swap.rs:77:5 | LL | / c.0 = a; LL | | a = c.0; diff --git a/tests/ui/unnecessary_clone.rs b/tests/ui/unnecessary_clone.rs index 4ff835115909..6a799411df1a 100644 --- a/tests/ui/unnecessary_clone.rs +++ b/tests/ui/unnecessary_clone.rs @@ -1,5 +1,5 @@ #![warn(clippy::clone_on_ref_ptr)] -#![allow(unused)] +#![allow(unused, clippy::redundant_clone)] use std::cell::RefCell; use std::collections::HashSet;