Skip to content

Commit 22f8bde

Browse files
committedDec 12, 2021
Auto merge of #91549 - fee1-dead:const_env, r=spastorino
Eliminate ConstnessAnd again Closes #91489. Closes #89432. Reverts #91491. Reverts #89450. r? `@spastorino`
2 parents 6bda5b3 + ffc9082 commit 22f8bde

File tree

69 files changed

+622
-458
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+622
-458
lines changed
 

‎compiler/rustc_borrowck/src/type_check/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ use rustc_middle::ty::fold::TypeFoldable;
3131
use rustc_middle::ty::subst::{GenericArgKind, SubstsRef, UserSubsts};
3232
use rustc_middle::ty::{
3333
self, CanonicalUserTypeAnnotation, CanonicalUserTypeAnnotations, OpaqueTypeKey, RegionVid,
34-
ToPredicate, Ty, TyCtxt, UserType, UserTypeAnnotationIndex, WithConstness,
34+
ToPredicate, Ty, TyCtxt, UserType, UserTypeAnnotationIndex,
3535
};
3636
use rustc_span::def_id::CRATE_DEF_ID;
3737
use rustc_span::{Span, DUMMY_SP};

‎compiler/rustc_const_eval/src/const_eval/eval_queries.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use crate::interpret::{
77
};
88

99
use rustc_errors::ErrorReported;
10+
use rustc_hir as hir;
1011
use rustc_hir::def::DefKind;
1112
use rustc_middle::mir;
1213
use rustc_middle::mir::interpret::ErrorHandled;
@@ -215,6 +216,7 @@ pub fn eval_to_const_value_raw_provider<'tcx>(
215216
tcx: TyCtxt<'tcx>,
216217
key: ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>,
217218
) -> ::rustc_middle::mir::interpret::EvalToConstValueResult<'tcx> {
219+
assert!(key.param_env.constness() == hir::Constness::Const);
218220
// see comment in eval_to_allocation_raw_provider for what we're doing here
219221
if key.param_env.reveal() == Reveal::All {
220222
let mut key = key;
@@ -249,6 +251,7 @@ pub fn eval_to_allocation_raw_provider<'tcx>(
249251
tcx: TyCtxt<'tcx>,
250252
key: ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>,
251253
) -> ::rustc_middle::mir::interpret::EvalToAllocationRawResult<'tcx> {
254+
assert!(key.param_env.constness() == hir::Constness::Const);
252255
// Because the constant is computed twice (once per value of `Reveal`), we are at risk of
253256
// reporting the same error twice here. To resolve this, we check whether we can evaluate the
254257
// constant in the more restrictive `Reveal::UserFacing`, which most likely already was

0 commit comments

Comments
 (0)