Skip to content

Commit 53fe3f9

Browse files
committed
Test fixes
1 parent eaae523 commit 53fe3f9

14 files changed

+59
-51
lines changed

clippy_dev/src/fmt.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,7 @@ pub fn run(check: bool, verbose: bool) {
100100
}
101101

102102
fn format_command(program: impl AsRef<OsStr>, dir: impl AsRef<Path>, args: &[impl AsRef<OsStr>]) -> String {
103-
let arg_display: Vec<_> = args
104-
.iter()
105-
.map(|a| escape(a.as_ref().to_string_lossy()).to_owned())
106-
.collect();
103+
let arg_display: Vec<_> = args.iter().map(|a| escape(a.as_ref().to_string_lossy())).collect();
107104

108105
format!(
109106
"cd {} && {} {}",

tests/compile-test.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ fn config(mode: &str, dir: PathBuf) -> compiletest::Config {
3838

3939
let cfg_mode = mode.parse().expect("Invalid mode");
4040
if let Ok(name) = var::<&str>("TESTNAME") {
41-
let s: String = name.to_owned();
42-
config.filter = Some(s)
41+
config.filter = Some(name)
4342
}
4443

4544
if rustc_test_suite().is_some() {

tests/ui/crashes/auxiliary/proc_macro_crash.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pub fn macro_test(input_stream: TokenStream) -> TokenStream {
3030
TokenTree::Ident(Ident::new("true", Span::call_site())),
3131
TokenTree::Group(clause.clone()),
3232
TokenTree::Ident(Ident::new("else", Span::call_site())),
33-
TokenTree::Group(clause.clone()),
33+
TokenTree::Group(clause),
3434
])
3535
})),
3636
])

tests/ui/escape_analysis.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
#![feature(box_syntax)]
2-
#![allow(clippy::borrowed_box, clippy::needless_pass_by_value, clippy::unused_unit)]
2+
#![allow(
3+
clippy::borrowed_box,
4+
clippy::needless_pass_by_value,
5+
clippy::unused_unit,
6+
clippy::redundant_clone
7+
)]
38
#![warn(clippy::boxed_local)]
49

510
#[derive(Clone)]

tests/ui/escape_analysis.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
error: local variable doesn't need to be boxed here
2-
--> $DIR/escape_analysis.rs:34:13
2+
--> $DIR/escape_analysis.rs:39:13
33
|
44
LL | fn warn_arg(x: Box<A>) {
55
| ^
66
|
77
= note: `-D clippy::boxed-local` implied by `-D warnings`
88

99
error: local variable doesn't need to be boxed here
10-
--> $DIR/escape_analysis.rs:125:12
10+
--> $DIR/escape_analysis.rs:130:12
1111
|
1212
LL | pub fn new(_needs_name: Box<PeekableSeekable<&()>>) -> () {}
1313
| ^^^^^^^^^^^
1414

1515
error: local variable doesn't need to be boxed here
16-
--> $DIR/escape_analysis.rs:165:23
16+
--> $DIR/escape_analysis.rs:170:23
1717
|
1818
LL | fn closure_borrow(x: Box<A>) {
1919
| ^

tests/ui/map_clone.fixed

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// run-rustfix
22
#![warn(clippy::all, clippy::pedantic)]
33
#![allow(clippy::iter_cloned_collect)]
4-
#![allow(clippy::clone_on_copy)]
4+
#![allow(clippy::clone_on_copy, clippy::redundant_clone)]
55
#![allow(clippy::missing_docs_in_private_items)]
66
#![allow(clippy::redundant_closure_for_method_calls)]
77

tests/ui/map_clone.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// run-rustfix
22
#![warn(clippy::all, clippy::pedantic)]
33
#![allow(clippy::iter_cloned_collect)]
4-
#![allow(clippy::clone_on_copy)]
4+
#![allow(clippy::clone_on_copy, clippy::redundant_clone)]
55
#![allow(clippy::missing_docs_in_private_items)]
66
#![allow(clippy::redundant_closure_for_method_calls)]
77

tests/ui/needless_pass_by_value.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
clippy::single_match,
55
clippy::redundant_pattern_matching,
66
clippy::many_single_char_names,
7-
clippy::option_option
7+
clippy::option_option,
8+
clippy::redundant_clone
89
)]
910

1011
use std::borrow::Borrow;

tests/ui/needless_pass_by_value.stderr

