Rust mutable union allows write to field w/o needing unsafe block in stable ( Documentation issue? ) #2095
Labels
T-lang
Relevant to the language team, which will review and decide on the RFC.
https://play.rust-lang.org/?gist=beaba7cc10b93f3e6ac1d97717099f26&version=undefined
The code produces a warning:
Saying the unsafe block is not needed for a write.
But the rfc says writes to union mutable fields require a unsafe block
https://github.com/rust-lang/rfcs/blob/master/text/1444-union.md#writing-fields
Found here:
https://www.reddit.com/r/rust/comments/6rcegm/unsafe_field_accesses_for_unions/
On second reading, the RFC says "May" which is not the same as "Shall". Which seems weird. Do you HAVE to use unsafe code to write mutable union fields? Is it optional? When is it needed/not needed?
The text was updated successfully, but these errors were encountered: