1
- use clippy_utils:: diagnostics:: { span_lint_and_help , span_lint_and_note} ;
1
+ use clippy_utils:: diagnostics:: span_lint_and_note;
2
2
use clippy_utils:: get_parent_node;
3
3
use clippy_utils:: is_must_use_func_call;
4
4
use clippy_utils:: ty:: { is_copy, is_must_use_ty, is_type_lang_item} ;
@@ -47,35 +47,6 @@ declare_clippy_lint! {
47
47
"call to `std::mem::forget` with a value which does not implement `Drop`"
48
48
}
49
49
50
- declare_clippy_lint ! {
51
- /// ### What it does
52
- /// Prevents the safe `std::mem::drop` function from being called on `std::mem::ManuallyDrop`.
53
- ///
54
- /// ### Why is this bad?
55
- /// The safe `drop` function does not drop the inner value of a `ManuallyDrop`.
56
- ///
57
- /// ### Known problems
58
- /// Does not catch cases if the user binds `std::mem::drop`
59
- /// to a different name and calls it that way.
60
- ///
61
- /// ### Example
62
- /// ```rust
63
- /// struct S;
64
- /// drop(std::mem::ManuallyDrop::new(S));
65
- /// ```
66
- /// Use instead:
67
- /// ```rust
68
- /// struct S;
69
- /// unsafe {
70
- /// std::mem::ManuallyDrop::drop(&mut std::mem::ManuallyDrop::new(S));
71
- /// }
72
- /// ```
73
- #[ clippy:: version = "1.49.0" ]
74
- pub UNDROPPED_MANUALLY_DROPS ,
75
- correctness,
76
- "use of safe `std::mem::drop` function to drop a std::mem::ManuallyDrop, which will not drop the inner value"
77
- }
78
-
79
50
const DROP_NON_DROP_SUMMARY : & str = "call to `std::mem::drop` with a value that does not implement `Drop`. \
80
51
Dropping such a type only extends its contained lifetimes";
81
52
const FORGET_NON_DROP_SUMMARY : & str = "call to `std::mem::forget` with a value that does not implement `Drop`. \
@@ -84,7 +55,6 @@ const FORGET_NON_DROP_SUMMARY: &str = "call to `std::mem::forget` with a value t
84
55
declare_lint_pass ! ( DropForgetRef => [
85
56
DROP_NON_DROP ,
86
57
FORGET_NON_DROP ,
87
- UNDROPPED_MANUALLY_DROPS
88
58
] ) ;
89
59
90
60
impl < ' tcx > LateLintPass < ' tcx > for DropForgetRef {
@@ -103,17 +73,7 @@ impl<'tcx> LateLintPass<'tcx> for DropForgetRef {
103
73
sym:: mem_forget if arg_ty. is_ref ( ) => return ,
104
74
sym:: mem_drop if is_copy && !drop_is_single_call_in_arm => return ,
105
75
sym:: mem_forget if is_copy => return ,
106
- sym:: mem_drop if is_type_lang_item ( cx, arg_ty, LangItem :: ManuallyDrop ) => {
107
- span_lint_and_help (
108
- cx,
109
- UNDROPPED_MANUALLY_DROPS ,
110
- expr. span ,
111
- "the inner value of this ManuallyDrop will not be dropped" ,
112
- None ,
113
- "to drop a `ManuallyDrop<T>`, use std::mem::ManuallyDrop::drop" ,
114
- ) ;
115
- return ;
116
- }
76
+ sym:: mem_drop if is_type_lang_item ( cx, arg_ty, LangItem :: ManuallyDrop ) => return ,
117
77
sym:: mem_drop
118
78
if !( arg_ty. needs_drop ( cx. tcx , cx. param_env )
119
79
|| is_must_use_func_call ( cx, arg)
0 commit comments