Closed
Description
Code
extern "C" {
static FOO: i32;
}
const BAR: i32 = FOO;
Current output
error[E0080]: evaluation of constant value failed
--> src/lib.rs:5:18
|
5 | const BAR: i32 = FOO;
| ^^^ cannot access extern static (DefId(0:4 ~ playground[6412]::{extern#0}::FOO))
error[E0133]: use of extern static is unsafe and requires unsafe function or block
--> src/lib.rs:5:18
|
5 | const BAR: i32 = FOO;
| ^^^ use of extern static
|
= note: extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior
Some errors have detailed explanations: E0080, E0133.
For more information about an error, try `rustc --explain E0080`.
Desired output
error[E0080]: evaluation of constant value failed
--> src/lib.rs:5:18
|
5 | const BAR: i32 = FOO;
| ^^^ cannot access extern static
error[E0133]: use of extern static is unsafe and requires unsafe function or block
--> src/lib.rs:5:18
|
5 | const BAR: i32 = FOO;
| ^^^ use of extern static
|
= note: extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior
Some errors have detailed explanations: E0080, E0133.
For more information about an error, try `rustc --explain E0080`.
Rationale and extra context
No response
Other cases
Rust Version
rustc 1.85.1 (4eb161250 2025-03-15)
binary: rustc
commit-hash: 4eb161250e340c8f48f66e2b929ef4a5bed7c181
commit-date: 2025-03-15
host: x86_64-unknown-linux-gnu
release: 1.85.1
LLVM version: 19.1.7
Anything else?
No response