Skip to content

Commit 71f7868

Browse files
authored
Rollup merge of rust-lang#111756 - Urgau:rename_drop_forget_copy_ref_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`
2 parents df8b0df + 6b08a74 commit 71f7868

File tree

65 files changed

+155
-155
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+155
-155
lines changed

compiler/rustc_lint/messages.ftl

+4-4
Original file line numberDiff line numberDiff line change
@@ -521,18 +521,18 @@ lint_opaque_hidden_inferred_bound = opaque type `{$ty}` does not satisfy its ass
521521
522522
lint_opaque_hidden_inferred_bound_sugg = add this bound
523523
524-
lint_drop_ref = calls to `std::mem::drop` with a reference instead of an owned value does nothing
524+
lint_dropping_references = calls to `std::mem::drop` with a reference instead of an owned value does nothing
525525
.label = argument has type `{$arg_ty}`
526526
.note = use `let _ = ...` to ignore the expression or result
527527
528-
lint_drop_copy = calls to `std::mem::drop` with a value that implements `Copy` does nothing
528+
lint_dropping_copy_types = calls to `std::mem::drop` with a value that implements `Copy` does nothing
529529
.label = argument has type `{$arg_ty}`
530530
.note = use `let _ = ...` to ignore the expression or result
531531
532-
lint_forget_ref = calls to `std::mem::forget` with a reference instead of an owned value does nothing
532+
lint_forgetting_references = calls to `std::mem::forget` with a reference instead of an owned value does nothing
533533
.label = argument has type `{$arg_ty}`
534534
.note = use `let _ = ...` to ignore the expression or result
535535
536-
lint_forget_copy = calls to `std::mem::forget` with a value that implements `Copy` does nothing
536+
lint_forgetting_copy_types = calls to `std::mem::forget` with a value that implements `Copy` does nothing
537537
.label = argument has type `{$arg_ty}`
538538
.note = use `let _ = ...` to ignore the expression or result

compiler/rustc_lint/src/drop_forget_useless.rs

+13-13
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use crate::{
77
};
88

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

