Skip to content

Commit 0fce74e

Browse files
committed
The mutability was ignored anyway, so just check for staticness
1 parent aec4741 commit 0fce74e

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

compiler/rustc_const_eval/src/const_eval/eval_queries.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -335,13 +335,16 @@ pub fn eval_to_allocation_raw_provider<'tcx>(
335335
let mut ref_tracking = RefTracking::new(mplace.clone());
336336
let mut inner = false;
337337
while let Some((mplace, path)) = ref_tracking.todo.pop() {
338-
let mode = match tcx.static_mutability(cid.instance.def_id()) {
339-
Some(_) if cid.promoted.is_some() => {
338+
let mode = if is_static {
339+
if cid.promoted.is_some() {
340340
// Promoteds in statics are allowed to point to statics.
341341
CtfeValidationMode::Const { inner, allow_static_ptrs: true }
342+
} else {
343+
// a `static`
344+
CtfeValidationMode::Regular
342345
}
343-
Some(_) => CtfeValidationMode::Regular, // a `static`
344-
None => CtfeValidationMode::Const { inner, allow_static_ptrs: false },
346+
} else {
347+
CtfeValidationMode::Const { inner, allow_static_ptrs: false }
345348
};
346349
ecx.const_validate_operand(&mplace.into(), path, &mut ref_tracking, mode)?;
347350
inner = true;

0 commit comments

Comments
 (0)