Rustup to rustc 1.33.0-nightly (68fe5182c 2019-01-05)

This commit is contained in:
bjorn3 2019-01-06 15:27:20 +01:00
parent 70f313aad3
commit 8a586eb6cb
4 changed files with 25 additions and 16 deletions

View file

@ -3,7 +3,7 @@ use std::borrow::Cow;
use rustc::mir::interpret::{
read_target_uint, AllocId, AllocKind, Allocation, ConstValue, EvalResult, GlobalId, Scalar,
};
use rustc::ty::Const;
use rustc::ty::{Const, LazyConst};
use rustc_mir::interpret::{
EvalContext, MPlaceTy, Machine, Memory, MemoryKind, OpTy, PlaceTy, Pointer, StackPopCleanup,
};
@ -61,7 +61,6 @@ pub fn trans_promoted<'a, 'tcx: 'a>(
}))
.unwrap();
let const_ = force_eval_const(fx, const_);
trans_const_place(fx, const_)
}
@ -76,10 +75,10 @@ pub fn trans_constant<'a, 'tcx: 'a>(
pub fn force_eval_const<'a, 'tcx: 'a>(
fx: &FunctionCx<'a, 'tcx, impl Backend>,
const_: &'tcx Const<'tcx>,
) -> &'tcx Const<'tcx> {
match const_.val {
ConstValue::Unevaluated(def_id, ref substs) => {
const_: &'tcx LazyConst<'tcx>,
) -> Const<'tcx> {
match *const_ {
LazyConst::Unevaluated(def_id, ref substs) => {
let param_env = ParamEnv::reveal_all();
let instance = Instance::resolve(fx.tcx, param_env, def_id, substs).unwrap();
let cid = GlobalId {
@ -88,13 +87,13 @@ pub fn force_eval_const<'a, 'tcx: 'a>(
};
fx.tcx.const_eval(param_env.and(cid)).unwrap()
}
_ => const_,
LazyConst::Evaluated(const_) => const_,
}
}
fn trans_const_value<'a, 'tcx: 'a>(
fx: &mut FunctionCx<'a, 'tcx, impl Backend>,
const_: &'tcx Const<'tcx>,
const_: Const<'tcx>,
) -> CValue<'tcx> {
let ty = fx.monomorphize(&const_.ty);
let layout = fx.layout_of(ty);
@ -124,7 +123,7 @@ fn trans_const_value<'a, 'tcx: 'a>(
fn trans_const_place<'a, 'tcx: 'a>(
fx: &mut FunctionCx<'a, 'tcx, impl Backend>,
const_: &'tcx Const<'tcx>,
const_: Const<'tcx>,
) -> CPlace<'tcx> {
// Adapted from https://github.com/rust-lang/rust/pull/53671/files#diff-e0b58bb6712edaa8595ad7237542c958L551
let result = || -> EvalResult<'tcx, &'tcx Allocation> {
@ -146,7 +145,7 @@ fn trans_const_place<'a, 'tcx: 'a>(
span: DUMMY_SP,
ty: const_.ty,
user_ty: None,
literal: const_,
literal: fx.tcx.intern_lazy_const(LazyConst::Evaluated(const_)),
})),
None,
)?;

View file

@ -352,6 +352,11 @@ pub fn codegen_intrinsic_call<'a, 'tcx: 'a>(
let needs_drop = CValue::const_val(fx, fx.tcx.types.bool, needs_drop);
ret.write_cvalue(fx, needs_drop);
};
panic_if_uninhabited, <T> () {
if fx.layout_of(T).abi.is_uninhabited() {
crate::trap::trap_panic(&mut fx.bcx);
}
};
_ if intrinsic.starts_with("atomic_fence"), () {};
_ if intrinsic.starts_with("atomic_singlethreadfence"), () {};

View file

@ -103,7 +103,7 @@ mod prelude {
pub struct Caches<'tcx> {
pub context: Context,
pub vtables: HashMap<(Ty<'tcx>, ty::PolyExistentialTraitRef<'tcx>), DataId>,
pub vtables: HashMap<(Ty<'tcx>, Option<ty::PolyExistentialTraitRef<'tcx>>), DataId>,
}
impl<'tcx> Default for Caches<'tcx> {

View file

@ -51,7 +51,7 @@ pub fn get_ptr_and_method_ref<'a, 'tcx: 'a>(
pub fn get_vtable<'a, 'tcx: 'a>(
fx: &mut FunctionCx<'a, 'tcx, impl Backend>,
ty: Ty<'tcx>,
trait_ref: ty::PolyExistentialTraitRef<'tcx>,
trait_ref: Option<ty::PolyExistentialTraitRef<'tcx>>,
) -> Value {
let data_id = if let Some(data_id) = fx.caches.vtables.get(&(ty, trait_ref)) {
*data_id
@ -68,7 +68,7 @@ pub fn get_vtable<'a, 'tcx: 'a>(
fn build_vtable<'a, 'tcx: 'a>(
fx: &mut FunctionCx<'a, 'tcx, impl Backend>,
ty: Ty<'tcx>,
trait_ref: ty::PolyExistentialTraitRef<'tcx>,
trait_ref: Option<ty::PolyExistentialTraitRef<'tcx>>,
) -> DataId {
let tcx = fx.tcx;
let usize_size = fx.layout_of(fx.tcx.types.usize).size.bytes() as usize;
@ -81,9 +81,14 @@ fn build_vtable<'a, 'tcx: 'a>(
let mut components: Vec<_> = vec![Some(drop_in_place_fn), None, None];
let trait_ref = trait_ref.with_self_ty(tcx, ty);
let methods = tcx.vtable_methods(trait_ref);
let methods = methods.iter().cloned().map(|opt_mth| {
let methods_root;
let methods = if let Some(trait_ref) = trait_ref {
methods_root = tcx.vtable_methods(trait_ref.with_self_ty(tcx, ty));
methods_root.iter()
} else {
(&[]).iter()
};
let methods = methods.cloned().map(|opt_mth| {
opt_mth.map_or(None, |(def_id, substs)| {
Some(import_function(
tcx,