You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Document that it is okay to temporarily have invalid data behind an &mut T #386
As part of this discussion, it seems we have general consensus that "it is acceptable to write bytes through a pointer derived from &mut T even if those bytes make the T invalid so long as the T is made valid again before the lifetime that would be given to the pointer if it were a reference expires and the parent &mut T is usable again."
Specifically, this is fine:
fnmain(){letmut b = false;let ptr = &mut b as*mutboolas*mutu8;unsafe{*ptr = 2;*ptr -= 1;}assert!(b);}
We should probably document this as UCG consensus, and maybe even find a way to get t-lang to sign off on this, though it seems unclear how to best do that.
This is helpful because it means the code in rust-lang/rfcs#2195 is fine without having to weaken the notion of validity of those enums specifically.
Activity
Darksonn commentedon Dec 28, 2022
This seems like it's just a weaker version of #346.
RalfJung commentedon Dec 28, 2022
RalfJung commentedon Jun 6, 2023
Closing in favor of #346