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
To my knowledge, the following code is intended to be legal:
fnmain(){letmut buf = String::with_capacity(11);
buf.push_str("hello");let hello:&str = unsafe{&*(buf.as_str()as*const_)};// laundering the lifetime -- we take care that `buf` does not reallocate, so that's okay.
buf.push_str(" world");println!("{}", hello);}
However, Miri currently flags this as UB.
I believe this is #60847, but for String. Discovered while writing this post.