diff --git a/src/interpreter.rs b/src/interpreter.rs index 91682207ed6..0b4aab71b61 100644 --- a/src/interpreter.rs +++ b/src/interpreter.rs @@ -830,7 +830,7 @@ impl<'a, 'tcx: 'a, 'arena> Interpreter<'a, 'tcx, 'arena> { Index(ref operand) => { let elem_size = match base_ty.sty { - ty::TyArray(elem_ty, _) => self.type_size(elem_ty), + ty::TyArray(elem_ty, _) | ty::TySlice(elem_ty) => self.type_size(elem_ty), _ => panic!("indexing expected an array or slice, got {:?}", base_ty), }; @@ -1109,11 +1109,9 @@ impl<'a, 'tcx: 'a, 'arena> Interpreter<'a, 'tcx, 'arena> { let vtable = selection.map(|predicate| { fulfill_cx.register_predicate_obligation(&infcx, predicate); }); - let vtable = infer::drain_fulfillment_cx_or_panic( + infer::drain_fulfillment_cx_or_panic( DUMMY_SP, &infcx, &mut fulfill_cx, &vtable - ); - - vtable + ) } /// Trait method, which has to be resolved to an impl method. @@ -1166,7 +1164,7 @@ impl<'a, 'tcx: 'a, 'arena> Interpreter<'a, 'tcx, 'arena> { } } -fn pointee_type<'tcx>(ptr_ty: ty::Ty<'tcx>) -> Option> { +fn pointee_type(ptr_ty: ty::Ty) -> Option { match ptr_ty.sty { ty::TyRef(_, ty::TypeAndMut { ty, .. }) | ty::TyRawPtr(ty::TypeAndMut { ty, .. }) | diff --git a/src/memory.rs b/src/memory.rs index 14aa4f9d799..285c3554b64 100644 --- a/src/memory.rs +++ b/src/memory.rs @@ -47,7 +47,7 @@ pub struct FieldRepr { impl Repr { pub fn size(&self) -> usize { match *self { - Repr::Primitive { size } => size, + Repr::Primitive { size } | Repr::Aggregate { size, .. } => size, Repr::Array { elem_size, length } => elem_size * length, } @@ -406,7 +406,7 @@ impl Memory { fn clear_relocations(&mut self, ptr: Pointer, size: usize) -> EvalResult<()> { // Find all relocations overlapping the given range. let keys: Vec<_> = try!(self.relocations(ptr, size)).map(|(&k, _)| k).collect(); - if keys.len() == 0 { return Ok(()); } + if keys.is_empty() { return Ok(()); } // Find the start and end of the given range and its outermost relocations. let start = ptr.offset;