Skip to content

Commit 811d73a

Browse files
committed
Test #[expect] for redundant_clone
1 parent e7c55a4 commit 811d73a

File tree

3 files changed

+40
-30
lines changed

3 files changed

+40
-30
lines changed

tests/ui/redundant_clone.fixed

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// run-rustfix
22
// rustfix-only-machine-applicable
33

4+
#![feature(lint_reasons)]
45
#![allow(clippy::implicit_clone, clippy::drop_non_drop)]
56
use std::ffi::OsString;
67
use std::path::Path;
@@ -29,6 +30,10 @@ fn main() {
2930
#[allow(clippy::redundant_clone)]
3031
let _s = String::new().to_string();
3132

33+
// Check that lint level works
34+
#[expect(clippy::redundant_clone)]
35+
let _s = String::new().to_string();
36+
3237
let tup = (String::from("foo"),);
3338
let _t = tup.0;
3439

tests/ui/redundant_clone.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// run-rustfix
22
// rustfix-only-machine-applicable
33

4+
#![feature(lint_reasons)]
45
#![allow(clippy::implicit_clone, clippy::drop_non_drop)]
56
use std::ffi::OsString;
67
use std::path::Path;
@@ -29,6 +30,10 @@ fn main() {
2930
#[allow(clippy::redundant_clone)]
3031
let _s = String::new().to_string();
3132

33+
// Check that lint level works
34+
#[expect(clippy::redundant_clone)]
35+
let _s = String::new().to_string();
36+
3237
let tup = (String::from("foo"),);
3338
let _t = tup.0.clone();
3439

tests/ui/redundant_clone.stderr

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

1414
error: redundant clone
15-
--> $DIR/redundant_clone.rs:12:15
15+
--> $DIR/redundant_clone.rs:13: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:12:14
21+
--> $DIR/redundant_clone.rs:13:14
2222
|
2323
LL | let _s = s.clone();
2424
| ^
2525

2626
error: redundant clone
27-
--> $DIR/redundant_clone.rs:15:15
27+
--> $DIR/redundant_clone.rs:16: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:15:14
33+
--> $DIR/redundant_clone.rs:16:14
3434
|
3535
LL | let _s = s.to_string();
3636
| ^
3737

3838
error: redundant clone
39-
--> $DIR/redundant_clone.rs:18:15
39+
--> $DIR/redundant_clone.rs:19: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:18:14
45+
--> $DIR/redundant_clone.rs:19:14
4646
|
4747
LL | let _s = s.to_owned();
4848
| ^
4949

5050
error: redundant clone
51-
--> $DIR/redundant_clone.rs:20:42
51+
--> $DIR/redundant_clone.rs:21: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:20:14
57+
--> $DIR/redundant_clone.rs:21: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:22:42
63+
--> $DIR/redundant_clone.rs:23: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:22:14
69+
--> $DIR/redundant_clone.rs:23: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:24:29
75+
--> $DIR/redundant_clone.rs:25: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:24:14
81+
--> $DIR/redundant_clone.rs:25:14
8282
|
8383
LL | let _s = OsString::new().to_owned();
8484
| ^^^^^^^^^^^^^^^
8585

8686
error: redundant clone
87-
--> $DIR/redundant_clone.rs:26:29
87+
--> $DIR/redundant_clone.rs:27: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:26:14
93+
--> $DIR/redundant_clone.rs:27:14
9494
|
9595
LL | let _s = OsString::new().to_os_string();
9696
| ^^^^^^^^^^^^^^^
9797

9898
error: redundant clone
99-
--> $DIR/redundant_clone.rs:33:19
99+
--> $DIR/redundant_clone.rs:38: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:33:14
105+
--> $DIR/redundant_clone.rs:38:14
106106
|
107107
LL | let _t = tup.0.clone();
108108
| ^^^^^
109109

110110
error: redundant clone
111-
--> $DIR/redundant_clone.rs:65:25
111+
--> $DIR/redundant_clone.rs:70: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:65:24
117+
--> $DIR/redundant_clone.rs:70:24
118118
|
119119
LL | if b { (a.clone(), a.clone()) } else { (Alpha, a) }
120120
| ^
121121

122122
error: redundant clone
123-
--> $DIR/redundant_clone.rs:122:15
123+
--> $DIR/redundant_clone.rs:127: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:122:14
129+
--> $DIR/redundant_clone.rs:127:14
130130
|
131131
LL | let _s = s.clone();
132132
| ^
133133

134134
error: redundant clone
135-
--> $DIR/redundant_clone.rs:123:15
135+
--> $DIR/redundant_clone.rs:128: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:123:14
141+
--> $DIR/redundant_clone.rs:128:14
142142
|
143143
LL | let _t = t.clone();
144144
| ^
145145

146146
error: redundant clone
147-
--> $DIR/redundant_clone.rs:133:19
147+
--> $DIR/redundant_clone.rs:138: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:133:18
153+
--> $DIR/redundant_clone.rs:138:18
154154
|
155155
LL | let _f = f.clone();
156156
| ^
157157

158158
error: redundant clone
159-
--> $DIR/redundant_clone.rs:145:14
159+
--> $DIR/redundant_clone.rs:150: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:145:13
165+
--> $DIR/redundant_clone.rs:150:13
166166
|
167167
LL | let y = x.clone().join("matthias");
168168
| ^^^^^^^^^
169169

170170
error: redundant clone
171-
--> $DIR/redundant_clone.rs:199:11
171+
--> $DIR/redundant_clone.rs:204: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:199:10
177+
--> $DIR/redundant_clone.rs:204:10
178178
|
179179
LL | foo(&x.clone(), move || {
180180
| ^

0 commit comments

Comments
 (0)