@@ -7,30 +7,6 @@ use rustc_lint::{LateContext, LateLintPass};
77use rustc_session:: { declare_lint_pass, declare_tool_lint} ;
88use rustc_span:: sym;
99
10- declare_clippy_lint ! {
11- /// ### What it does
12- /// Checks for calls to `std::mem::drop` with a reference
13- /// instead of an owned value.
14- ///
15- /// ### Why is this bad?
16- /// Calling `drop` on a reference will only drop the
17- /// reference itself, which is a no-op. It will not call the `drop` method (from
18- /// the `Drop` trait implementation) on the underlying referenced value, which
19- /// is likely what was intended.
20- ///
21- /// ### Example
22- /// ```ignore
23- /// let mut lock_guard = mutex.lock();
24- /// std::mem::drop(&lock_guard) // Should have been drop(lock_guard), mutex
25- /// // still locked
26- /// operation_that_requires_mutex_to_be_unlocked();
27- /// ```
28- #[ clippy:: version = "pre 1.29.0" ]
29- pub DROP_REF ,
30- correctness,
31- "calls to `std::mem::drop` with a reference instead of an owned value"
32- }
33-
3410declare_clippy_lint ! {
3511 /// ### What it does
3612 /// Checks for calls to `std::mem::forget` with a reference
@@ -172,8 +148,6 @@ declare_clippy_lint! {
172148 "use of safe `std::mem::drop` function to drop a std::mem::ManuallyDrop, which will not drop the inner value"
173149}
174150
175- const DROP_REF_SUMMARY : & str = "calls to `std::mem::drop` with a reference instead of an owned value. \
176- Dropping a reference does nothing";
177151const FORGET_REF_SUMMARY : & str = "calls to `std::mem::forget` with a reference instead of an owned value. \
178152 Forgetting a reference does nothing";
179153const DROP_COPY_SUMMARY : & str = "calls to `std::mem::drop` with a value that implements `Copy`. \
@@ -186,7 +160,6 @@ const FORGET_NON_DROP_SUMMARY: &str = "call to `std::mem::forget` with a value t
186160 Forgetting such a type is the same as dropping it";
187161
188162declare_lint_pass ! ( DropForgetRef => [
189- DROP_REF ,
190163 FORGET_REF ,
191164 DROP_COPY ,
192165 FORGET_COPY ,
@@ -206,7 +179,8 @@ impl<'tcx> LateLintPass<'tcx> for DropForgetRef {
206179 let is_copy = is_copy ( cx, arg_ty) ;
207180 let drop_is_single_call_in_arm = is_single_call_in_arm ( cx, arg, expr) ;
208181 let ( lint, msg) = match fn_name {
209- sym:: mem_drop if arg_ty. is_ref ( ) && !drop_is_single_call_in_arm => ( DROP_REF , DROP_REF_SUMMARY ) ,
182+ // early return for uplifted lints: drop_ref
183+ sym:: mem_drop if arg_ty. is_ref ( ) && !drop_is_single_call_in_arm => return ,
210184 sym:: mem_forget if arg_ty. is_ref ( ) => ( FORGET_REF , FORGET_REF_SUMMARY ) ,
211185 sym:: mem_drop if is_copy && !drop_is_single_call_in_arm => ( DROP_COPY , DROP_COPY_SUMMARY ) ,
212186 sym:: mem_forget if is_copy => ( FORGET_COPY , FORGET_COPY_SUMMARY ) ,
0 commit comments