]> git.proxmox.com Git - rustc.git/blobdiff - compiler/rustc_const_eval/src/const_eval/eval_queries.rs
New upstream version 1.68.2+dfsg1
[rustc.git] / compiler / rustc_const_eval / src / const_eval / eval_queries.rs
index c27790d8887a377a67a59da57daa99ca84f5f9b3..18e01567ca35e44888e52e19abd6bb07edca0d0e 100644 (file)
@@ -1,5 +1,5 @@
+use crate::const_eval::CheckAlignment;
 use std::borrow::Cow;
-use std::convert::TryInto;
 
 use either::{Left, Right};
 
@@ -77,7 +77,7 @@ fn eval_body_using_ecx<'mir, 'tcx>(
             None => InternKind::Constant,
         }
     };
-    ecx.machine.check_alignment = false; // interning doesn't need to respect alignment
+    ecx.machine.check_alignment = CheckAlignment::No; // interning doesn't need to respect alignment
     intern_const_alloc_recursive(ecx, intern_kind, &ret)?;
     // we leave alignment checks off, since this `ecx` will not be used for further evaluation anyway
 
@@ -103,11 +103,7 @@ pub(super) fn mk_eval_cx<'mir, 'tcx>(
         tcx,
         root_span,
         param_env,
-        CompileTimeInterpreter::new(
-            tcx.const_eval_limit(),
-            can_access_statics,
-            /*check_alignment:*/ false,
-        ),
+        CompileTimeInterpreter::new(tcx.const_eval_limit(), can_access_statics, CheckAlignment::No),
     )
 }
 
@@ -312,7 +308,11 @@ pub fn eval_to_allocation_raw_provider<'tcx>(
         CompileTimeInterpreter::new(
             tcx.const_eval_limit(),
             /*can_access_statics:*/ is_static,
-            /*check_alignment:*/ tcx.sess.opts.unstable_opts.extra_const_ub_checks,
+            if tcx.sess.opts.unstable_opts.extra_const_ub_checks {
+                CheckAlignment::Error
+            } else {
+                CheckAlignment::FutureIncompat
+            },
         ),
     );