Skip to content

Commit

Permalink
Rollup merge of rust-lang#111756 - Urgau:rename_drop_forget_copy_ref_…
Browse files Browse the repository at this point in the history
…lints, r=fee1-dead

Rename `{drop,forget}_{copy,ref}` lints to more consistent naming

This PR renames previous uplifted lints in rust-lang#109732 to more consistent naming.

I followed the renaming done [here](rust-lang#53224) and also advocated in this [clippy issue](rust-lang/rust-clippy#2845):
   - `drop_copy` to `dropping_copy_types`
   - `forget_copy` to `forgetting_copy_types`
   - `drop_ref` to `dropping_references`
   - `forget_ref` to `forgetting_references`
  • Loading branch information
Dylan-DPC authored May 22, 2023
2 parents df8b0df + 6b08a74 commit 71f7868
Show file tree
Hide file tree
Showing 65 changed files with 155 additions and 155 deletions.
8 changes: 4 additions & 4 deletions compiler/rustc_lint/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -521,18 +521,18 @@ lint_opaque_hidden_inferred_bound = opaque type `{$ty}` does not satisfy its ass
lint_opaque_hidden_inferred_bound_sugg = add this bound
lint_drop_ref = calls to `std::mem::drop` with a reference instead of an owned value does nothing
lint_dropping_references = calls to `std::mem::drop` with a reference instead of an owned value does nothing
.label = argument has type `{$arg_ty}`
.note = use `let _ = ...` to ignore the expression or result
lint_drop_copy = calls to `std::mem::drop` with a value that implements `Copy` does nothing
lint_dropping_copy_types = calls to `std::mem::drop` with a value that implements `Copy` does nothing
.label = argument has type `{$arg_ty}`
.note = use `let _ = ...` to ignore the expression or result
lint_forget_ref = calls to `std::mem::forget` with a reference instead of an owned value does nothing
lint_forgetting_references = calls to `std::mem::forget` with a reference instead of an owned value does nothing
.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
26 changes: 13 additions & 13 deletions compiler/rustc_lint/src/drop_forget_useless.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::{
};

declare_lint! {
/// The `drop_ref` lint checks for calls to `std::mem::drop` with a reference
/// The `dropping_references` lint checks for calls to `std::mem::drop` with a reference
/// instead of an owned value.
///
/// ### Example
Expand All @@ -29,13 +29,13 @@ declare_lint! {
/// reference itself, which is a no-op. It will not call the `drop` method (from
/// the `Drop` trait implementation) on the underlying referenced value, which
/// is likely what was intended.
pub DROP_REF,
pub DROPPING_REFERENCES,
Warn,
"calls to `std::mem::drop` with a reference instead of an owned value"
}

declare_lint! {
/// The `forget_ref` lint checks for calls to `std::mem::forget` with a reference
/// The `forgetting_references` lint checks for calls to `std::mem::forget` with a reference
/// instead of an owned value.
///
/// ### Example
Expand All @@ -52,13 +52,13 @@ declare_lint! {
/// Calling `forget` on a reference will only forget the
/// reference itself, which is a no-op. It will not forget the underlying
/// referenced value, which is likely what was intended.
pub FORGET_REF,
pub FORGETTING_REFERENCES,
Warn,
"calls to `std::mem::forget` with a reference instead of an owned value"
}

declare_lint! {
/// The `drop_copy` lint checks for calls to `std::mem::drop` with a value
/// The `dropping_copy_types` lint checks for calls to `std::mem::drop` with a value
/// that derives the Copy trait.
///
/// ### Example
Expand All @@ -76,13 +76,13 @@ declare_lint! {
/// Calling `std::mem::drop` [does nothing for types that
/// implement Copy](https://doc.rust-lang.org/std/mem/fn.drop.html), since the
/// value will be copied and moved into the function on invocation.
pub DROP_COPY,
pub DROPPING_COPY_TYPES,
Warn,
"calls to `std::mem::drop` with a value that implements Copy"
}

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
Expand All @@ -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, DROP_COPY, FORGET_COPY]);
declare_lint_pass!(DropForgetUseless => [DROPPING_REFERENCES, FORGETTING_REFERENCES, DROPPING_COPY_TYPES, FORGETTING_COPY_TYPES]);

impl<'tcx> LateLintPass<'tcx> for DropForgetUseless {
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) {
Expand All @@ -123,16 +123,16 @@ impl<'tcx> LateLintPass<'tcx> for DropForgetUseless {
let drop_is_single_call_in_arm = is_single_call_in_arm(cx, arg, expr);
match fn_name {
sym::mem_drop if arg_ty.is_ref() && !drop_is_single_call_in_arm => {
cx.emit_spanned_lint(DROP_REF, expr.span, DropRefDiag { arg_ty, label: arg.span });
cx.emit_spanned_lint(DROPPING_REFERENCES, expr.span, DropRefDiag { arg_ty, label: arg.span });
},
sym::mem_forget if arg_ty.is_ref() => {
cx.emit_spanned_lint(FORGET_REF, expr.span, ForgetRefDiag { arg_ty, label: arg.span });
cx.emit_spanned_lint(FORGETTING_REFERENCES, expr.span, ForgetRefDiag { arg_ty, label: arg.span });
},
sym::mem_drop if is_copy && !drop_is_single_call_in_arm => {
cx.emit_spanned_lint(DROP_COPY, expr.span, DropCopyDiag { arg_ty, label: arg.span });
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,
};
Expand Down
10 changes: 5 additions & 5 deletions compiler/rustc_lint/src/lints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -662,9 +662,9 @@ pub struct ForLoopsOverFalliblesSuggestion<'a> {
pub end_span: Span,
}

// drop_ref.rs
// drop_forget_useless.rs
#[derive(LintDiagnostic)]
#[diag(lint_drop_ref)]
#[diag(lint_dropping_references)]
#[note]
pub struct DropRefDiag<'a> {
pub arg_ty: Ty<'a>,
Expand All @@ -673,7 +673,7 @@ pub struct DropRefDiag<'a> {
}

#[derive(LintDiagnostic)]
#[diag(lint_drop_copy)]
#[diag(lint_dropping_copy_types)]
#[note]
pub struct DropCopyDiag<'a> {
pub arg_ty: Ty<'a>,
Expand All @@ -682,7 +682,7 @@ pub struct DropCopyDiag<'a> {
}

#[derive(LintDiagnostic)]
#[diag(lint_forget_ref)]
#[diag(lint_forgetting_references)]
#[note]
pub struct ForgetRefDiag<'a> {
pub arg_ty: Ty<'a>,
Expand All @@ -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>,
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/mem/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -968,7 +968,7 @@ pub const fn replace<T>(dest: &mut T, src: T) -> T {
/// Integers and other types implementing [`Copy`] are unaffected by `drop`.
///
/// ```
/// # #![cfg_attr(not(bootstrap), allow(drop_copy))]
/// # #![cfg_attr(not(bootstrap), allow(dropping_copy_types))]
/// #[derive(Copy, Clone)]
/// struct Foo(u8);
///
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/clippy_lints/src/drop_forget_ref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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, drop_copy, forget_ref, forget_copy
// early return for uplifted lints: dropping_references, dropping_copy_types, forgetting_references, 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,
Expand Down
8 changes: 4 additions & 4 deletions src/tools/clippy/clippy_lints/src/renamed_lints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ pub static RENAMED_LINTS: &[(&str, &str)] = &[
("clippy::zero_width_space", "clippy::invisible_characters"),
("clippy::clone_double_ref", "suspicious_double_ref_op"),
("clippy::drop_bounds", "drop_bounds"),
("clippy::drop_copy", "drop_copy"),
("clippy::drop_ref", "drop_ref"),
("clippy::drop_copy", "dropping_copy_types"),
("clippy::drop_ref", "dropping_references"),
("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_ref", "forget_ref"),
("clippy::forget_copy", "forgetting_copy_types"),
("clippy::forget_ref", "forgetting_references"),
("clippy::into_iter_on_array", "array_into_iter"),
("clippy::invalid_atomic_ordering", "invalid_atomic_ordering"),
("clippy::invalid_ref", "invalid_value"),
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/tests/ui/mem_forget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/tests/ui/multiple_unsafe_ops_per_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#![allow(unused)]
#![allow(deref_nullptr)]
#![allow(clippy::unnecessary_operation)]
#![allow(drop_copy)]
#![allow(dropping_copy_types)]
#![warn(clippy::multiple_unsafe_ops_per_block)]

extern crate proc_macros;
Expand Down
16 changes: 8 additions & 8 deletions src/tools/clippy/tests/ui/rename.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@
#![allow(clippy::invisible_characters)]
#![allow(suspicious_double_ref_op)]
#![allow(drop_bounds)]
#![allow(drop_copy)]
#![allow(drop_ref)]
#![allow(dropping_copy_types)]
#![allow(dropping_references)]
#![allow(for_loops_over_fallibles)]
#![allow(forget_copy)]
#![allow(forget_ref)]
#![allow(forgetting_copy_types)]
#![allow(forgetting_references)]
#![allow(array_into_iter)]
#![allow(invalid_atomic_ordering)]
#![allow(invalid_value)]
Expand Down Expand Up @@ -77,13 +77,13 @@
#![warn(clippy::invisible_characters)]
#![warn(suspicious_double_ref_op)]
#![warn(drop_bounds)]
#![warn(drop_copy)]
#![warn(drop_ref)]
#![warn(dropping_copy_types)]
#![warn(dropping_references)]
#![warn(for_loops_over_fallibles)]
#![warn(for_loops_over_fallibles)]
#![warn(for_loops_over_fallibles)]
#![warn(forget_copy)]
#![warn(forget_ref)]
#![warn(forgetting_copy_types)]
#![warn(forgetting_references)]
#![warn(array_into_iter)]
#![warn(invalid_atomic_ordering)]
#![warn(invalid_value)]
Expand Down
8 changes: 4 additions & 4 deletions src/tools/clippy/tests/ui/rename.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@
#![allow(clippy::invisible_characters)]
#![allow(suspicious_double_ref_op)]
#![allow(drop_bounds)]
#![allow(drop_copy)]
#![allow(drop_ref)]
#![allow(dropping_copy_types)]
#![allow(dropping_references)]
#![allow(for_loops_over_fallibles)]
#![allow(forget_copy)]
#![allow(forget_ref)]
#![allow(forgetting_copy_types)]
#![allow(forgetting_references)]
#![allow(array_into_iter)]
#![allow(invalid_atomic_ordering)]
#![allow(invalid_value)]
Expand Down
16 changes: 8 additions & 8 deletions src/tools/clippy/tests/ui/rename.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -186,17 +186,17 @@ error: lint `clippy::drop_bounds` has been renamed to `drop_bounds`
LL | #![warn(clippy::drop_bounds)]
| ^^^^^^^^^^^^^^^^^^^ help: use the new name: `drop_bounds`

error: lint `clippy::drop_copy` has been renamed to `drop_copy`
error: lint `clippy::drop_copy` has been renamed to `dropping_copy_types`
--> $DIR/rename.rs:80:9
|
LL | #![warn(clippy::drop_copy)]
| ^^^^^^^^^^^^^^^^^ help: use the new name: `drop_copy`
| ^^^^^^^^^^^^^^^^^ help: use the new name: `dropping_copy_types`

error: lint `clippy::drop_ref` has been renamed to `drop_ref`
error: lint `clippy::drop_ref` has been renamed to `dropping_references`
--> $DIR/rename.rs:81:9
|
LL | #![warn(clippy::drop_ref)]
| ^^^^^^^^^^^^^^^^ help: use the new name: `drop_ref`
| ^^^^^^^^^^^^^^^^ help: use the new name: `dropping_references`

error: lint `clippy::for_loop_over_option` has been renamed to `for_loops_over_fallibles`
--> $DIR/rename.rs:82:9
Expand All @@ -216,17 +216,17 @@ 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`
error: lint `clippy::forget_ref` has been renamed to `forgetting_references`
--> $DIR/rename.rs:86:9
|
LL | #![warn(clippy::forget_ref)]
| ^^^^^^^^^^^^^^^^^^ help: use the new name: `forget_ref`
| ^^^^^^^^^^^^^^^^^^ help: use the new name: `forgetting_references`

error: lint `clippy::into_iter_on_array` has been renamed to `array_into_iter`
--> $DIR/rename.rs:87:9
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(drop_ref)]
#![allow(dropping_references)]

fn main() {
let target = &mut 42;
Expand Down
2 changes: 1 addition & 1 deletion src/tools/miri/tests/fail/uninit_buffer.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//@error-in-other-file: memory is uninitialized at [0x4..0x10]

#![allow(drop_copy)]
#![allow(dropping_copy_types)]

use std::alloc::{alloc, dealloc, Layout};
use std::slice::from_raw_parts;
Expand Down
2 changes: 1 addition & 1 deletion src/tools/miri/tests/fail/uninit_buffer_with_provenance.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//@error-in-other-file: memory is uninitialized at [0x4..0x8]
//@normalize-stderr-test: "a[0-9]+" -> "ALLOC"
#![feature(strict_provenance)]
#![allow(drop_copy)]
#![allow(dropping_copy_types)]

// Test printing allocations that contain single-byte provenance.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//@compile-flags: -Zmiri-retag-fields
// Checks that the test does not run forever (which relies on a fast path).

#![allow(drop_copy)]
#![allow(dropping_copy_types)]

fn main() {
let array = [(); usize::MAX];
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/associated-inherent-types/inference.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#![feature(inherent_associated_types)]
#![allow(incomplete_features)]
#![allow(drop_copy)]
#![allow(dropping_copy_types)]

use std::convert::identity;

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/borrowck/borrowck-closures-slice-patterns-ok.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Check that closure captures for slice patterns are inferred correctly

#![allow(unused_variables)]
#![allow(drop_ref)]
#![allow(dropping_references)]

// run-pass

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/borrowck/borrowck-field-sensitivity-rpass.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// run-pass
#![allow(unused_mut)]
#![allow(unused_variables)]
#![allow(drop_copy)]
#![allow(dropping_copy_types)]
// pretty-expanded FIXME #23616

struct A { a: isize, b: Box<isize> }
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/borrowck/borrowck-use-mut-borrow-rpass.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// run-pass
// pretty-expanded FIXME #23616

#![allow(drop_copy)]
#![allow(dropping_copy_types)]

struct A { a: isize, b: Box<isize> }

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// run-pass

#![warn(rust_2021_incompatible_closure_captures)]
#![allow(drop_ref, drop_copy)]
#![allow(dropping_references, dropping_copy_types)]

fn main() {
if let a = "" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#![allow(unused)]
#![allow(dead_code)]
#![allow(drop_ref)]
#![allow(dropping_references)]

struct Int(i32);
struct B<'a>(&'a i32);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// check-pass

#![feature(rustc_attrs)]
#![allow(drop_ref)]
#![allow(dropping_references)]

fn main() {
let mut x = 1;
Expand Down
Loading

0 comments on commit 71f7868

Please sign in to comment.