Skip to content

Commit cf6d227

Browse files
committed
Drop uplifted clippy::forget_ref
1 parent 1ef9c16 commit cf6d227

File tree

9 files changed

+60
-236
lines changed

9 files changed

+60
-236
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
@@ -135,7 +135,6 @@ pub(crate) static LINTS: &[&crate::LintInfo] = &[
135135
crate::drop_forget_ref::DROP_NON_DROP_INFO,
136136
crate::drop_forget_ref::FORGET_COPY_INFO,
137137
crate::drop_forget_ref::FORGET_NON_DROP_INFO,
138-
crate::drop_forget_ref::FORGET_REF_INFO,
139138
crate::drop_forget_ref::UNDROPPED_MANUALLY_DROPS_INFO,
140139
crate::duplicate_mod::DUPLICATE_MOD_INFO,
141140
crate::else_if_without_else::ELSE_IF_WITHOUT_ELSE_INFO,

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

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +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 reference
13-
/// instead of an owned value.
14-
///
15-
/// ### Why is this bad?
16-
/// Calling `forget` on a reference will only forget the
17-
/// reference itself, which is a no-op. It will not forget the underlying
18-
/// referenced
19-
/// value, which is likely what was intended.
20-
///
21-
/// ### Example
22-
/// ```rust
23-
/// let x = Box::new(1);
24-
/// std::mem::forget(&x) // Should have been forget(x), x will still be dropped
25-
/// ```
26-
#[clippy::version = "pre 1.29.0"]
27-
pub FORGET_REF,
28-
correctness,
29-
"calls to `std::mem::forget` with a reference instead of an owned value"
30-
}
31-
3210
declare_clippy_lint! {
3311
/// ### What it does
3412
/// Checks for calls to `std::mem::forget` with a value that
@@ -126,8 +104,6 @@ declare_clippy_lint! {
126104
"use of safe `std::mem::drop` function to drop a std::mem::ManuallyDrop, which will not drop the inner value"
127105
}
128106

129-
const FORGET_REF_SUMMARY: &str = "calls to `std::mem::forget` with a reference instead of an owned value. \
130-
Forgetting a reference does nothing";
131107
const FORGET_COPY_SUMMARY: &str = "calls to `std::mem::forget` with a value that implements `Copy`. \
132108
Forgetting a copy leaves the original intact";
133109
const DROP_NON_DROP_SUMMARY: &str = "call to `std::mem::drop` with a value that does not implement `Drop`. \
@@ -136,7 +112,6 @@ const FORGET_NON_DROP_SUMMARY: &str = "call to `std::mem::forget` with a value t
136112
Forgetting such a type is the same as dropping it";
137113

138114
declare_lint_pass!(DropForgetRef => [
139-
FORGET_REF,
140115
FORGET_COPY,
141116
DROP_NON_DROP,
142117
FORGET_NON_DROP,
@@ -154,9 +129,9 @@ impl<'tcx> LateLintPass<'tcx> for DropForgetRef {
154129
let is_copy = is_copy(cx, arg_ty);
155130
let drop_is_single_call_in_arm = is_single_call_in_arm(cx, arg, expr);
156131
let (lint, msg) = match fn_name {
157-
// early return for uplifted lints: drop_ref, drop_copy
132+
// early return for uplifted lints: drop_ref, drop_copy, forget_ref
158133
sym::mem_drop if arg_ty.is_ref() && !drop_is_single_call_in_arm => return,
159-
sym::mem_forget if arg_ty.is_ref() => (FORGET_REF, FORGET_REF_SUMMARY),
134+
sym::mem_forget if arg_ty.is_ref() => return,
160135
sym::mem_drop if is_copy && !drop_is_single_call_in_arm => return,
161136
sym::mem_forget if is_copy => (FORGET_COPY, FORGET_COPY_SUMMARY),
162137
sym::mem_drop if is_type_lang_item(cx, arg_ty, LangItem::ManuallyDrop) => {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ pub static RENAMED_LINTS: &[(&str, &str)] = &[
3737
("clippy::for_loop_over_option", "for_loops_over_fallibles"),
3838
("clippy::for_loop_over_result", "for_loops_over_fallibles"),
3939
("clippy::for_loops_over_fallibles", "for_loops_over_fallibles"),
40+
("clippy::forget_ref", "forget_ref"),
4041
("clippy::into_iter_on_array", "array_into_iter"),
4142
("clippy::invalid_atomic_ordering", "invalid_atomic_ordering"),
4243
("clippy::invalid_ref", "invalid_value"),

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(drop_copy, clippy::forget_copy)]
2-
#![allow(clippy::toplevel_ref_arg, drop_ref, clippy::forget_ref, unused_mut)]
2+
#![allow(clippy::toplevel_ref_arg, drop_ref, forget_ref, unused_mut)]
33

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

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

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

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

Lines changed: 0 additions & 111 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
@@ -32,6 +32,7 @@
3232
#![allow(drop_copy)]
3333
#![allow(drop_ref)]
3434
#![allow(for_loops_over_fallibles)]
35+
#![allow(forget_ref)]
3536
#![allow(array_into_iter)]
3637
#![allow(invalid_atomic_ordering)]
3738
#![allow(invalid_value)]
@@ -78,6 +79,7 @@
7879
#![warn(for_loops_over_fallibles)]
7980
#![warn(for_loops_over_fallibles)]
8081
#![warn(for_loops_over_fallibles)]
82+
#![warn(forget_ref)]
8183
#![warn(array_into_iter)]
8284
#![warn(invalid_atomic_ordering)]
8385
#![warn(invalid_value)]

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#![allow(drop_copy)]
3333
#![allow(drop_ref)]
3434
#![allow(for_loops_over_fallibles)]
35+
#![allow(forget_ref)]
3536
#![allow(array_into_iter)]
3637
#![allow(invalid_atomic_ordering)]
3738
#![allow(invalid_value)]
@@ -78,6 +79,7 @@
7879
#![warn(clippy::for_loop_over_option)]
7980
#![warn(clippy::for_loop_over_result)]
8081
#![warn(clippy::for_loops_over_fallibles)]
82+
#![warn(clippy::forget_ref)]
8183
#![warn(clippy::into_iter_on_array)]
8284
#![warn(clippy::invalid_atomic_ordering)]
8385
#![warn(clippy::invalid_ref)]

0 commit comments

Comments
 (0)