Skip to content

Commit 8a919eb

Browse files
committed
fix clippy
1 parent 63c5d38 commit 8a919eb

File tree

6 files changed

+10
-71
lines changed

6 files changed

+10
-71
lines changed

src/tools/clippy/clippy_dev/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ extern crate rustc_lexer;
1212

1313
use std::path::PathBuf;
1414

15-
pub mod bless
15+
pub mod bless;
1616
pub mod dogfood;
1717
pub mod fmt;
1818
pub mod lint;

src/tools/clippy/tests/ui/deprecated.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,5 @@
1818
#![warn(clippy::filter_map)]
1919
#![warn(clippy::pub_enum_variant_names)]
2020
#![warn(clippy::wrong_pub_self_convention)]
21-
#![warn(clippy::clone_double_ref)]
2221

2322
fn main() {}

src/tools/clippy/tests/ui/deprecated.stderr

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,5 @@ error: lint `clippy::wrong_pub_self_convention` has been removed: set the `avoid
9696
LL | #![warn(clippy::wrong_pub_self_convention)]
9797
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
9898

99-
error: lint `clippy::clone_double_ref` has been renamed to `clone_double_ref`
100-
--> $DIR/deprecated.rs:21:9
101-
|
102-
LL | #![warn(clippy::clone_double_ref)]
103-
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clone_double_ref`
104-
105-
error: aborting due to 17 previous errors
99+
error: aborting due to 16 previous errors
106100

src/tools/clippy/tests/ui/unnecessary_clone.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,6 @@ fn clone_on_copy_generic<T: Copy>(t: T) {
4242
Some(t).clone();
4343
}
4444

45-
fn clone_on_double_ref() {
46-
let x = vec![1];
47-
let y = &&x;
48-
let z: &Vec<_> = y.clone();
49-
50-
println!("{:p} {:p}", *y, z);
51-
}
52-
5345
mod many_derefs {
5446
struct A;
5547
struct B;
@@ -84,11 +76,6 @@ mod many_derefs {
8476
let _: E = a.clone();
8577
let _: E = *****a;
8678
}
87-
88-
fn check(mut encoded: &[u8]) {
89-
let _ = &mut encoded.clone();
90-
let _ = &encoded.clone();
91-
}
9279
}
9380

9481
mod issue2076 {

src/tools/clippy/tests/ui/unnecessary_clone.stderr

Lines changed: 3 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -45,62 +45,16 @@ LL | Some(t).clone();
4545
| ^^^^^^^^^^^^^^^ help: try removing the `clone` call: `Some(t)`
4646

4747
error: using `clone` on type `E` which implements the `Copy` trait
48-
--> $DIR/unnecessary_clone.rs:84:20
48+
--> $DIR/unnecessary_clone.rs:76:20
4949
|
5050
LL | let _: E = a.clone();
5151
| ^^^^^^^^^ help: try dereferencing it: `*****a`
5252

5353
error: using `.clone()` on a ref-counted pointer
54-
--> $DIR/unnecessary_clone.rs:108:14
54+
--> $DIR/unnecessary_clone.rs:95:14
5555
|
5656
LL | Some(try_opt!(Some(rc)).clone())
5757
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `Rc::<u8>::clone(&try_opt!(Some(rc)))`
5858

59-
error: using `clone` on a double-reference, which copies the reference of type `std::vec::Vec<i32>` instead of cloning the inner type
60-
--> $DIR/unnecessary_clone.rs:48:22
61-
|
62-
LL | let z: &Vec<_> = y.clone();
63-
| ^^^^^^^^^
64-
|
65-
= note: `-D clone-double-ref` implied by `-D warnings`
66-
help: try dereferencing it
67-
|
68-
LL | let z: &Vec<_> = &(*y).clone();
69-
| +++ ~~~~~~~~~
70-
help: or try being explicit if you are sure, that you want to clone a reference
71-
|
72-
LL | let z: &Vec<_> = <&std::vec::Vec<i32>>::clone(y);
73-
| +++++++++++++++++++++++++++++ ~
74-
75-
error: using `clone` on a double-reference, which copies the reference of type `[u8]` instead of cloning the inner type
76-
--> $DIR/unnecessary_clone.rs:89:22
77-
|
78-
LL | let _ = &mut encoded.clone();
79-
| ^^^^^^^^^^^^^^^
80-
|
81-
help: try dereferencing it
82-
|
83-
LL | let _ = &mut &(*encoded).clone();
84-
| +++ ~~~~~~~~~
85-
help: or try being explicit if you are sure, that you want to clone a reference
86-
|
87-
LL | let _ = &mut <&[u8]>::clone(encoded);
88-
| +++++++++++++++ ~
89-
90-
error: using `clone` on a double-reference, which copies the reference of type `[u8]` instead of cloning the inner type
91-
--> $DIR/unnecessary_clone.rs:90:18
92-
|
93-
LL | let _ = &encoded.clone();
94-
| ^^^^^^^^^^^^^^^
95-
|
96-
help: try dereferencing it
97-
|
98-
LL | let _ = &&(*encoded).clone();
99-
| +++ ~~~~~~~~~
100-
help: or try being explicit if you are sure, that you want to clone a reference
101-
|
102-
LL | let _ = &<&[u8]>::clone(encoded);
103-
| +++++++++++++++ ~
104-
105-
error: aborting due to 12 previous errors
59+
error: aborting due to 9 previous errors
10660

tests/ui/lint/clone-double-ref.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,9 @@ fn rust_clippy_issue_9272() {
2020
println!("{str}")
2121
}
2222

23+
fn check(mut encoded: &[u8]) {
24+
let _ = &mut encoded.clone();
25+
let _ = &encoded.clone();
26+
}
27+
2328
fn main() {}

0 commit comments

Comments
 (0)