Skip to content

Commit aaf1005

Browse files
committed
Auto merge of rust-lang#97652 - RalfJung:cenum_impl_drop_cast, r=nagisa
make cenum_impl_drop_cast deny-by-default Also make it show up as future breakage diagnostic. In rust-lang#96862 we are proposing to change behavior of those drops *again*, so this looks like a good opportunity to increase our pressure on getting them out of the ecosystem. Looking at the [tracking issue](rust-lang#73333), so far nobody spoke up in favor of this (accidental) feature. Cc rust-lang#73333 `@oli-obk`
2 parents c3b7d7b + f6b41e3 commit aaf1005

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

compiler/rustc_lint_defs/src/builtin.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1154,7 +1154,6 @@ declare_lint! {
11541154
/// ### Example
11551155
///
11561156
/// ```compile_fail
1157-
/// #![deny(unaligned_references)]
11581157
/// #[repr(packed)]
11591158
/// pub struct Foo {
11601159
/// field1: u64,
@@ -2614,7 +2613,7 @@ declare_lint! {
26142613
///
26152614
/// ### Example
26162615
///
2617-
/// ```rust
2616+
/// ```compile_fail
26182617
/// # #![allow(unused)]
26192618
/// enum E {
26202619
/// A,
@@ -2650,10 +2649,11 @@ declare_lint! {
26502649
/// [issue #73333]: https://github.com/rust-lang/rust/issues/73333
26512650
/// [`Copy`]: https://doc.rust-lang.org/std/marker/trait.Copy.html
26522651
pub CENUM_IMPL_DROP_CAST,
2653-
Warn,
2652+
Deny,
26542653
"a C-like enum implementing Drop is cast",
26552654
@future_incompatible = FutureIncompatibleInfo {
26562655
reference: "issue #73333 <https://github.com/rust-lang/rust/issues/73333>",
2656+
reason: FutureIncompatibilityReason::FutureReleaseErrorReportNow,
26572657
};
26582658
}
26592659

src/test/run-pass-valgrind/cast-enum-with-dtor.rs

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

33
// check dtor calling order when casting enums.
44

src/test/ui/cenum_impl_drop_cast.stderr

+15
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,18 @@ LL | #![deny(cenum_impl_drop_cast)]
1414

1515
error: aborting due to previous error
1616

17+
Future incompatibility report: Future breakage diagnostic:
18+
error: cannot cast enum `E` into integer `u32` because it implements `Drop`
19+
--> $DIR/cenum_impl_drop_cast.rs:15:13
20+
|
21+
LL | let i = e as u32;
22+
| ^^^^^^^^
23+
|
24+
note: the lint level is defined here
25+
--> $DIR/cenum_impl_drop_cast.rs:1:9
26+
|
27+
LL | #![deny(cenum_impl_drop_cast)]
28+
| ^^^^^^^^^^^^^^^^^^^^
29+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
30+
= note: for more information, see issue #73333 <https://github.com/rust-lang/rust/issues/73333>
31+

0 commit comments

Comments
 (0)