Open
Description
I tried this code:
#![feature(super_let)]
use std::sync::atomic::AtomicI32;
const WORKS: &Option<AtomicI32> = {
super let a: Option<AtomicI32> = None;
&a
};
const WORKS2: &Option<AtomicI32> = {
super let a: Option<AtomicI32> = None;
let x = &a;
&*x
};
const FAILS: &Option<AtomicI32> = {
super let a: Option<AtomicI32> = None;
let _x = &a;
&a
};
I expected to see this happen: Either all three constants compile, or all three fail.
Instead, this happened: Only the FAILS
constant fails to compile
error[E0492]: constants cannot refer to interior mutable data
--> src/lib.rs:19:5
|
19 | &a
| ^^ this borrow of an interior mutable value may end up in the final value
For more information about this error, try `rustc --explain E0492`.
error: could not compile `playground` (lib) due to 1 previous error
See also #142229, which also involves super let
in const
, and issues with mutability.
Meta
Reproducible on the playground with 1.89.0-nightly (2025-06-11 e703dff8fe220b78195c)
@rustbot labels +F-super_let +A-const-eval