about summary refs log tree commit diff
path: root/compiler/rustc_mir/src/const_eval/eval_queries.rs
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2020-12-20 15:49:08 +0100
committerRalf Jung <post@ralfj.de>2020-12-20 15:54:20 +0100
commit06ca7b700cae83324b4bad8be3286da4f964bb58 (patch)
tree5756db310758494b1727a41b841882e9e2f6026c /compiler/rustc_mir/src/const_eval/eval_queries.rs
parentbd2f1cb2785f87177249e2bdb628ed782fcd8def (diff)
downloadrust-06ca7b700cae83324b4bad8be3286da4f964bb58.tar.gz
rust-06ca7b700cae83324b4bad8be3286da4f964bb58.zip
validate promoteds
Diffstat (limited to 'compiler/rustc_mir/src/const_eval/eval_queries.rs')
-rw-r--r--compiler/rustc_mir/src/const_eval/eval_queries.rs28
1 files changed, 9 insertions, 19 deletions
diff --git a/compiler/rustc_mir/src/const_eval/eval_queries.rs b/compiler/rustc_mir/src/const_eval/eval_queries.rs
index f13b4b7b919..3a3117d5ccf 100644
--- a/compiler/rustc_mir/src/const_eval/eval_queries.rs
+++ b/compiler/rustc_mir/src/const_eval/eval_queries.rs
@@ -383,25 +383,15 @@ pub fn eval_to_allocation_raw_provider<'tcx>(
         Ok(mplace) => {
             // Since evaluation had no errors, valiate the resulting constant:
             let validation = try {
-                // FIXME do not validate promoteds until a decision on
-                // https://github.com/rust-lang/rust/issues/67465 and
-                // https://github.com/rust-lang/rust/issues/67534 is made.
-                // Promoteds can contain unexpected `UnsafeCell` and reference `static`s, but their
-                // otherwise restricted form ensures that this is still sound. We just lose the
-                // extra safety net of some of the dynamic checks. They can also contain invalid
-                // values, but since we do not usually check intermediate results of a computation
-                // for validity, it might be surprising to do that here.
-                if cid.promoted.is_none() {
-                    let mut ref_tracking = RefTracking::new(mplace);
-                    let mut inner = false;
-                    while let Some((mplace, path)) = ref_tracking.todo.pop() {
-                        let mode = match tcx.static_mutability(cid.instance.def_id()) {
-                            Some(_) => CtfeValidationMode::Regular, // a `static`
-                            None => CtfeValidationMode::Const { inner },
-                        };
-                        ecx.const_validate_operand(mplace.into(), path, &mut ref_tracking, mode)?;
-                        inner = true;
-                    }
+                let mut ref_tracking = RefTracking::new(mplace);
+                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 },
+                    };
+                    ecx.const_validate_operand(mplace.into(), path, &mut ref_tracking, mode)?;
+                    inner = true;
                 }
             };
             if let Err(error) = validation {