about summary refs log tree commit diff
path: root/compiler/rustc_const_eval/src/const_eval
diff options
context:
space:
mode:
authorOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2021-10-25 16:49:39 +0000
committerDeadbeef <ent3rm4n@gmail.com>2021-11-29 21:19:50 +0800
commitf394bb57bb800be024e95e624d96bc698e04dde3 (patch)
treee0f59b65e0a77e941740afb421ce145f656878f9 /compiler/rustc_const_eval/src/const_eval
parenta9a79f657c4a6b86483f3c1165e6f0ebbf77c927 (diff)
downloadrust-f394bb57bb800be024e95e624d96bc698e04dde3.tar.gz
rust-f394bb57bb800be024e95e624d96bc698e04dde3.zip
Always use const param envs for const eval.
Nothing else makes sense, and there is no "danger" in doing so, as it only does something if there are const bounds, which are unstable. This used to happen implicitly via the inferctxt before, which was much more fragile.
Diffstat (limited to 'compiler/rustc_const_eval/src/const_eval')
-rw-r--r--compiler/rustc_const_eval/src/const_eval/eval_queries.rs3
1 files changed, 3 insertions, 0 deletions
diff --git a/compiler/rustc_const_eval/src/const_eval/eval_queries.rs b/compiler/rustc_const_eval/src/const_eval/eval_queries.rs
index 6d3a89c0a8a..c5412affafe 100644
--- a/compiler/rustc_const_eval/src/const_eval/eval_queries.rs
+++ b/compiler/rustc_const_eval/src/const_eval/eval_queries.rs
@@ -7,6 +7,7 @@ use crate::interpret::{
 };
 
 use rustc_errors::ErrorReported;
+use rustc_hir as hir;
 use rustc_hir::def::DefKind;
 use rustc_middle::mir;
 use rustc_middle::mir::interpret::ErrorHandled;
@@ -215,6 +216,7 @@ pub fn eval_to_const_value_raw_provider<'tcx>(
     tcx: TyCtxt<'tcx>,
     key: ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>,
 ) -> ::rustc_middle::mir::interpret::EvalToConstValueResult<'tcx> {
+    assert!(key.param_env.constness() == hir::Constness::Const);
     // see comment in eval_to_allocation_raw_provider for what we're doing here
     if key.param_env.reveal() == Reveal::All {
         let mut key = key;
@@ -249,6 +251,7 @@ pub fn eval_to_allocation_raw_provider<'tcx>(
     tcx: TyCtxt<'tcx>,
     key: ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>,
 ) -> ::rustc_middle::mir::interpret::EvalToAllocationRawResult<'tcx> {
+    assert!(key.param_env.constness() == hir::Constness::Const);
     // Because the constant is computed twice (once per value of `Reveal`), we are at risk of
     // reporting the same error twice here. To resolve this, we check whether we can evaluate the
     // constant in the more restrictive `Reveal::UserFacing`, which most likely already was