Skip to content

Commit ae880e4

Browse files
committed
Auto merge of rust-lang#10873 - Alexendoo:redundant-clone-nursery, r=flip1995
Move `redundant_clone` to `nursery` changelog: [`redundant_clone`]: Move to `nursery` A bunch of FPs in `redundant_clone` have sprung up after upstream MIR changes: rust-lang#108944 - rust-lang/rust-clippy#10870 - rust-lang/rust-clippy#10577 - rust-lang/rust-clippy#10545 - rust-lang/rust-clippy#10517 r? `@flip1995`
2 parents 8c0ed28 + e29a681 commit ae880e4

6 files changed

+35
-33
lines changed

clippy_lints/src/redundant_clone.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ declare_clippy_lint! {
5757
/// ```
5858
#[clippy::version = "1.32.0"]
5959
pub REDUNDANT_CLONE,
60-
perf,
60+
nursery,
6161
"`clone()` of an owned value that is going to be dropped immediately"
6262
}
6363

tests/ui/redundant_clone.fixed

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//@run-rustfix
22
// rustfix-only-machine-applicable
33
#![feature(lint_reasons)]
4+
#![warn(clippy::redundant_clone)]
45
#![allow(clippy::drop_non_drop, clippy::implicit_clone, clippy::uninlined_format_args)]
56

67
use std::ffi::OsString;

tests/ui/redundant_clone.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//@run-rustfix
22
// rustfix-only-machine-applicable
33
#![feature(lint_reasons)]
4+
#![warn(clippy::redundant_clone)]
45
#![allow(clippy::drop_non_drop, clippy::implicit_clone, clippy::uninlined_format_args)]
56

67
use std::ffi::OsString;

tests/ui/redundant_clone.stderr

+30-30
Original file line numberDiff line numberDiff line change
@@ -1,180 +1,180 @@
11
error: redundant clone
2-
--> $DIR/redundant_clone.rs:10:42
2+
--> $DIR/redundant_clone.rs:11:42
33
|
44
LL | let _s = ["lorem", "ipsum"].join(" ").to_string();
55
| ^^^^^^^^^^^^ help: remove this
66
|
77
note: this value is dropped without further use
8-
--> $DIR/redundant_clone.rs:10:14
8+
--> $DIR/redundant_clone.rs:11:14
99
|
1010
LL | let _s = ["lorem", "ipsum"].join(" ").to_string();
1111
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1212
= note: `-D clippy::redundant-clone` implied by `-D warnings`
1313

1414
error: redundant clone
15-
--> $DIR/redundant_clone.rs:13:15
15+
--> $DIR/redundant_clone.rs:14:15
1616
|
1717
LL | let _s = s.clone();
1818
| ^^^^^^^^ help: remove this
1919
|
2020
note: this value is dropped without further use
21-
--> $DIR/redundant_clone.rs:13:14
21+
--> $DIR/redundant_clone.rs:14:14
2222
|
2323
LL | let _s = s.clone();
2424
| ^
2525

2626
error: redundant clone
27-
--> $DIR/redundant_clone.rs:16:15
27+
--> $DIR/redundant_clone.rs:17:15
2828
|
2929
LL | let _s = s.to_string();
3030
| ^^^^^^^^^^^^ help: remove this
3131
|
3232
note: this value is dropped without further use
33-
--> $DIR/redundant_clone.rs:16:14
33+
--> $DIR/redundant_clone.rs:17:14
3434
|
3535
LL | let _s = s.to_string();
3636
| ^
3737

3838
error: redundant clone
39-
--> $DIR/redundant_clone.rs:19:15
39+
--> $DIR/redundant_clone.rs:20:15
4040
|
4141
LL | let _s = s.to_owned();
4242
| ^^^^^^^^^^^ help: remove this
4343
|
4444
note: this value is dropped without further use
45-
--> $DIR/redundant_clone.rs:19:14
45+
--> $DIR/redundant_clone.rs:20:14
4646
|
4747
LL | let _s = s.to_owned();
4848
| ^
4949

5050
error: redundant clone
51-
--> $DIR/redundant_clone.rs:21:42
51+
--> $DIR/redundant_clone.rs:22:42
5252
|
5353
LL | let _s = Path::new("/a/b/").join("c").to_owned();
5454
| ^^^^^^^^^^^ help: remove this
5555
|
5656
note: this value is dropped without further use
57-
--> $DIR/redundant_clone.rs:21:14
57+
--> $DIR/redundant_clone.rs:22:14
5858
|
5959
LL | let _s = Path::new("/a/b/").join("c").to_owned();
6060
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6161

6262
error: redundant clone
63-
--> $DIR/redundant_clone.rs:23:42
63+
--> $DIR/redundant_clone.rs:24:42
6464
|
6565
LL | let _s = Path::new("/a/b/").join("c").to_path_buf();
6666
| ^^^^^^^^^^^^^^ help: remove this
6767
|
6868
note: this value is dropped without further use
69-
--> $DIR/redundant_clone.rs:23:14
69+
--> $DIR/redundant_clone.rs:24:14
7070
|
7171
LL | let _s = Path::new("/a/b/").join("c").to_path_buf();
7272
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
7373