3737
declare_lint! {
38-
/// The `forget_ref` lint checks for calls to `std::mem::forget` with a reference
38+
/// The `forgetting_references` lint checks for calls to `std::mem::forget` with a reference
3939
/// instead of an owned value.
4040
///
4141
/// ### Example
@@ -52,13 +52,13 @@ declare_lint! {
5252
/// Calling `forget` on a reference will only forget the
5353
/// reference itself, which is a no-op. It will not forget the underlying
5454
/// referenced value, which is likely what was intended.
55-
pub FORGET_REF,
55+
pub FORGETTING_REFERENCES,
5656
Warn,
5757
"calls to `std::mem::forget` with a reference instead of an owned value"
5858
}
5959

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

8484
declare_lint! {
85-
/// The `forget_copy` lint checks for calls to `std::mem::forget` with a value
85+
/// The `forgetting_copy_types` lint checks for calls to `std::mem::forget` with a value
8686
/// that derives the Copy trait.
8787
///
8888
/// ### Example
@@ -104,12 +104,12 @@ declare_lint! {
104104
/// An alternative, but also valid, explanation is that Copy types do not
105105
/// implement the Drop trait, which means they have no destructors. Without a
106106
/// destructor, there is nothing for `std::mem::forget` to ignore.
107-
pub FORGET_COPY,
107+
pub FORGETTING_COPY_TYPES,
108108
Warn,
109109
"calls to `std::mem::forget` with a value that implements Copy"
110110
}
111111

112-
declare_lint_pass!(DropForgetUseless => [DROP_REF, FORGET_REF, DROP_COPY, FORGET_COPY]);
112+
declare_lint_pass!(DropForgetUseless => [DROPPING_REFERENCES, FORGETTING_REFERENCES, DROPPING_COPY_TYPES, FORGETTING_COPY_TYPES]);
113113

114114
impl<'tcx> LateLintPass<'tcx> for DropForgetUseless {
115115
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) {
@@ -123,16 +123,16 @@ impl<'tcx> LateLintPass<'tcx> for DropForgetUseless {
123123
let drop_is_single_call_in_arm = is_single_call_in_arm(cx, arg, expr);
124124
match fn_name {
125125
sym::mem_drop if arg_ty.is_ref() && !drop_is_single_call_in_arm => {
126-
cx.emit_spanned_lint(DROP_REF, expr.span, DropRefDiag { arg_ty, label: arg.span });
126+
cx.emit_spanned_lint(DROPPING_REFERENCES, expr.span, DropRefDiag { arg_ty, label: arg.span });
127127
},
128128
sym::mem_forget if arg_ty.is_ref() => {
129-
cx.emit_spanned_lint(FORGET_REF, expr.span, ForgetRefDiag { arg_ty, label: arg.span });
129+
cx.emit_spanned_lint(FORGETTING_REFERENCES, expr.span, ForgetRefDiag { arg_ty, label: arg.span });
130130
},
131131
sym::mem_drop if is_copy && !drop_is_single_call_in_arm => {
132-
cx.emit_spanned_lint(DROP_COPY, expr.span, DropCopyDiag { arg_ty, label: arg.span });
132+
cx.emit_spanned_lint(DROPPING_COPY_TYPES, expr.span, DropCopyDiag { arg_ty, label: arg.span });
133133
}
134134
sym::mem_forget if is_copy => {
135-
cx.emit_spanned_lint(FORGET_COPY, expr.span, ForgetCopyDiag { arg_ty, label: arg.span });
135+
cx.emit_spanned_lint(FORGETTING_COPY_TYPES, expr.span, ForgetCopyDiag { arg_ty, label: arg.span });
136136
}
137137
_ => return,
138138
};

compiler/rustc_lint/src/lints.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -662,9 +662,9 @@ pub struct ForLoopsOverFalliblesSuggestion<'a> {
662662
pub end_span: Span,
663663
}
664664

665-
// drop_ref.rs
665+
// drop_forget_useless.rs
666666
#[derive(LintDiagnostic)]
667-
#[diag(lint_drop_ref)]
667+
#[diag(lint_dropping_references)]
668668
#[note]
669669
pub struct DropRefDiag<'a> {
670670
pub arg_ty: Ty<'a>,
@@ -673,7 +673,7 @@ pub struct DropRefDiag<'a> {
673673
}
674674

675675
#[derive(LintDiagnostic)]
676-
#[diag(lint_drop_copy)]
676+
#[diag(lint_dropping_copy_types)]
677677
#[note]
678678
pub struct DropCopyDiag<'a> {
679679
pub arg_ty: Ty<'a>,
@@ -682,7 +682,7 @@ pub struct DropCopyDiag<'a> {
682682
}
683683

684684
#[derive(LintDiagnostic)]
685-
#[diag(lint_forget_ref)]
685+
#[diag(lint_forgetting_references)]
686686
#[note]
687687
pub struct ForgetRefDiag<'a> {
688688
pub arg_ty: Ty<'a>,
@@ -691,7 +691,7 @@ pub struct ForgetRefDiag<'a> {
691691
}
692692

693693
#[derive(LintDiagnostic)]
694-
#[diag(lint_forget_copy)]
694+
#[diag(lint_forgetting_copy_types)]
695695
#[note]
696696
pub struct ForgetCopyDiag<'a> {
697697
pub arg_ty: Ty<'a>,

