-
-
Notifications
You must be signed in to change notification settings - Fork 14.3k
Open
Labels
A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Constant evaluation, covers all const contexts (static, const fn, ...)A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.Category: This is a bug.T-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
The following example passes the static const checks, reaching const-eval and erroring post-monomorphization. I need to figure out what's going wrong here before const_mut_refs is stabilized.
cc #57349
#![feature(const_raw_ptr_deref, const_mut_refs)]
#![allow(unused)]
use std::cell::UnsafeCell;
struct Foo(UnsafeCell<u32>);
unsafe impl Send for Foo {}
unsafe impl Sync for Foo {}
static FOO: Foo = Foo(UnsafeCell::new(42));
static BAR: () = unsafe {
*FOO.0.get() = 5; //~ ERROR
};
fn main() {}Errors:
Compiling playground v0.0.1 (/playground)
error[E0080]: could not evaluate static initializer
--> src/main.rs:14:5
|
14 | *FOO.0.get() = 5; //~ ERROR
| ^^^^^^^^^^^^^^^^ modifying a static's initial value from another static's initializer
error: aborting due to previous error
For more information about this error, try `rustc --explain E0080`.
error: could not compile `playground`
To learn more, run the command again with --verbose.
Metadata
Metadata
Assignees
Labels
A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Constant evaluation, covers all const contexts (static, const fn, ...)A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.Category: This is a bug.T-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.