7474
error: redundant clone
75-
--> $DIR/redundant_clone.rs:25:29
75+
--> $DIR/redundant_clone.rs:26:29
7676
|
7777
LL | let _s = OsString::new().to_owned();
7878
| ^^^^^^^^^^^ help: remove this
7979
|
8080
note: this value is dropped without further use
81-
--> $DIR/redundant_clone.rs:25:14
81+
--> $DIR/redundant_clone.rs:26:14
8282
|
8383
LL | let _s = OsString::new().to_owned();
8484
| ^^^^^^^^^^^^^^^
8585

8686
error: redundant clone
87-
--> $DIR/redundant_clone.rs:27:29
87+
--> $DIR/redundant_clone.rs:28:29
8888
|
8989
LL | let _s = OsString::new().to_os_string();
9090
| ^^^^^^^^^^^^^^^ help: remove this
9191
|
9292
note: this value is dropped without further use
93-
--> $DIR/redundant_clone.rs:27:14
93+
--> $DIR/redundant_clone.rs:28:14
9494
|
9595
LL | let _s = OsString::new().to_os_string();
9696
| ^^^^^^^^^^^^^^^
9797

9898
error: redundant clone
99-
--> $DIR/redundant_clone.rs:38:19
99+
--> $DIR/redundant_clone.rs:39:19
100100
|
101101
LL | let _t = tup.0.clone();
102102
| ^^^^^^^^ help: remove this
103103
|
104104
note: this value is dropped without further use
105-
--> $DIR/redundant_clone.rs:38:14
105+
--> $DIR/redundant_clone.rs:39:14
106106
|
107107
LL | let _t = tup.0.clone();
108108
| ^^^^^
109109

110110
error: redundant clone
111-
--> $DIR/redundant_clone.rs:70:25
111+
--> $DIR/redundant_clone.rs:71:25
112112
|
113113
LL | if b { (a.clone(), a.clone()) } else { (Alpha, a) }
114114
| ^^^^^^^^ help: remove this
115115
|
116116
note: this value is dropped without further use
117-
--> $DIR/redundant_clone.rs:70:24
117+
--> $DIR/redundant_clone.rs:71:24
118118
|
119119
LL | if b { (a.clone(), a.clone()) } else { (Alpha, a) }
120120
| ^
121121

122122
error: redundant clone
123-
--> $DIR/redundant_clone.rs:127:15
123+
--> $DIR/redundant_clone.rs:128:15
124124
|
125125
LL | let _s = s.clone();
126126
| ^^^^^^^^ help: remove this
127127
|
128128
note: this value is dropped without further use
129-
--> $DIR/redundant_clone.rs:127:14
129+
--> $DIR/redundant_clone.rs:128:14
130130
|
131131
LL | let _s = s.clone();
132132
| ^
133133

134134
error: redundant clone
135-
--> $DIR/redundant_clone.rs:128:15
135+
--> $DIR/redundant_clone.rs:129:15
136136
|
137137
LL | let _t = t.clone();
138138
| ^^^^^^^^ help: remove this
139139
|
140140
note: this value is dropped without further use
141-
--> $DIR/redundant_clone.rs:128:14
141+
--> $DIR/redundant_clone.rs:129:14
142142
|
143143
LL | let _t = t.clone();
144144
| ^
145145

146146
error: redundant clone
147-
--> $DIR/redundant_clone.rs:138:19
147+
--> $DIR/redundant_clone.rs:139:19
148148
|
149149
LL | let _f = f.clone();
150150
| ^^^^^^^^ help: remove this
151151
|
152152
note: this value is dropped without further use
153-
--> $DIR/redundant_clone.rs:138:18
153+
--> $DIR/redundant_clone.rs:139:18
154154
|
155155
LL | let _f = f.clone();
156156
| ^
157157

158158
error: redundant clone
159-
--> $DIR/redundant_clone.rs:150:14
159+
--> $DIR/redundant_clone.rs:151:14
160160
|
161161
LL | let y = x.clone().join("matthias");
162162
| ^^^^^^^^ help: remove this
163163
|
164164
note: cloned value is neither consumed nor mutated
165-
--> $DIR/redundant_clone.rs:150:13
165+
--> $DIR/redundant_clone.rs:151:13
166166
|
167167
LL | let y = x.clone().join("matthias");
168168
| ^^^^^^^^^
169169

170170
error: redundant clone
171-
--> $DIR/redundant_clone.rs:204:11
171+
--> $DIR/redundant_clone.rs:205:11
172172
|
173173
LL | foo(&x.clone(), move || {
174174
| ^^^^^^^^ help: remove this
175175
|
176176
note: this value is dropped without further use
177-
--> $DIR/redundant_clone.rs:204:10
177+
--> $DIR/redundant_clone.rs:205:10
178178
|
179179
LL | foo(&x.clone(), move || {
180180
| ^

tests/ui/unnecessary_to_owned.fixed

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//@run-rustfix
22

33
#![allow(clippy::needless_borrow, clippy::ptr_arg)]
4-
#![warn(clippy::unnecessary_to_owned)]
4+
#![warn(clippy::unnecessary_to_owned, clippy::redundant_clone)]
55

66
use std::borrow::Cow;
77
use std::ffi::{CStr, CString, OsStr, OsString};

tests/ui/unnecessary_to_owned.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//@run-rustfix
22

33
#![allow(clippy::needless_borrow, clippy::ptr_arg)]
4-
#![warn(clippy::unnecessary_to_owned)]
4+
#![warn(clippy::unnecessary_to_owned, clippy::redundant_clone)]
55

66
use std::borrow::Cow;
77
use std::ffi::{CStr, CString, OsStr, OsString};

0 commit comments

Comments
 (0)