Skip to content

Commit d218a02

Browse files
committed
Drop uplifted clippy::forget_copy
1 parent 1e4f98a commit d218a02

File tree

9 files changed

+60
-460
lines changed

9 files changed

+60
-460
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
@@ -132,7 +132,6 @@ pub(crate) static LINTS: &[&crate::LintInfo] = &[
132132
crate::doc::UNNECESSARY_SAFETY_DOC_INFO,
133133
crate::double_parens::DOUBLE_PARENS_INFO,
134134
crate::drop_forget_ref::DROP_NON_DROP_INFO,
135-
crate::drop_forget_ref::FORGET_COPY_INFO,
136135
crate::drop_forget_ref::FORGET_NON_DROP_INFO,
137136
crate::drop_forget_ref::UNDROPPED_MANUALLY_DROPS_INFO,
138137
crate::duplicate_mod::DUPLICATE_MOD_INFO,

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

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -7,34 +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::forget` with a value that
13-
/// derives the Copy trait
14-
///
15-
/// ### Why is this bad?
16-
/// Calling `std::mem::forget` [does nothing for types that
17-
/// implement Copy](https://doc.rust-lang.org/std/mem/fn.drop.html) since the
18-
/// value will be copied and moved into the function on invocation.
19-
///
20-
/// An alternative, but also valid, explanation is that Copy types do not
21-
/// implement
22-
/// the Drop trait, which means they have no destructors. Without a destructor,
23-
/// there
24-
/// is nothing for `std::mem::forget` to ignore.
25-
///
26-
/// ### Example
27-
/// ```rust
28-
/// let x: i32 = 42; // i32 implements Copy
29-
/// std::mem::forget(x) // A copy of x is passed to the function, leaving the
30-
/// // original unaffected
31-
/// ```
32-
#[clippy::version = "pre 1.29.0"]
33-
pub FORGET_COPY,
34-
correctness,
35-
"calls to `std::mem::forget` with a value that implements Copy"
36-
}
37-
3810
declare_clippy_lint! {
3911
/// ### What it does
4012
/// Checks for calls to `std::mem::drop` with a value that does not implement `Drop`.
@@ -104,15 +76,12 @@ declare_clippy_lint! {
10476
"use of safe `std::mem::drop` function to drop a std::mem::ManuallyDrop, which will not drop the inner value"
10577
}
10678

107-
const FORGET_COPY_SUMMARY: &str = "calls to `std::mem::forget` with a value that implements `Copy`. \
108-
Forgetting a copy leaves the original intact";
10979
const DROP_NON_DROP_SUMMARY: &str = "call to `std::mem::drop` with a value that does not implement `Drop`. \
11080
Dropping such a type only extends its contained lifetimes";
11181
const FORGET_NON_DROP_SUMMARY: &str = "call to `std::mem::forget` with a value that does not implement `Drop`. \
11282
Forgetting such a type is the same as dropping it";
11383

11484
declare_lint_pass!(DropForgetRef => [
115-
FORGET_COPY,
11685
DROP_NON_DROP,
11786
FORGET_NON_DROP,
11887
UNDROPPED_MANUALLY_DROPS
@@ -129,11 +98,11 @@ impl<'tcx> LateLintPass<'tcx> for DropForgetRef {
12998
let is_copy = is_copy(cx, arg_ty);
13099
let drop_is_single_call_in_arm = is_single_call_in_arm(cx, arg, expr);
131100
let (lint, msg) = match fn_name {
132-
// early return for uplifted lints: drop_ref, drop_copy, forget_ref
101+
// early return for uplifted lints: drop_ref, drop_copy, forget_ref, forget_copy
133102
sym::mem_drop if arg_ty.is_ref() && !drop_is_single_call_in_arm => return,
134103
sym::mem_forget if arg_ty.is_ref() => return,
135104
sym::mem_drop if is_copy && !drop_is_single_call_in_arm => return,
136-
sym::mem_forget if is_copy => (FORGET_COPY, FORGET_COPY_SUMMARY),
105+
sym::mem_forget if is_copy => return,
137106
sym::mem_drop if is_type_lang_item(cx, arg_ty, LangItem::ManuallyDrop) => {
138107
span_lint_and_help(
139108
cx,

src/tools/clippy/clippy_lints/src/renamed_lints.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ pub static RENAMED_LINTS: &[(&str, &str)] = &[
3636
("clippy::for_loop_over_option", "for_loops_over_fallibles"),
3737
("clippy::for_loop_over_result", "for_loops_over_fallibles"),
3838
("clippy::for_loops_over_fallibles", "for_loops_over_fallibles"),
39+
("clippy::forget_copy", "forget_copy"),
3940
("clippy::forget_ref", "forget_ref"),
4041
("clippy::into_iter_on_array", "array_into_iter"),
4142
("clippy::invalid_atomic_ordering", "invalid_atomic_ordering"),

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

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

0 commit comments

Comments
 (0)