Merge pull request #179 from dwrensha/rustup

update for upstream ParamEnv changes
This commit is contained in:
Eduard-Mihai Burtescu 2017-06-03 08:54:05 +03:00 committed by GitHub
commit 14848b3bad
4 changed files with 16 additions and 16 deletions

View File

@ -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>> {
@ -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(
@ -2033,7 +2031,7 @@ 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;
}
@ -2041,11 +2039,9 @@ pub fn needs_drop_glue<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, t: Ty<'tcx>) -> bo
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
}
@ -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
@ -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,

View File

@ -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};
@ -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));

View File

@ -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};
@ -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)?;
}

View File

@ -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();