1- use clippy_utils:: diagnostics:: { span_lint_and_help , span_lint_and_note} ;
1+ use clippy_utils:: diagnostics:: span_lint_and_note;
22use clippy_utils:: get_parent_node;
33use clippy_utils:: is_must_use_func_call;
44use clippy_utils:: ty:: { is_copy, is_must_use_ty, is_type_lang_item} ;
@@ -47,35 +47,6 @@ declare_clippy_lint! {
4747 "call to `std::mem::forget` with a value which does not implement `Drop`"
4848}
4949
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-
7950const DROP_NON_DROP_SUMMARY : & str = "call to `std::mem::drop` with a value that does not implement `Drop`. \
8051 Dropping such a type only extends its contained lifetimes";
8152const 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
8455declare_lint_pass ! ( DropForgetRef => [
8556 DROP_NON_DROP ,
8657 FORGET_NON_DROP ,
87- UNDROPPED_MANUALLY_DROPS
8858] ) ;
8959
9060impl < ' tcx > LateLintPass < ' tcx > for DropForgetRef {
@@ -103,17 +73,7 @@ impl<'tcx> LateLintPass<'tcx> for DropForgetRef {
10373 sym:: mem_forget if arg_ty. is_ref ( ) => return ,
10474 sym:: mem_drop if is_copy && !drop_is_single_call_in_arm => return ,
10575 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 ,
11777 sym:: mem_drop
11878 if !( arg_ty. needs_drop ( cx. tcx , cx. param_env )
11979 || is_must_use_func_call ( cx, arg)
0 commit comments