-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-NLLArea: Non-lexical lifetimes (NLL)Area: Non-lexical lifetimes (NLL)F-thread_local`#![feature(thread_local)]``#![feature(thread_local)]`NLL-soundWorking towards the "invalid code does not compile" goalWorking towards the "invalid code does not compile" goalP-mediumMedium priorityMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way.This issue requires a nightly compiler in some way.
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;
}
}
schneiderfelipejoseluis
Metadata
Metadata
Assignees
Labels
A-NLLArea: Non-lexical lifetimes (NLL)Area: Non-lexical lifetimes (NLL)F-thread_local`#![feature(thread_local)]``#![feature(thread_local)]`NLL-soundWorking towards the "invalid code does not compile" goalWorking towards the "invalid code does not compile" goalP-mediumMedium priorityMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way.This issue requires a nightly compiler in some way.