Closed
Description
Code
I tried this code:
union Union {
value: u64,
}
fn main() {
let u = Union { value: 42 };
|| {
unsafe { u.value }
};
}
I expected to see this happen: no error
Instead, this happened: error[E0133]: access to union field is unsafe and requires unsafe function or block
Version it worked on
rustc 1.55.0-nightly 2018 edition
https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=091d060959b30415131533f2e6d93f71
Version with regression
rustc 1.55.0-nightly 2021 edition
https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=091d060959b30415131533f2e6d93f71