Skip to content

Commit 5e2e927

Browse files
committed
Fix rebase fallout
1 parent 90aee14 commit 5e2e927

File tree

6 files changed

+15
-9
lines changed

6 files changed

+15
-9
lines changed

src/librustc_middle/ty/consts.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ impl<'tcx> Const<'tcx> {
158158
ty: Ty<'tcx>,
159159
) -> Option<u128> {
160160
assert_eq!(self.ty, ty);
161-
let size = tcx.layout_of(param_env.with_reveal_all().and(ty)).ok()?.size;
161+
let size = tcx.layout_of(param_env.with_reveal_all_normalized(tcx).and(ty)).ok()?.size;
162162
// if `ty` does not depend on generic parameters, use an empty param_env
163163
self.val.eval(tcx, param_env).try_to_bits(size)
164164
}

src/librustc_middle/ty/consts/kind.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,16 @@ impl<'tcx> ConstKind<'tcx> {
9696
if let ConstKind::Unevaluated(def, substs, promoted) = self {
9797
use crate::mir::interpret::ErrorHandled;
9898

99-
let param_env_and_substs = param_env.with_reveal_all().and(substs);
100-
10199
// HACK(eddyb) this erases lifetimes even though `const_eval_resolve`
102100
// also does later, but we want to do it before checking for
103101
// inference variables.
104-
let param_env_and_substs = tcx.erase_regions(&param_env_and_substs);
102+
// Note that we erase regions *before* calling `with_reveal_all_normalized`,
103+
// so that we don't try to invoke this query with
104+
// any region variables.
105+
let param_env_and_substs = tcx
106+
.erase_regions(&param_env)
107+
.with_reveal_all_normalized(tcx)
108+
.and(tcx.erase_regions(&substs));
105109

106110
// HACK(eddyb) when the query key would contain inference variables,
107111
// attempt using identity substs and `ParamEnv` instead, that will succeed

src/librustc_middle/ty/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1822,7 +1822,7 @@ impl<'tcx> ParamEnv<'tcx> {
18221822
/// All opaque types in the caller_bounds of the `ParamEnv`
18231823
/// will be normalized to their underlying types.
18241824
/// See PR #65989 and issue #65918 for more details
1825-
pub fn with_reveal_all_normalized(mut self) -> Self {
1825+
pub fn with_reveal_all_normalized(self, tcx: TyCtxt<'tcx>) -> Self {
18261826
if self.packed_data & 1 == 1 {
18271827
return self;
18281828
}

src/librustc_middle/ty/util.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1163,6 +1163,6 @@ pub fn normalize_opaque_types(
11631163
val.fold_with(&mut visitor)
11641164
}
11651165

1166-
pub fn provide(providers: &mut ty::query::Providers<'_>) {
1166+
pub fn provide(providers: &mut ty::query::Providers) {
11671167
*providers = ty::query::Providers { normalize_opaque_types, ..*providers }
11681168
}

src/librustc_mir/transform/validate.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
189189
// Normalize projections and things like that.
190190
// FIXME: We need to reveal_all, as some optimizations change types in ways
191191
// that require unfolding opaque types.
192-
let param_env = self.param_env.with_reveal_all();
192+
let param_env = self.param_env.with_reveal_all_normalized(self.tcx);
193193
let src = self.tcx.normalize_erasing_regions(param_env, src);
194194
let dest = self.tcx.normalize_erasing_regions(param_env, dest);
195195

src/librustc_passes/layout_test.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,10 @@ impl LayoutTest<'tcx> {
8282
}
8383

8484
sym::debug => {
85-
let normalized_ty =
86-
self.tcx.normalize_erasing_regions(param_env.with_reveal_all(), ty);
85+
let normalized_ty = self.tcx.normalize_erasing_regions(
86+
param_env.with_reveal_all_normalized(self.tcx),
87+
ty,
88+
);
8789
self.tcx.sess.span_err(
8890
item.span,
8991
&format!("layout_of({:?}) = {:#?}", normalized_ty, *ty_layout),

0 commit comments

Comments
 (0)