library/core/src/mem/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -968,7 +968,7 @@ pub const fn replace<T>(dest: &mut T, src: T) -> T {
968968
/// Integers and other types implementing [`Copy`] are unaffected by `drop`.
969969
///
970970
/// ```
971-
/// # #![cfg_attr(not(bootstrap), allow(drop_copy))]
971+
/// # #![cfg_attr(not(bootstrap), allow(dropping_copy_types))]
972972
/// #[derive(Copy, Clone)]
973973
/// struct Foo(u8);
974974
///

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ impl<'tcx> LateLintPass<'tcx> for DropForgetRef {
9898
let is_copy = is_copy(cx, arg_ty);
9999
let drop_is_single_call_in_arm = is_single_call_in_arm(cx, arg, expr);
100100
let (lint, msg) = match fn_name {
101-
// early return for uplifted lints: drop_ref, drop_copy, forget_ref, forget_copy
101+
// early return for uplifted lints: dropping_references, dropping_copy_types, forgetting_references, forgetting_copy_types
102102
sym::mem_drop if arg_ty.is_ref() && !drop_is_single_call_in_arm => return,
103103
sym::mem_forget if arg_ty.is_ref() => return,
104104
sym::mem_drop if is_copy && !drop_is_single_call_in_arm => return,

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ pub static RENAMED_LINTS: &[(&str, &str)] = &[
3333
("clippy::zero_width_space", "clippy::invisible_characters"),
3434
("clippy::clone_double_ref", "suspicious_double_ref_op"),
3535
("clippy::drop_bounds", "drop_bounds"),
36-
("clippy::drop_copy", "drop_copy"),
37-
("clippy::drop_ref", "drop_ref"),
36+
("clippy::drop_copy", "dropping_copy_types"),
37+
("clippy::drop_ref", "dropping_references"),
3838
("clippy::for_loop_over_option", "for_loops_over_fallibles"),
3939
("clippy::for_loop_over_result", "for_loops_over_fallibles"),
4040
("clippy::for_loops_over_fallibles", "for_loops_over_fallibles"),
41-
("clippy::forget_copy", "forget_copy"),
42-
("clippy::forget_ref", "forget_ref"),
41+
("clippy::forget_copy", "forgetting_copy_types"),
42+
("clippy::forget_ref", "forgetting_references"),
4343
("clippy::into_iter_on_array", "array_into_iter"),
4444
("clippy::invalid_atomic_ordering", "invalid_atomic_ordering"),
4545
("clippy::invalid_ref", "invalid_value"),

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::mem as memstuff;
55
use std::mem::forget as forgetSomething;
66

77
#[warn(clippy::mem_forget)]
8-
#[allow(forget_copy)]
8+
#[allow(forgetting_copy_types)]
99
fn main() {
1010
let five: i32 = 5;
1111
forgetSomething(five);

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#![allow(unused)]
33
#![allow(deref_nullptr)]
44
#![allow(clippy::unnecessary_operation)]
5-
#![allow(drop_copy)]
5+
#![allow(dropping_copy_types)]
66
#![warn(clippy::multiple_unsafe_ops_per_block)]
77

88
extern crate proc_macros;

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

+8-8
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@
3030
#![allow(clippy::invisible_characters)]
3131
#![allow(suspicious_double_ref_op)]
3232
#![allow(drop_bounds)]
33-
#![allow(drop_copy)]
34-
#![allow(drop_ref)]
33+
#![allow(dropping_copy_types)]
34+
#![allow(dropping_references)]
3535
#![allow(for_loops_over_fallibles)]
36-
#![allow(forget_copy)]
37-
#![allow(forget_ref)]
36+
#![allow(forgetting_copy_types)]
37+
#![allow(forgetting_references)]
3838
#![allow(array_into_iter)]
3939
#![allow(invalid_atomic_ordering)]
4040
#![allow(invalid_value)]
@@ -77,13 +77,13 @@
7777
#![warn(clippy::invisible_characters)]
7878
#![warn(suspicious_double_ref_op)]
7979
#![warn(drop_bounds)]
80-
#![warn(drop_copy)]
81-
#![warn(drop_ref)]
80+
#![warn(dropping_copy_types)]
81+
#![warn(dropping_references)]
8282
#![warn(for_loops_over_fallibles)]
8383
#![warn(for_loops_over_fallibles)]
8484
#![warn(for_loops_over_fallibles)]
85-
#![warn(forget_copy)]
86-
#![warn(forget_ref)]
85+
#![warn(forgetting_copy_types)]
86+
#![warn(forgetting_references)]
8787
#![warn(array_into_iter)]
8888
#![warn(invalid_atomic_ordering)]
8989
#![warn(invalid_value)]

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@
3030
#![allow(clippy::invisible_characters)]
3131
#![allow(suspicious_double_ref_op)]
3232
#![allow(drop_bounds)]
33-
#![allow(drop_copy)]
34-
#![allow(drop_ref)]
33+
#![allow(dropping_copy_types)]
34+
#![allow(dropping_references)]
3535
#![allow(for_loops_over_fallibles)]
36-
#![allow(forget_copy)]
37-
#![allow(forget_ref)]
36+
#![allow(forgetting_copy_types)]
37+
#![allow(forgetting_references)]
3838
#![allow(array_into_iter)]
3939
#![allow(invalid_atomic_ordering)]
4040
#![allow(invalid_value)]

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

+8-8
Original file line numberDiff line numberDiff line change
@@ -186,17 +186,17 @@ error: lint `clippy::drop_bounds` has been renamed to `drop_bounds`
186186
LL | #![warn(clippy::drop_bounds)]
187187
| ^^^^^^^^^^^^^^^^^^^ help: use the new name: `drop_bounds`
188188

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

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

201201
error: lint `clippy::for_loop_over_option` has been renamed to `for_loops_over_fallibles`
202202
--> $DIR/rename.rs:82:9
@@ -216,17 +216,17 @@ error: lint `clippy::for_loops_over_fallibles` has been renamed to `for_loops_ov
216216
LL | #![warn(clippy::for_loops_over_fallibles)]
217217
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `for_loops_over_fallibles`
218218

219-
error: lint `clippy::forget_copy` has been renamed to `forget_copy`
219+
error: lint `clippy::forget_copy` has been renamed to `forgetting_copy_types`
220220
--> $DIR/rename.rs:85:9
221221
|
222222
LL | #![warn(clippy::forget_copy)]
223-
| ^^^^^^^^^^^^^^^^^^^ help: use the new name: `forget_copy`
223+
| ^^^^^^^^^^^^^^^^^^^ help: use the new name: `forgetting_copy_types`
224224

225-
error: lint `clippy::forget_ref` has been renamed to `forget_ref`
225+
error: lint `clippy::forget_ref` has been renamed to `forgetting_references`
226226
--> $DIR/rename.rs:86:9
227227
|
228228
LL | #![warn(clippy::forget_ref)]
229-
| ^^^^^^^^^^^^^^^^^^ help: use the new name: `forget_ref`
229+
| ^^^^^^^^^^^^^^^^^^ help: use the new name: `forgetting_references`
230230

231231
error: lint `clippy::into_iter_on_array` has been renamed to `array_into_iter`
232232
--> $DIR/rename.rs:87:9

src/tools/miri/tests/fail/stacked_borrows/illegal_write2.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![allow(drop_ref)]
1+
#![allow(dropping_references)]
22

33
fn main() {
44
let target = &mut 42;

src/tools/miri/tests/fail/uninit_buffer.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//@error-in-other-file: memory is uninitialized at [0x4..0x10]
22

3-
#![allow(drop_copy)]
3+
#![allow(dropping_copy_types)]
44

55
use std::alloc::{alloc, dealloc, Layout};
66
use std::slice::from_raw_parts;

src/tools/miri/tests/fail/uninit_buffer_with_provenance.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//@error-in-other-file: memory is uninitialized at [0x4..0x8]
22
//@normalize-stderr-test: "a[0-9]+" -> "ALLOC"
33
#![feature(strict_provenance)]
4-
#![allow(drop_copy)]
4+
#![allow(dropping_copy_types)]
55

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

src/tools/miri/tests/pass/stacked-borrows/zst-field-retagging-terminates.rs

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

4-
#![allow(drop_copy)]
4+
#![allow(dropping_copy_types)]
55

66
fn main() {
77
let array = [(); usize::MAX];

tests/ui/associated-inherent-types/inference.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
#![feature(inherent_associated_types)]
55
#![allow(incomplete_features)]
6-
#![allow(drop_copy)]
6+
#![allow(dropping_copy_types)]
77

88
use std::convert::identity;
99

tests/ui/borrowck/borrowck-closures-slice-patterns-ok.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Check that closure captures for slice patterns are inferred correctly
22

33
#![allow(unused_variables)]
4-
#![allow(drop_ref)]
4+
#![allow(dropping_references)]
55

66
// run-pass
77

tests/ui/borrowck/borrowck-field-sensitivity-rpass.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// run-pass
22
#![allow(unused_mut)]
33
#![allow(unused_variables)]
4-
#![allow(drop_copy)]
4+
#![allow(dropping_copy_types)]
55
// pretty-expanded FIXME #23616
66

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

tests/ui/borrowck/borrowck-use-mut-borrow-rpass.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// run-pass
22
// pretty-expanded FIXME #23616
33

4-
#![allow(drop_copy)]
4+
#![allow(dropping_copy_types)]
55

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

tests/ui/closures/2229_closure_analysis/migrations/issue-78720.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// run-pass
22

33
#![warn(rust_2021_incompatible_closure_captures)]
4-
#![allow(drop_ref, drop_copy)]
4+
#![allow(dropping_references, dropping_copy_types)]
55

66
fn main() {
77
if let a = "" {

tests/ui/closures/2229_closure_analysis/optimization/edge_case_run_pass.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
#![allow(unused)]
55
#![allow(dead_code)]
6-
#![allow(drop_ref)]
6+
#![allow(dropping_references)]
77

88
struct Int(i32);
99
struct B<'a>(&'a i32);

tests/ui/closures/2229_closure_analysis/run_pass/drop_then_use_fake_reads.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// check-pass
33

44
#![feature(rustc_attrs)]
5-
#![allow(drop_ref)]
5+
#![allow(dropping_references)]
66

77
fn main() {
88
let mut x = 1;

0 commit comments

Comments
 (0)