diff --git a/src/doc/rustc/src/lints/index.md b/src/doc/rustc/src/lints/index.md index 029c9edc1b5fe..0566bf631cf9e 100644 --- a/src/doc/rustc/src/lints/index.md +++ b/src/doc/rustc/src/lints/index.md @@ -39,19 +39,38 @@ provides detailed information and an opportunity for feedback. This gives users some time to fix the code to accommodate the change. After some time, the warning may become an error. -The following is an example of what a future-incompatible looks like: +The following is an example of what future-incompatible code looks like: + +```rust,compile_fail +#![allow(unused)] +enum E { + A, +} +impl Drop for E { + fn drop(&mut self) { + println!("Drop"); + } +} + +#[allow(cenum_impl_drop_cast)] +fn main() { + let e = E::A; + let i = e as u32; +} +``` + +This will produce the following warning: ```text -warning: borrow of packed field is unsafe and requires unsafe function or block (error E0133) - --> lint_example.rs:11:13 - | -11 | let y = &x.data.0; - | ^^^^^^^^^ - | - = note: `#[warn(safe_packed_borrows)]` on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #46043 - = note: fields of packed structs might be misaligned: dereferencing a misaligned pointer or even just creating a misaligned reference is undefined behavior +> warning: cannot cast enum `E` into integer `u32` because it implements `Drop` +> --> src/main.rs:14:13 +> | +> 14 | let i = e as u32; +> | ^^^^^^^^ +> | +> = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! +> = note: for more information, see issue #73333 +> ``` For more information about the process and policy of future-incompatible