The mutability was ignored anyway, so just check for staticness

This commit is contained in:
Oli Scherer 2023-10-09 15:42:03 +00:00
parent aec4741d42
commit 0fce74e1c0

View File

@ -335,13 +335,16 @@ pub fn eval_to_allocation_raw_provider<'tcx>(
let mut ref_tracking = RefTracking::new(mplace.clone());
let mut inner = false;
while let Some((mplace, path)) = ref_tracking.todo.pop() {
let mode = match tcx.static_mutability(cid.instance.def_id()) {
Some(_) if cid.promoted.is_some() => {
let mode = if is_static {
if cid.promoted.is_some() {
// Promoteds in statics are allowed to point to statics.
CtfeValidationMode::Const { inner, allow_static_ptrs: true }
} else {
// a `static`
CtfeValidationMode::Regular
}
Some(_) => CtfeValidationMode::Regular, // a `static`
None => CtfeValidationMode::Const { inner, allow_static_ptrs: false },
} else {
CtfeValidationMode::Const { inner, allow_static_ptrs: false }
};
ecx.const_validate_operand(&mplace.into(), path, &mut ref_tracking, mode)?;
inner = true;