mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-30 22:12:15 +00:00
Rename forget_copy
lint to forgetting_copy_types
This commit is contained in:
parent
1c7ab18c08
commit
85a1828943
@ -533,6 +533,6 @@ lint_forget_ref = calls to `std::mem::forget` with a reference instead of an own
|
||||
.label = argument has type `{$arg_ty}`
|
||||
.note = use `let _ = ...` to ignore the expression or result
|
||||
|
||||
lint_forget_copy = calls to `std::mem::forget` with a value that implements `Copy` does nothing
|
||||
lint_forgetting_copy_types = calls to `std::mem::forget` with a value that implements `Copy` does nothing
|
||||
.label = argument has type `{$arg_ty}`
|
||||
.note = use `let _ = ...` to ignore the expression or result
|
||||
|
@ -82,7 +82,7 @@ declare_lint! {
|
||||
}
|
||||
|
||||
declare_lint! {
|
||||
/// The `forget_copy` lint checks for calls to `std::mem::forget` with a value
|
||||
/// The `forgetting_copy_types` lint checks for calls to `std::mem::forget` with a value
|
||||
/// that derives the Copy trait.
|
||||
///
|
||||
/// ### Example
|
||||
@ -104,12 +104,12 @@ declare_lint! {
|
||||
/// An alternative, but also valid, explanation is that Copy types do not
|
||||
/// implement the Drop trait, which means they have no destructors. Without a
|
||||
/// destructor, there is nothing for `std::mem::forget` to ignore.
|
||||
pub FORGET_COPY,
|
||||
pub FORGETTING_COPY_TYPES,
|
||||
Warn,
|
||||
"calls to `std::mem::forget` with a value that implements Copy"
|
||||
}
|
||||
|
||||
declare_lint_pass!(DropForgetUseless => [DROP_REF, FORGET_REF, DROPPING_COPY_TYPES, FORGET_COPY]);
|
||||
declare_lint_pass!(DropForgetUseless => [DROP_REF, FORGET_REF, DROPPING_COPY_TYPES, FORGETTING_COPY_TYPES]);
|
||||
|
||||
impl<'tcx> LateLintPass<'tcx> for DropForgetUseless {
|
||||
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) {
|
||||
@ -132,7 +132,7 @@ impl<'tcx> LateLintPass<'tcx> for DropForgetUseless {
|
||||
cx.emit_spanned_lint(DROPPING_COPY_TYPES, expr.span, DropCopyDiag { arg_ty, label: arg.span });
|
||||
}
|
||||
sym::mem_forget if is_copy => {
|
||||
cx.emit_spanned_lint(FORGET_COPY, expr.span, ForgetCopyDiag { arg_ty, label: arg.span });
|
||||
cx.emit_spanned_lint(FORGETTING_COPY_TYPES, expr.span, ForgetCopyDiag { arg_ty, label: arg.span });
|
||||
}
|
||||
_ => return,
|
||||
};
|
||||
|
@ -691,7 +691,7 @@ pub struct ForgetRefDiag<'a> {
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[diag(lint_forget_copy)]
|
||||
#[diag(lint_forgetting_copy_types)]
|
||||
#[note]
|
||||
pub struct ForgetCopyDiag<'a> {
|
||||
pub arg_ty: Ty<'a>,
|
||||
|
@ -98,7 +98,7 @@ impl<'tcx> LateLintPass<'tcx> for DropForgetRef {
|
||||
let is_copy = is_copy(cx, arg_ty);
|
||||
let drop_is_single_call_in_arm = is_single_call_in_arm(cx, arg, expr);
|
||||
let (lint, msg) = match fn_name {
|
||||
// early return for uplifted lints: drop_ref, dropping_copy_types, forget_ref, forget_copy
|
||||
// early return for uplifted lints: drop_ref, dropping_copy_types, forget_ref, forgetting_copy_types
|
||||
sym::mem_drop if arg_ty.is_ref() && !drop_is_single_call_in_arm => return,
|
||||
sym::mem_forget if arg_ty.is_ref() => return,
|
||||
sym::mem_drop if is_copy && !drop_is_single_call_in_arm => return,
|
||||
|
@ -38,7 +38,7 @@ pub static RENAMED_LINTS: &[(&str, &str)] = &[
|
||||
("clippy::for_loop_over_option", "for_loops_over_fallibles"),
|
||||
("clippy::for_loop_over_result", "for_loops_over_fallibles"),
|
||||
("clippy::for_loops_over_fallibles", "for_loops_over_fallibles"),
|
||||
("clippy::forget_copy", "forget_copy"),
|
||||
("clippy::forget_copy", "forgetting_copy_types"),
|
||||
("clippy::forget_ref", "forget_ref"),
|
||||
("clippy::into_iter_on_array", "array_into_iter"),
|
||||
("clippy::invalid_atomic_ordering", "invalid_atomic_ordering"),
|
||||
|
@ -5,7 +5,7 @@ use std::mem as memstuff;
|
||||
use std::mem::forget as forgetSomething;
|
||||
|
||||
#[warn(clippy::mem_forget)]
|
||||
#[allow(forget_copy)]
|
||||
#[allow(forgetting_copy_types)]
|
||||
fn main() {
|
||||
let five: i32 = 5;
|
||||
forgetSomething(five);
|
||||
|
@ -33,7 +33,7 @@
|
||||
#![allow(dropping_copy_types)]
|
||||
#![allow(drop_ref)]
|
||||
#![allow(for_loops_over_fallibles)]
|
||||
#![allow(forget_copy)]
|
||||
#![allow(forgetting_copy_types)]
|
||||
#![allow(forget_ref)]
|
||||
#![allow(array_into_iter)]
|
||||
#![allow(invalid_atomic_ordering)]
|
||||
@ -82,7 +82,7 @@
|
||||
#![warn(for_loops_over_fallibles)]
|
||||
#![warn(for_loops_over_fallibles)]
|
||||
#![warn(for_loops_over_fallibles)]
|
||||
#![warn(forget_copy)]
|
||||
#![warn(forgetting_copy_types)]
|
||||
#![warn(forget_ref)]
|
||||
#![warn(array_into_iter)]
|
||||
#![warn(invalid_atomic_ordering)]
|
||||
|
@ -33,7 +33,7 @@
|
||||
#![allow(dropping_copy_types)]
|
||||
#![allow(drop_ref)]
|
||||
#![allow(for_loops_over_fallibles)]
|
||||
#![allow(forget_copy)]
|
||||
#![allow(forgetting_copy_types)]
|
||||
#![allow(forget_ref)]
|
||||
#![allow(array_into_iter)]
|
||||
#![allow(invalid_atomic_ordering)]
|
||||
|
@ -216,11 +216,11 @@ error: lint `clippy::for_loops_over_fallibles` has been renamed to `for_loops_ov
|
||||
LL | #![warn(clippy::for_loops_over_fallibles)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `for_loops_over_fallibles`
|
||||
|
||||
error: lint `clippy::forget_copy` has been renamed to `forget_copy`
|
||||
error: lint `clippy::forget_copy` has been renamed to `forgetting_copy_types`
|
||||
--> $DIR/rename.rs:85:9
|
||||
|
|
||||
LL | #![warn(clippy::forget_copy)]
|
||||
| ^^^^^^^^^^^^^^^^^^^ help: use the new name: `forget_copy`
|
||||
| ^^^^^^^^^^^^^^^^^^^ help: use the new name: `forgetting_copy_types`
|
||||
|
||||
error: lint `clippy::forget_ref` has been renamed to `forget_ref`
|
||||
--> $DIR/rename.rs:86:9
|
||||
|
@ -1,6 +1,6 @@
|
||||
// check-pass
|
||||
|
||||
#![allow(forget_copy)]
|
||||
#![allow(forgetting_copy_types)]
|
||||
|
||||
use std::mem::forget;
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
// check-pass
|
||||
|
||||
#![allow(forget_copy)]
|
||||
#![allow(forgetting_copy_types)]
|
||||
|
||||
const _: () = core::mem::forget(Box::<u32>::default);
|
||||
const _: () = core::mem::forget(|| Box::<u32>::default());
|
||||
|
@ -1,6 +1,6 @@
|
||||
// check-pass
|
||||
|
||||
#![warn(forget_copy)]
|
||||
#![warn(forgetting_copy_types)]
|
||||
|
||||
use std::mem::forget;
|
||||
use std::vec::Vec;
|
@ -1,5 +1,5 @@
|
||||
warning: calls to `std::mem::forget` with a value that implements `Copy` does nothing
|
||||
--> $DIR/forget_copy.rs:34:5
|
||||
--> $DIR/forgetting_copy_types.rs:34:5
|
||||
|
|
||||
LL | forget(s1);
|
||||
| ^^^^^^^--^
|
||||
@ -8,13 +8,13 @@ LL | forget(s1);
|
||||
|
|
||||
= note: use `let _ = ...` to ignore the expression or result
|
||||
note: the lint level is defined here
|
||||
--> $DIR/forget_copy.rs:3:9
|
||||
--> $DIR/forgetting_copy_types.rs:3:9
|
||||
|
|
||||
LL | #![warn(forget_copy)]
|
||||
| ^^^^^^^^^^^
|
||||
LL | #![warn(forgetting_copy_types)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: calls to `std::mem::forget` with a value that implements `Copy` does nothing
|
||||
--> $DIR/forget_copy.rs:35:5
|
||||
--> $DIR/forgetting_copy_types.rs:35:5
|
||||
|
|
||||
LL | forget(s2);
|
||||
| ^^^^^^^--^
|
||||
@ -24,7 +24,7 @@ LL | forget(s2);
|
||||
= note: use `let _ = ...` to ignore the expression or result
|
||||
|
||||
warning: calls to `std::mem::forget` with a reference instead of an owned value does nothing
|
||||
--> $DIR/forget_copy.rs:36:5
|
||||
--> $DIR/forgetting_copy_types.rs:36:5
|
||||
|
|
||||
LL | forget(s3);
|
||||
| ^^^^^^^--^
|
||||
@ -35,7 +35,7 @@ LL | forget(s3);
|
||||
= note: `#[warn(forget_ref)]` on by default
|
||||
|
||||
warning: calls to `std::mem::forget` with a value that implements `Copy` does nothing
|
||||
--> $DIR/forget_copy.rs:37:5
|
||||
--> $DIR/forgetting_copy_types.rs:37:5
|
||||
|
|
||||
LL | forget(s4);
|
||||
| ^^^^^^^--^
|
||||
@ -45,7 +45,7 @@ LL | forget(s4);
|
||||
= note: use `let _ = ...` to ignore the expression or result
|
||||
|
||||
warning: calls to `std::mem::forget` with a reference instead of an owned value does nothing
|
||||
--> $DIR/forget_copy.rs:38:5
|
||||
--> $DIR/forgetting_copy_types.rs:38:5
|
||||
|
|
||||
LL | forget(s5);
|
||||
| ^^^^^^^--^
|
||||
@ -55,7 +55,7 @@ LL | forget(s5);
|
||||
= note: use `let _ = ...` to ignore the expression or result
|
||||
|
||||
warning: calls to `std::mem::forget` with a reference instead of an owned value does nothing
|
||||
--> $DIR/forget_copy.rs:50:5
|
||||
--> $DIR/forgetting_copy_types.rs:50:5
|
||||
|
|
||||
LL | forget(a2);
|
||||
| ^^^^^^^--^
|
||||
@ -65,7 +65,7 @@ LL | forget(a2);
|
||||
= note: use `let _ = ...` to ignore the expression or result
|
||||
|
||||
warning: calls to `std::mem::forget` with a reference instead of an owned value does nothing
|
||||
--> $DIR/forget_copy.rs:52:5
|
||||
--> $DIR/forgetting_copy_types.rs:52:5
|
||||
|
|
||||
LL | forget(a3);
|
||||
| ^^^^^^^--^
|
||||
@ -75,7 +75,7 @@ LL | forget(a3);
|
||||
= note: use `let _ = ...` to ignore the expression or result
|
||||
|
||||
warning: calls to `std::mem::forget` with a reference instead of an owned value does nothing
|
||||
--> $DIR/forget_copy.rs:53:5
|
||||
--> $DIR/forgetting_copy_types.rs:53:5
|
||||
|
|
||||
LL | forget(a4);
|
||||
| ^^^^^^^--^
|
Loading…
Reference in New Issue
Block a user