+26-26
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
11
error: this argument is passed by value, but not consumed in the function body
2-
--> $DIR/needless_pass_by_value.rs:16:23
2+
--> $DIR/needless_pass_by_value.rs:17:23
33
|
44
LL | fn foo<T: Default>(v: Vec<T>, w: Vec<T>, mut x: Vec<T>, y: Vec<T>) -> Vec<T> {
55
| ^^^^^^ help: consider changing the type to: `&[T]`
66
|
77
= note: `-D clippy::needless-pass-by-value` implied by `-D warnings`
88

99
error: this argument is passed by value, but not consumed in the function body
10-
--> $DIR/needless_pass_by_value.rs:30:11
10+
--> $DIR/needless_pass_by_value.rs:31:11
1111
|
1212
LL | fn bar(x: String, y: Wrapper) {
1313
| ^^^^^^ help: consider changing the type to: `&str`
1414

1515
error: this argument is passed by value, but not consumed in the function body
16-
--> $DIR/needless_pass_by_value.rs:30:22
16+
--> $DIR/needless_pass_by_value.rs:31:22
1717
|
1818
LL | fn bar(x: String, y: Wrapper) {
1919
| ^^^^^^^ help: consider taking a reference instead: `&Wrapper`
2020

2121
error: this argument is passed by value, but not consumed in the function body
22-
--> $DIR/needless_pass_by_value.rs:36:71
22+
--> $DIR/needless_pass_by_value.rs:37:71
2323
|
2424
LL | fn test_borrow_trait<T: Borrow<str>, U: AsRef<str>, V>(t: T, u: U, v: V) {
2525
| ^ help: consider taking a reference instead: `&V`
2626

2727
error: this argument is passed by value, but not consumed in the function body
28-
--> $DIR/needless_pass_by_value.rs:48:18
28+
--> $DIR/needless_pass_by_value.rs:49:18
2929
|
3030
LL | fn test_match(x: Option<Option<String>>, y: Option<Option<String>>) {
3131
| ^^^^^^^^^^^^^^^^^^^^^^
@@ -36,13 +36,13 @@ LL | match *x {
3636
|
3737

3838
error: this argument is passed by value, but not consumed in the function body
39-
--> $DIR/needless_pass_by_value.rs:61:24
39+
--> $DIR/needless_pass_by_value.rs:62:24
4040
|
4141
LL | fn test_destructure(x: Wrapper, y: Wrapper, z: Wrapper) {
4242
| ^^^^^^^ help: consider taking a reference instead: `&Wrapper`
4343

4444
error: this argument is passed by value, but not consumed in the function body
45-
--> $DIR/needless_pass_by_value.rs:61:36
45+
--> $DIR/needless_pass_by_value.rs:62:36
4646
|
4747
LL | fn test_destructure(x: Wrapper, y: Wrapper, z: Wrapper) {
4848
| ^^^^^^^
@@ -55,19 +55,19 @@ LL | let Wrapper(_) = *y; // still not moved
5555
|
5656

5757
error: this argument is passed by value, but not consumed in the function body
58-
--> $DIR/needless_pass_by_value.rs:77:49
58+
--> $DIR/needless_pass_by_value.rs:78:49
5959
|
6060
LL | fn test_blanket_ref<T: Foo, S: Serialize>(_foo: T, _serializable: S) {}
6161
| ^ help: consider taking a reference instead: `&T`
6262

6363
error: this argument is passed by value, but not consumed in the function body
64-
--> $DIR/needless_pass_by_value.rs:79:18
64+
--> $DIR/needless_pass_by_value.rs:80:18
6565
|
6666
LL | fn issue_2114(s: String, t: String, u: Vec<i32>, v: Vec<i32>) {
6767
| ^^^^^^ help: consider taking a reference instead: `&String`
6868

6969
error: this argument is passed by value, but not consumed in the function body
70-
--> $DIR/needless_pass_by_value.rs:79:29
70+
--> $DIR/needless_pass_by_value.rs:80:29
7171
|
7272
LL | fn issue_2114(s: String, t: String, u: Vec<i32>, v: Vec<i32>) {
7373
| ^^^^^^
@@ -81,13 +81,13 @@ LL | let _ = t.to_string();
8181
| ^^^^^^^^^^^^^
8282

8383
error: this argument is passed by value, but not consumed in the function body
84-
--> $DIR/needless_pass_by_value.rs:79:40
84+
--> $DIR/needless_pass_by_value.rs:80:40
8585
|
8686
LL | fn issue_2114(s: String, t: String, u: Vec<i32>, v: Vec<i32>) {
8787
| ^^^^^^^^ help: consider taking a reference instead: `&Vec<i32>`
8888

8989
error: this argument is passed by value, but not consumed in the function body
90-
--> $DIR/needless_pass_by_value.rs:79:53
90+
--> $DIR/needless_pass_by_value.rs:80:53
9191
|
9292
LL | fn issue_2114(s: String, t: String, u: Vec<i32>, v: Vec<i32>) {
9393
| ^^^^^^^^
@@ -101,61 +101,61 @@ LL | let _ = v.to_owned();
101101
| ^^^^^^^^^^^^
102102

103103
error: this argument is passed by value, but not consumed in the function body
104-
--> $DIR/needless_pass_by_value.rs:92:12
104+
--> $DIR/needless_pass_by_value.rs:93:12
105105
|
106106
LL | s: String,
107107
| ^^^^^^ help: consider changing the type to: `&str`
108108

109109
error: this argument is passed by value, but not consumed in the function body
110-
--> $DIR/needless_pass_by_value.rs:93:12
110+
--> $DIR/needless_pass_by_value.rs:94:12
111111
|
112112
LL | t: String,
113113
| ^^^^^^ help: consider taking a reference instead: `&String`
114114

115115
error: this argument is passed by value, but not consumed in the function body
116-
--> $DIR/needless_pass_by_value.rs:102:23
116+
--> $DIR/needless_pass_by_value.rs:103:23
117117
|
118118
LL | fn baz(&self, _u: U, _s: Self) {}
119119
| ^ help: consider taking a reference instead: `&U`
120120

121121
error: this argument is passed by value, but not consumed in the function body
122-
--> $DIR/needless_pass_by_value.rs:102:30
122+
--> $DIR/needless_pass_by_value.rs:103:30
123123
|
124124
LL | fn baz(&self, _u: U, _s: Self) {}
125125
| ^^^^ help: consider taking a reference instead: `&Self`
126126

127127
error: this argument is passed by value, but not consumed in the function body
128-
--> $DIR/needless_pass_by_value.rs:124:24
128+
--> $DIR/needless_pass_by_value.rs:125:24
129129
|
130130
LL | fn bar_copy(x: u32, y: CopyWrapper) {
131131
| ^^^^^^^^^^^ help: consider taking a reference instead: `&CopyWrapper`
132132
|
133133
help: consider marking this type as Copy
134-
--> $DIR/needless_pass_by_value.rs:122:1
134+
--> $DIR/needless_pass_by_value.rs:123:1
135135
|
136136
LL | struct CopyWrapper(u32);
137137
| ^^^^^^^^^^^^^^^^^^^^^^^^
138138

139139
error: this argument is passed by value, but not consumed in the function body
140-
--> $DIR/needless_pass_by_value.rs:130:29
140+
--> $DIR/needless_pass_by_value.rs:131:29
141141
|
142142
LL | fn test_destructure_copy(x: CopyWrapper, y: CopyWrapper, z: CopyWrapper) {
143143
| ^^^^^^^^^^^ help: consider taking a reference instead: `&CopyWrapper`
144144
|
145145
help: consider marking this type as Copy
146-
--> $DIR/needless_pass_by_value.rs:122:1
146+
--> $DIR/needless_pass_by_value.rs:123:1
147147
|
148148
LL | struct CopyWrapper(u32);
149149
| ^^^^^^^^^^^^^^^^^^^^^^^^
150150

151151
error: this argument is passed by value, but not consumed in the function body
152-
--> $DIR/needless_pass_by_value.rs:130:45
152+
--> $DIR/needless_pass_by_value.rs:131:45
153153
|
154154
LL | fn test_destructure_copy(x: CopyWrapper, y: CopyWrapper, z: CopyWrapper) {
155155
| ^^^^^^^^^^^
156156
|
157157
help: consider marking this type as Copy
158-
--> $DIR/needless_pass_by_value.rs:122:1
158+
--> $DIR/needless_pass_by_value.rs:123:1
159159
|
160160
LL | struct CopyWrapper(u32);
161161
| ^^^^^^^^^^^^^^^^^^^^^^^^
@@ -168,13 +168,13 @@ LL | let CopyWrapper(_) = *y; // still not moved
168168
|
169169

170170
error: this argument is passed by value, but not consumed in the function body
171-
--> $DIR/needless_pass_by_value.rs:130:61
171+
--> $DIR/needless_pass_by_value.rs:131:61
172172
|
173173
LL | fn test_destructure_copy(x: CopyWrapper, y: CopyWrapper, z: CopyWrapper) {
174174
| ^^^^^^^^^^^
175175
|
176176
help: consider marking this type as Copy
177-
--> $DIR/needless_pass_by_value.rs:122:1
177+
--> $DIR/needless_pass_by_value.rs:123:1
178178
|
179179
LL | struct CopyWrapper(u32);
180180
| ^^^^^^^^^^^^^^^^^^^^^^^^
@@ -185,13 +185,13 @@ LL | let CopyWrapper(s) = *z; // moved
185185
|
186186

187187
error: this argument is passed by value, but not consumed in the function body
188-
--> $DIR/needless_pass_by_value.rs:142:40
188+
--> $DIR/needless_pass_by_value.rs:143:40
189189
|
190190
LL | fn some_fun<'b, S: Bar<'b, ()>>(_item: S) {}
191191
| ^ help: consider taking a reference instead: `&S`
192192

193193
error: this argument is passed by value, but not consumed in the function body
194-
--> $DIR/needless_pass_by_value.rs:147:20
194+
--> $DIR/needless_pass_by_value.rs:148:20
195195
|
196196
LL | fn more_fun(_item: impl Club<'static, i32>) {}
197197
| ^^^^^^^^^^^^^^^^^^^^^^^ help: consider taking a reference instead: `&impl Club<'static, i32>`

tests/ui/ptr_arg.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![allow(unused, clippy::many_single_char_names)]
1+
#![allow(unused, clippy::many_single_char_names, clippy::redundant_clone)]
22
#![warn(clippy::ptr_arg)]
33

44
use std::borrow::Cow;

tests/ui/question_mark.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ fn main() {
104104
};
105105
move_struct.ref_func();
106106
move_struct.clone().mov_func_reuse();
107-
move_struct.clone().mov_func_no_use();
107+
move_struct.mov_func_no_use();
108108

109109
let so = SeemsOption::Some(45);
110110
returns_something_similar_to_option(so);

tests/ui/swap.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
#![warn(clippy::all)]
2-
#![allow(clippy::blacklisted_name, clippy::no_effect, redundant_semicolon, unused_assignments)]
2+
#![allow(
3+
clippy::blacklisted_name,
4+
clippy::no_effect,
5+
clippy::redundant_clone,
6+
redundant_semicolon,
7+
unused_assignments
8+
)]
39

410
struct Foo(u32);
511

tests/ui/swap.stderr

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: this looks like you are swapping elements of `foo` manually
2-
--> $DIR/swap.rs:27:5
2+
--> $DIR/swap.rs:33:5
33
|
44
LL | / let temp = foo[0];
55
LL | | foo[0] = foo[1];
@@ -9,23 +9,23 @@ LL | | foo[1] = temp;
99
= note: `-D clippy::manual-swap` implied by `-D warnings`
1010

1111
error: this looks like you are swapping elements of `foo` manually
12-
--> $DIR/swap.rs:36:5
12+
--> $DIR/swap.rs:42:5
1313
|
1414
LL | / let temp = foo[0];
1515
LL | | foo[0] = foo[1];
1616
LL | | foo[1] = temp;
1717
| |_________________^ help: try: `foo.swap(0, 1)`
1818

1919
error: this looks like you are swapping elements of `foo` manually
20-
--> $DIR/swap.rs:45:5
20+
--> $DIR/swap.rs:51:5
2121
|
2222
LL | / let temp = foo[0];
2323
LL | | foo[0] = foo[1];
2424
LL | | foo[1] = temp;
2525
| |_________________^ help: try: `foo.swap(0, 1)`
2626

2727
error: this looks like you are swapping `a` and `b` manually
28-
--> $DIR/swap.rs:65:7
28+
--> $DIR/swap.rs:71:7
2929
|
3030
LL | ; let t = a;
3131
| _______^
@@ -36,7 +36,7 @@ LL | | b = t;
3636
= note: or maybe you should use `std::mem::replace`?
3737

3838
error: this looks like you are swapping `c.0` and `a` manually
39-
--> $DIR/swap.rs:74:7
39+
--> $DIR/swap.rs:80:7
4040
|
4141
LL | ; let t = c.0;
4242
| _______^
@@ -47,7 +47,7 @@ LL | | a = t;
4747
= note: or maybe you should use `std::mem::replace`?
4848

4949
error: this looks like you are trying to swap `a` and `b`
50-
--> $DIR/swap.rs:62:5
50+
--> $DIR/swap.rs:68:5
5151
|
5252
LL | / a = b;
5353
LL | | b = a;
@@ -57,7 +57,7 @@ LL | | b = a;
5757
= note: or maybe you should use `std::mem::replace`?
5858

5959
error: this looks like you are trying to swap `c.0` and `a`
60-
--> $DIR/swap.rs:71:5
60+
--> $DIR/swap.rs:77:5
6161
|
6262
LL | / c.0 = a;
6363
LL | | a = c.0;

tests/ui/unnecessary_clone.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![warn(clippy::clone_on_ref_ptr)]
2-
#![allow(unused)]
2+
#![allow(unused, clippy::redundant_clone)]
33

44
use std::cell::RefCell;
55
use std::collections::HashSet;

0 commit comments

Comments
 (0)