Skip to content

Commit 551f6e6

Browse files
committed
Drop uplifted clippy::drop_copy
1 parent 6af0359 commit 551f6e6

11 files changed

+102
-117
lines changed

clippy_lints/src/declared_lints.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ pub(crate) static LINTS: &[&crate::LintInfo] = &[
132132
crate::doc::NEEDLESS_DOCTEST_MAIN_INFO,
133133
crate::doc::UNNECESSARY_SAFETY_DOC_INFO,
134134
crate::double_parens::DOUBLE_PARENS_INFO,
135-
crate::drop_forget_ref::DROP_COPY_INFO,
136135
crate::drop_forget_ref::DROP_NON_DROP_INFO,
137136
crate::drop_forget_ref::FORGET_COPY_INFO,
138137
crate::drop_forget_ref::FORGET_NON_DROP_INFO,

clippy_lints/src/drop_forget_ref.rs

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -29,28 +29,6 @@ declare_clippy_lint! {
2929
"calls to `std::mem::forget` with a reference instead of an owned value"
3030
}
3131

32-
declare_clippy_lint! {
33-
/// ### What it does
34-
/// Checks for calls to `std::mem::drop` with a value
35-
/// that derives the Copy trait
36-
///
37-
/// ### Why is this bad?
38-
/// Calling `std::mem::drop` [does nothing for types that
39-
/// implement Copy](https://doc.rust-lang.org/std/mem/fn.drop.html), since the
40-
/// value will be copied and moved into the function on invocation.
41-
///
42-
/// ### Example
43-
/// ```rust
44-
/// let x: i32 = 42; // i32 implements Copy
45-
/// std::mem::drop(x) // A copy of x is passed to the function, leaving the
46-
/// // original unaffected
47-
/// ```
48-
#[clippy::version = "pre 1.29.0"]
49-
pub DROP_COPY,
50-
correctness,
51-
"calls to `std::mem::drop` with a value that implements Copy"
52-
}
53-
5432
declare_clippy_lint! {
5533
/// ### What it does
5634
/// Checks for calls to `std::mem::forget` with a value that
@@ -150,8 +128,6 @@ declare_clippy_lint! {
150128

151129
const FORGET_REF_SUMMARY: &str = "calls to `std::mem::forget` with a reference instead of an owned value. \
152130
Forgetting a reference does nothing";
153-
const DROP_COPY_SUMMARY: &str = "calls to `std::mem::drop` with a value that implements `Copy`. \
154-
Dropping a copy leaves the original intact";
155131
const FORGET_COPY_SUMMARY: &str = "calls to `std::mem::forget` with a value that implements `Copy`. \
156132
Forgetting a copy leaves the original intact";
157133
const DROP_NON_DROP_SUMMARY: &str = "call to `std::mem::drop` with a value that does not implement `Drop`. \
@@ -161,7 +137,6 @@ const FORGET_NON_DROP_SUMMARY: &str = "call to `std::mem::forget` with a value t
161137

162138
declare_lint_pass!(DropForgetRef => [
163139
FORGET_REF,
164-
DROP_COPY,
165140
FORGET_COPY,
166141
DROP_NON_DROP,
167142
FORGET_NON_DROP,
@@ -179,10 +154,10 @@ impl<'tcx> LateLintPass<'tcx> for DropForgetRef {
179154
let is_copy = is_copy(cx, arg_ty);
180155
let drop_is_single_call_in_arm = is_single_call_in_arm(cx, arg, expr);
181156
let (lint, msg) = match fn_name {
182-
// early return for uplifted lints: drop_ref
157+
// early return for uplifted lints: drop_ref, drop_copy
183158
sym::mem_drop if arg_ty.is_ref() && !drop_is_single_call_in_arm => return,
184159
sym::mem_forget if arg_ty.is_ref() => (FORGET_REF, FORGET_REF_SUMMARY),
185-
sym::mem_drop if is_copy && !drop_is_single_call_in_arm => (DROP_COPY, DROP_COPY_SUMMARY),
160+
sym::mem_drop if is_copy && !drop_is_single_call_in_arm => return,
186161
sym::mem_forget if is_copy => (FORGET_COPY, FORGET_COPY_SUMMARY),
187162
sym::mem_drop if is_type_lang_item(cx, arg_ty, LangItem::ManuallyDrop) => {
188163
span_lint_and_help(

clippy_lints/src/renamed_lints.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ pub static RENAMED_LINTS: &[(&str, &str)] = &[
3232
("clippy::zero_width_space", "clippy::invisible_characters"),
3333
("clippy::clone_double_ref", "suspicious_double_ref_op"),
3434
("clippy::drop_bounds", "drop_bounds"),
35+
("clippy::drop_copy", "drop_copy"),
3536
("clippy::drop_ref", "drop_ref"),
3637
("clippy::for_loop_over_option", "for_loops_over_fallibles"),
3738
("clippy::for_loop_over_result", "for_loops_over_fallibles"),

tests/ui/drop_forget_copy.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![warn(clippy::drop_copy, clippy::forget_copy)]
1+
#![warn(drop_copy, clippy::forget_copy)]
22
#![allow(clippy::toplevel_ref_arg, drop_ref, clippy::forget_ref, unused_mut)]
33

44
use std::mem::{drop, forget};

tests/ui/drop_forget_copy.stderr

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,3 @@
1-
error: calls to `std::mem::drop` with a value that implements `Copy`. Dropping a copy leaves the original intact
2-
--> $DIR/drop_forget_copy.rs:33:5
3-
|
4-
LL | drop(s1);
5-
| ^^^^^^^^
6-
|
7-
note: argument has type `SomeStruct`
8-
--> $DIR/drop_forget_copy.rs:33:10
9-
|
10-
LL | drop(s1);
11-
| ^^
12-
= note: `-D clippy::drop-copy` implied by `-D warnings`
13-
14-
error: calls to `std::mem::drop` with a value that implements `Copy`. Dropping a copy leaves the original intact
15-
--> $DIR/drop_forget_copy.rs:34:5
16-
|
17-
LL | drop(s2);
18-
| ^^^^^^^^
19-
|
20-
note: argument has type `SomeStruct`
21-
--> $DIR/drop_forget_copy.rs:34:10
22-
|
23-
LL | drop(s2);
24-
| ^^
25-
26-
error: calls to `std::mem::drop` with a value that implements `Copy`. Dropping a copy leaves the original intact
27-
--> $DIR/drop_forget_copy.rs:36:5
28-
|
29-
LL | drop(s4);
30-
| ^^^^^^^^
31-
|
32-
note: argument has type `SomeStruct`
33-
--> $DIR/drop_forget_copy.rs:36:10
34-
|
35-
LL | drop(s4);
36-
| ^^
37-
381
error: calls to `std::mem::forget` with a value that implements `Copy`. Forgetting a copy leaves the original intact
392
--> $DIR/drop_forget_copy.rs:39:5
403
|
@@ -72,7 +35,44 @@ note: argument has type `SomeStruct`
7235
LL | forget(s4);
7336
| ^^
7437

75-
error: calls to `std::mem::drop` with a value that implements `Copy`. Dropping a copy leaves the original intact
38+
error: calls to `std::mem::drop` with a value that implements `Copy`.
39+
--> $DIR/drop_forget_copy.rs:33:5
40+
|
41+
LL | drop(s1);
42+
| ^^^^^^^^
43+
|
44+
note: argument has type `SomeStruct`
45+
--> $DIR/drop_forget_copy.rs:33:10
46+
|
47+
LL | drop(s1);
48+
| ^^
49+
= note: `-D drop-copy` implied by `-D warnings`
50+
51+
error: calls to `std::mem::drop` with a value that implements `Copy`.
52+
--> $DIR/drop_forget_copy.rs:34:5
53+
|
54+
LL | drop(s2);
55+
| ^^^^^^^^
56+
|
57+
note: argument has type `SomeStruct`
58+
--> $DIR/drop_forget_copy.rs:34:10
59+
|
60+
LL | drop(s2);
61+
| ^^
62+
63+
error: calls to `std::mem::drop` with a value that implements `Copy`.
64+
--> $DIR/drop_forget_copy.rs:36:5
65+
|
66+
LL | drop(s4);
67+
| ^^^^^^^^
68+
|
69+
note: argument has type `SomeStruct`
70+
--> $DIR/drop_forget_copy.rs:36:10
71+
|
72+
LL | drop(s4);
73+
| ^^
74+
75+
error: calls to `std::mem::drop` with a value that implements `Copy`.
7676
--> $DIR/drop_forget_copy.rs:80:13
7777
|
7878
LL | drop(println_and(13)); // Lint, even if we only care about the side-effect, it's already in a block
@@ -84,7 +84,7 @@ note: argument has type `i32`
8484
LL | drop(println_and(13)); // Lint, even if we only care about the side-effect, it's already in a block
8585
| ^^^^^^^^^^^^^^^
8686

87-
error: calls to `std::mem::drop` with a value that implements `Copy`. Dropping a copy leaves the original intact
87+
error: calls to `std::mem::drop` with a value that implements `Copy`.
8888
--> $DIR/drop_forget_copy.rs:82:14
8989
|
9090
LL | 3 if drop(println_and(14)) == () => (), // Lint, idiomatic use is only in body of `Arm`
@@ -96,7 +96,7 @@ note: argument has type `i32`
9696
LL | 3 if drop(println_and(14)) == () => (), // Lint, idiomatic use is only in body of `Arm`
9797
| ^^^^^^^^^^^^^^^
9898

99-
error: calls to `std::mem::drop` with a value that implements `Copy`. Dropping a copy leaves the original intact
99+
error: calls to `std::mem::drop` with a value that implements `Copy`.
100100
--> $DIR/drop_forget_copy.rs:83:14
101101
|
102102
LL | 4 => drop(2), // Lint, not a fn/method call

tests/ui/multiple_unsafe_ops_per_block.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#![allow(unused)]
33
#![allow(deref_nullptr)]
44
#![allow(clippy::unnecessary_operation)]
5-
#![allow(clippy::drop_copy)]
5+
#![allow(drop_copy)]
66
#![warn(clippy::multiple_unsafe_ops_per_block)]
77

88
extern crate proc_macros;

tests/ui/rename.fixed

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#![allow(clippy::invisible_characters)]
3030
#![allow(suspicious_double_ref_op)]
3131
#![allow(drop_bounds)]
32+
#![allow(drop_copy)]
3233
#![allow(drop_ref)]
3334
#![allow(for_loops_over_fallibles)]
3435
#![allow(array_into_iter)]
@@ -72,6 +73,7 @@
7273
#![warn(clippy::invisible_characters)]
7374
#![warn(suspicious_double_ref_op)]
7475
#![warn(drop_bounds)]
76+
#![warn(drop_copy)]
7577
#![warn(drop_ref)]
7678
#![warn(for_loops_over_fallibles)]
7779
#![warn(for_loops_over_fallibles)]

tests/ui/rename.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#![allow(clippy::invisible_characters)]
3030
#![allow(suspicious_double_ref_op)]
3131
#![allow(drop_bounds)]
32+
#![allow(drop_copy)]
3233
#![allow(drop_ref)]
3334
#![allow(for_loops_over_fallibles)]
3435
#![allow(array_into_iter)]
@@ -72,6 +73,7 @@
7273
#![warn(clippy::zero_width_space)]
7374
#![warn(clippy::clone_double_ref)]
7475
#![warn(clippy::drop_bounds)]
76+
#![warn(clippy::drop_copy)]
7577
#![warn(clippy::drop_ref)]
7678
#![warn(clippy::for_loop_over_option)]
7779
#![warn(clippy::for_loop_over_result)]

0 commit comments

Comments
 (0)