Skip to content

Instantly share code, notes, and snippets.

@pnkfelix
Last active December 10, 2019 13:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pnkfelix/ae03d3ea95160fb71a797b15e05f8d49 to your computer and use it in GitHub Desktop.
Save pnkfelix/ae03d3ea95160fb71a797b15e05f8d49 to your computer and use it in GitHub Desktop.
brash: future incompat issue

This crate currently triggers a future incompatibility warning with Rust.

In src/lib.rs:13:9, there is the following code:

let y = &x.data.0;

This causes rustc to issue the following diagnostic, from rust-lang/rust#46043

warning: borrow of packed field is unsafe and requires unsafe function or block (error E0133)
  --> src/lib.rs:13:9
   |
13 | 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

Since this construct is going to become a hard error in the future, we should eliminate occurrences of it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment