Skip to content

Commit

Permalink
Fix rebase fallout
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron1011 committed Jul 22, 2020
1 parent 90aee14 commit 5e2e927
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/librustc_middle/ty/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ impl<'tcx> Const<'tcx> {
ty: Ty<'tcx>,
) -> Option<u128> {
assert_eq!(self.ty, ty);
let size = tcx.layout_of(param_env.with_reveal_all().and(ty)).ok()?.size;
let size = tcx.layout_of(param_env.with_reveal_all_normalized(tcx).and(ty)).ok()?.size;
// if `ty` does not depend on generic parameters, use an empty param_env
self.val.eval(tcx, param_env).try_to_bits(size)
}
Expand Down
10 changes: 7 additions & 3 deletions src/librustc_middle/ty/consts/kind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,16 @@ impl<'tcx> ConstKind<'tcx> {
if let ConstKind::Unevaluated(def, substs, promoted) = self {
use crate::mir::interpret::ErrorHandled;

let param_env_and_substs = param_env.with_reveal_all().and(substs);

// HACK(eddyb) this erases lifetimes even though `const_eval_resolve`
// also does later, but we want to do it before checking for
// inference variables.
let param_env_and_substs = tcx.erase_regions(&param_env_and_substs);
// Note that we erase regions *before* calling `with_reveal_all_normalized`,
// so that we don't try to invoke this query with
// any region variables.
let param_env_and_substs = tcx
.erase_regions(&param_env)
.with_reveal_all_normalized(tcx)
.and(tcx.erase_regions(&substs));

// HACK(eddyb) when the query key would contain inference variables,
// attempt using identity substs and `ParamEnv` instead, that will succeed
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_middle/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1822,7 +1822,7 @@ impl<'tcx> ParamEnv<'tcx> {
/// All opaque types in the caller_bounds of the `ParamEnv`
/// will be normalized to their underlying types.
/// See PR #65989 and issue #65918 for more details
pub fn with_reveal_all_normalized(mut self) -> Self {
pub fn with_reveal_all_normalized(self, tcx: TyCtxt<'tcx>) -> Self {
if self.packed_data & 1 == 1 {
return self;
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_middle/ty/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1163,6 +1163,6 @@ pub fn normalize_opaque_types(
val.fold_with(&mut visitor)
}

pub fn provide(providers: &mut ty::query::Providers<'_>) {
pub fn provide(providers: &mut ty::query::Providers) {
*providers = ty::query::Providers { normalize_opaque_types, ..*providers }
}
2 changes: 1 addition & 1 deletion src/librustc_mir/transform/validate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
// Normalize projections and things like that.
// FIXME: We need to reveal_all, as some optimizations change types in ways
// that require unfolding opaque types.
let param_env = self.param_env.with_reveal_all();
let param_env = self.param_env.with_reveal_all_normalized(self.tcx);
let src = self.tcx.normalize_erasing_regions(param_env, src);
let dest = self.tcx.normalize_erasing_regions(param_env, dest);

Expand Down
6 changes: 4 additions & 2 deletions src/librustc_passes/layout_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,10 @@ impl LayoutTest<'tcx> {
}

sym::debug => {
let normalized_ty =
self.tcx.normalize_erasing_regions(param_env.with_reveal_all(), ty);
let normalized_ty = self.tcx.normalize_erasing_regions(
param_env.with_reveal_all_normalized(self.tcx),
ty,
);
self.tcx.sess.span_err(
item.span,
&format!("layout_of({:?}) = {:#?}", normalized_ty, *ty_layout),
Expand Down

0 comments on commit 5e2e927

Please sign in to comment.