diff options
| author | Ralf Jung <post@ralfj.de> | 2020-12-20 19:34:29 +0100 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2020-12-20 19:34:29 +0100 |
| commit | 97cae9c555016cfa02a3aa1e41a41157525f8cf4 (patch) | |
| tree | 1108cdd59b4527414a19af585ccdaba9d342eb0f /compiler/rustc_mir/src/const_eval | |
| parent | 06ca7b700cae83324b4bad8be3286da4f964bb58 (diff) | |
promoteds in statics may refer to statics
Diffstat (limited to 'compiler/rustc_mir/src/const_eval')
| -rw-r--r-- | compiler/rustc_mir/src/const_eval/eval_queries.rs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/compiler/rustc_mir/src/const_eval/eval_queries.rs b/compiler/rustc_mir/src/const_eval/eval_queries.rs index 3a3117d5ccf..df163f65628 100644 --- a/compiler/rustc_mir/src/const_eval/eval_queries.rs +++ b/compiler/rustc_mir/src/const_eval/eval_queries.rs @@ -387,8 +387,12 @@ pub fn eval_to_allocation_raw_provider<'tcx>( 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_none() => CtfeValidationMode::Regular, // a `static` - _ => CtfeValidationMode::Const { inner }, + Some(_) if cid.promoted.is_some() => { + // Promoteds in statics are allowed to point to statics. + CtfeValidationMode::Const { inner, allow_static_ptrs: true } + } + Some(_) => CtfeValidationMode::Regular, // a `static` + None => CtfeValidationMode::Const { inner, allow_static_ptrs: false }, }; ecx.const_validate_operand(mplace.into(), path, &mut ref_tracking, mode)?; inner = true; |
