Skip to content

Commit 3d1940d

Browse files
committed
Drop uplifted clippy::drop_ref
1 parent 28cdbc2 commit 3d1940d

File tree

9 files changed

+58
-318
lines changed

9 files changed

+58
-318
lines changed

src/tools/clippy/clippy_lints/src/declared_lints.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ pub(crate) static LINTS: &[&crate::LintInfo] = &[
134134
crate::double_parens::DOUBLE_PARENS_INFO,
135135
crate::drop_forget_ref::DROP_COPY_INFO,
136136
crate::drop_forget_ref::DROP_NON_DROP_INFO,
137-
crate::drop_forget_ref::DROP_REF_INFO,
138137
crate::drop_forget_ref::FORGET_COPY_INFO,
139138
crate::drop_forget_ref::FORGET_NON_DROP_INFO,
140139
crate::drop_forget_ref::FORGET_REF_INFO,

src/tools/clippy/clippy_lints/src/drop_forget_ref.rs

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,6 @@ use rustc_lint::{LateContext, LateLintPass};
77
use rustc_session::{declare_lint_pass, declare_tool_lint};
88
use 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-
3410
declare_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";
177151
const FORGET_REF_SUMMARY: &str = "calls to `std::mem::forget` with a reference instead of an owned value. \
178152
Forgetting a reference does nothing";
179153
const 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

188162
declare_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),

src/tools/clippy/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_ref", "drop_ref"),
3536
("clippy::for_loop_over_option", "for_loops_over_fallibles"),
3637
("clippy::for_loop_over_result", "for_loops_over_fallibles"),
3738
("clippy::for_loops_over_fallibles", "for_loops_over_fallibles"),

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

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

44
use std::mem::{drop, forget};
55
use std::vec::Vec;

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

Lines changed: 0 additions & 97 deletions
This file was deleted.

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

Lines changed: 0 additions & 147 deletions
This file was deleted.

src/tools/clippy/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_ref)]
3233
#![allow(for_loops_over_fallibles)]
3334
#![allow(array_into_iter)]
3435
#![allow(invalid_atomic_ordering)]
@@ -71,6 +72,7 @@
7172
#![warn(clippy::invisible_characters)]
7273
#![warn(suspicious_double_ref_op)]
7374
#![warn(drop_bounds)]
75+
#![warn(drop_ref)]
7476
#![warn(for_loops_over_fallibles)]
7577
#![warn(for_loops_over_fallibles)]
7678
#![warn(for_loops_over_fallibles)]

src/tools/clippy/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_ref)]
3233
#![allow(for_loops_over_fallibles)]
3334
#![allow(array_into_iter)]
3435
#![allow(invalid_atomic_ordering)]
@@ -71,6 +72,7 @@
7172
#![warn(clippy::zero_width_space)]
7273
#![warn(clippy::clone_double_ref)]
7374
#![warn(clippy::drop_bounds)]
75+
#![warn(clippy::drop_ref)]
7476
#![warn(clippy::for_loop_over_option)]
7577
#![warn(clippy::for_loop_over_result)]
7678
#![warn(clippy::for_loops_over_fallibles)]

0 commit comments

Comments
 (0)