- Notifications
You must be signed in to change notification settings - Fork 14k
Open
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsT-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.
Description
Code
static DANGLING: &mut () = unsafe { &mut *(1 as *mut ()) }; const WUT: &mut () = DANGLING;Current output
error[E0596]: cannot borrow `*DANGLING` as mutable, as `DANGLING` is an immutable static item --> src/lib.rs:2:22 | 2 | const WUT: &mut () = DANGLING; | ^^^^^^^^ cannot borrow as mutable For more information about this error, try `rustc --explain E0596`. error: could not compile `playground` (lib) due to 1 previous errorDesired output
Mention the fact that &mut T doesn't implement Copy.Rationale and extra context
Found while investigating #140123
Other cases
Rust Version
Reproducible on the playground with version 1.89.0-nightly (2025-06-11 e703dff8fe220b78195c)Anything else?
No response
estebank
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsT-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.