From 0fa5c0f4faf6f3b87159d343f485bbe460549b57 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 14 Nov 2018 14:31:42 +0100 Subject: [PATCH] Rustup to rustc 1.32.0-nightly (9fefb6766 2018-11-13) --- src/base.rs | 14 +++++++------- src/common.rs | 2 +- src/lib.rs | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/base.rs b/src/base.rs index 09e78b47f8c..40955f2cd3d 100644 --- a/src/base.rs +++ b/src/base.rs @@ -373,7 +373,7 @@ fn trans_stmt<'a, 'tcx: 'a>( if *variant_index != dataful_variant { let niche = place.place_field(fx, mir::Field::new(0)); //let niche_llty = niche.layout.immediate_llvm_type(bx.cx); - let niche_value = ((variant_index - *niche_variants.start()) as u128) + let niche_value = ((variant_index.as_u32() - niche_variants.start().as_u32()) as u128) .wrapping_add(niche_start); // FIXME(eddyb) Check the actual primitive type here. let niche_llval = if niche_value == 0 { @@ -683,7 +683,7 @@ pub fn trans_get_discriminant<'a, 'tcx: 'a>( } match layout.variants { layout::Variants::Single { index } => { - let discr_val = layout.ty.ty_adt_def().map_or(index as u128, |def| { + let discr_val = layout.ty.ty_adt_def().map_or(index.as_u32() as u128, |def| { def.discriminant_for_variant(fx.tcx, index).val }); return CValue::const_val(fx, dest_layout.ty, discr_val as u64 as i64); @@ -720,29 +720,29 @@ pub fn trans_get_discriminant<'a, 'tcx: 'a>( let if_true = fx .bcx .ins() - .iconst(dest_clif_ty, *niche_variants.start() as u64 as i64); + .iconst(dest_clif_ty, niche_variants.start().as_u32() as i64); let if_false = fx .bcx .ins() - .iconst(dest_clif_ty, dataful_variant as u64 as i64); + .iconst(dest_clif_ty, dataful_variant.as_u32() as i64); let val = fx.bcx.ins().select(b, if_true, if_false); return CValue::ByVal(val, dest_layout); } else { // Rebase from niche values to discriminant values. - let delta = niche_start.wrapping_sub(*niche_variants.start() as u128); + let delta = niche_start.wrapping_sub(niche_variants.start().as_u32() as u128); let delta = fx.bcx.ins().iconst(niche_llty, delta as u64 as i64); let lldiscr = fx.bcx.ins().isub(lldiscr, delta); let b = fx.bcx.ins().icmp_imm( IntCC::UnsignedLessThanOrEqual, lldiscr, - *niche_variants.end() as u64 as i64, + niche_variants.end().as_u32() as i64, ); let if_true = clif_intcast(fx, lldiscr, fx.clif_type(dest_layout.ty).unwrap(), false); let if_false = fx .bcx .ins() - .iconst(dest_clif_ty, dataful_variant as u64 as i64); + .iconst(dest_clif_ty, dataful_variant.as_u32() as i64); let val = fx.bcx.ins().select(b, if_true, if_false); return CValue::ByVal(val, dest_layout); } diff --git a/src/common.rs b/src/common.rs index d024cb49e4f..77376182756 100644 --- a/src/common.rs +++ b/src/common.rs @@ -561,7 +561,7 @@ pub fn unchecked_cast_to(self, layout: TyLayout<'tcx>) -> Self { } } - pub fn downcast_variant(self, fx: &FunctionCx<'a, 'tcx, impl Backend>, variant: usize) -> Self { + pub fn downcast_variant(self, fx: &FunctionCx<'a, 'tcx, impl Backend>, variant: VariantIdx) -> Self { let layout = self.layout().for_variant(fx, variant); self.unchecked_cast_to(layout) } diff --git a/src/lib.rs b/src/lib.rs index f5415584eff..b4d7d0e2f46 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -96,7 +96,7 @@ mod prelude { config::{CrateType, Lto}, Session, }; - pub use rustc::ty::layout::{self, Abi, LayoutOf, Scalar, Size, TyLayout}; + pub use rustc::ty::layout::{self, Abi, LayoutOf, Scalar, Size, TyLayout, VariantIdx}; pub use rustc::ty::{ self, subst::Substs, FnSig, Instance, InstanceDef, ParamEnv, PolyFnSig, Ty, TyCtxt, TypeAndMut, TypeFoldable,