Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 30 additions & 11 deletions src/doc/rustc/src/lints/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://github.com/rust-lang/rust/issues/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 <https://github.com/rust-lang/rust/issues/73333>
>
```

For more information about the process and policy of future-incompatible
Expand Down