Skip to content

Commit

Permalink
Merge pull request #179 from dwrensha/rustup
Browse files Browse the repository at this point in the history
update for upstream ParamEnv changes
  • Loading branch information
eddyb authored Jun 3, 2017
2 parents d7d11c1 + ca8347a commit 14848b3
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
23 changes: 10 additions & 13 deletions src/eval_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
pub(super) fn type_is_sized(&self, ty: Ty<'tcx>) -> bool {
// generics are weird, don't run this function on a generic
assert!(!ty.needs_subst());
ty.is_sized(self.tcx, ty::ParamEnv::empty(), DUMMY_SP)
ty.is_sized(self.tcx, ty::ParamEnv::empty(Reveal::All), DUMMY_SP)
}

pub fn load_mir(&self, instance: ty::InstanceDef<'tcx>) -> EvalResult<'tcx, &'tcx mir::Mir<'tcx>> {
Expand Down Expand Up @@ -438,9 +438,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
// TODO(solson): Is this inefficient? Needs investigation.
let ty = self.monomorphize(ty, substs);

self.tcx.infer_ctxt((), Reveal::All).enter(|infcx| {
ty.layout(&infcx).map_err(EvalError::Layout)
})
ty.layout(self.tcx, ty::ParamEnv::empty(Reveal::All)).map_err(EvalError::Layout)
}

pub fn push_stack_frame(
Expand Down Expand Up @@ -2033,19 +2031,17 @@ pub fn needs_drop_glue<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, t: Ty<'tcx>) -> bo
// returned `false` does not appear unsound. The impact on
// code quality is unknown at this time.)

let env = ty::ParamEnv::empty();
let env = ty::ParamEnv::empty(Reveal::All);
if !t.needs_drop(tcx, env) {
return false;
}
match t.sty {
ty::TyAdt(def, _) if def.is_box() => {
let typ = t.boxed_ty();
if !typ.needs_drop(tcx, env) && type_is_sized(tcx, typ) {
tcx.infer_ctxt((), traits::Reveal::All).enter(|infcx| {
let layout = t.layout(&infcx).unwrap();
// `Box<ZeroSizeType>` does not allocate.
layout.size(&tcx.data_layout).bytes() != 0
})
let layout = t.layout(tcx, ty::ParamEnv::empty(Reveal::All)).unwrap();
// `Box<ZeroSizeType>` does not allocate.
layout.size(&tcx.data_layout).bytes() != 0
} else {
true
}
Expand Down Expand Up @@ -2157,7 +2153,7 @@ impl<'a, 'tcx> ::rustc::ty::fold::TypeFolder<'tcx, 'tcx> for AssociatedTypeNorma
fn type_is_sized<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ty: Ty<'tcx>) -> bool {
// generics are weird, don't run this function on a generic
assert!(!ty.needs_subst());
ty.is_sized(tcx, ty::ParamEnv::empty(), DUMMY_SP)
ty.is_sized(tcx, ty::ParamEnv::empty(Reveal::All), DUMMY_SP)
}

/// Attempts to resolve an obligation. The result is a shallow vtable resolution -- meaning that we
Expand All @@ -2176,13 +2172,14 @@ fn fulfill_obligation<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,

// Do the initial selection for the obligation. This yields the
// shallow result we are looking for -- that is, what specific impl.
tcx.infer_ctxt((), Reveal::All).enter(|infcx| {
tcx.infer_ctxt(()).enter(|infcx| {
let mut selcx = traits::SelectionContext::new(&infcx);

let obligation_cause = traits::ObligationCause::misc(span,
ast::DUMMY_NODE_ID);
let obligation = traits::Obligation::new(obligation_cause,
trait_ref.to_poly_trait_predicate());
ty::ParamEnv::empty(Reveal::All),
trait_ref.to_poly_trait_predicate());

let selection = match selcx.select(&obligation) {
Ok(Some(selection)) => selection,
Expand Down
3 changes: 2 additions & 1 deletion src/step.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use rustc::hir::def_id::DefId;
use rustc::hir;
use rustc::mir::visit::{Visitor, LvalueContext};
use rustc::mir;
use rustc::traits::Reveal;
use rustc::ty::layout::Layout;
use rustc::ty::{subst, self};

Expand Down Expand Up @@ -197,7 +198,7 @@ impl<'a, 'b, 'tcx> ConstantExtractor<'a, 'b, 'tcx> {
let mutable = !shared ||
!mir.return_ty.is_freeze(
this.ecx.tcx,
ty::ParamEnv::empty(),
ty::ParamEnv::empty(Reveal::All),
span);
let cleanup = StackPopCleanup::MarkStatic(mutable);
let name = ty::tls::with(|tcx| tcx.item_path_str(def_id));
Expand Down
3 changes: 2 additions & 1 deletion src/terminator/intrinsic.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use rustc::mir;
use rustc::traits::Reveal;
use rustc::ty::layout::{Layout, Size, Align};
use rustc::ty::subst::Substs;
use rustc::ty::{self, Ty};
Expand Down Expand Up @@ -291,7 +292,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {

"needs_drop" => {
let ty = substs.type_at(0);
let env = ty::ParamEnv::empty();
let env = ty::ParamEnv::empty(Reveal::All);
let needs_drop = ty.needs_drop(self.tcx, env);
self.write_primval(dest, PrimVal::from_bool(needs_drop), dest_ty)?;
}
Expand Down
3 changes: 2 additions & 1 deletion src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
pub(crate) fn fulfill_obligation(&self, trait_ref: ty::PolyTraitRef<'tcx>) -> traits::Vtable<'tcx, ()> {
// Do the initial selection for the obligation. This yields the shallow result we are
// looking for -- that is, what specific impl.
self.tcx.infer_ctxt((), Reveal::All).enter(|infcx| {
self.tcx.infer_ctxt(()).enter(|infcx| {
let mut selcx = traits::SelectionContext::new(&infcx);

let obligation = traits::Obligation::new(
traits::ObligationCause::misc(DUMMY_SP, ast::DUMMY_NODE_ID),
ty::ParamEnv::empty(Reveal::All),
trait_ref.to_poly_trait_predicate(),
);
let selection = selcx.select(&obligation).unwrap().unwrap();
Expand Down

0 comments on commit 14848b3

Please sign in to comment.