Open
Description
Spinning off from #51269:
The MIR borrow checker (i.e., NLL) permits #[thread_local] static mut
to have 'static
lifetime. This is probably a bug. It arises because we ignore borrows of "unsafe places", which includes static mut
.
We probably ought to stop doing that — at least not ignoring them entirely — but if we do so, we have to ensure that we continue to accept overlapping borrows of static mut
(even though that is basically guaranteed UB), since it compiles today:
fn main() {
static mut X: usize = 22;
unsafe {
let p = &mut X;
let q = &mut X;
*p += 1;
*q += 1;
*p += 1;
}
}