From 684f75713963f0ca67fcce2b13746e982f203cee Mon Sep 17 00:00:00 2001 From: Scott Olson Date: Sun, 22 Jan 2017 00:19:35 -0800 Subject: [PATCH] Make clippy-suggested fixes. --- src/error.rs | 2 +- src/eval_context.rs | 4 ++-- src/lib.rs | 1 - src/terminator/mod.rs | 10 +++++----- src/vtable.rs | 22 +++++++++++----------- 5 files changed, 19 insertions(+), 20 deletions(-) diff --git a/src/error.rs b/src/error.rs index bf1c71f089db..c641fc24db52 100644 --- a/src/error.rs +++ b/src/error.rs @@ -153,7 +153,7 @@ impl<'tcx> fmt::Display for EvalError<'tcx> { EvalError::AlignmentCheckFailed { required, has } => write!(f, "tried to access memory with alignment {}, but alignment {} is required", has, required), - EvalError::TypeNotPrimitive(ref ty) => + EvalError::TypeNotPrimitive(ty) => write!(f, "expected primitive type, got {}", ty), EvalError::Layout(ref err) => write!(f, "rustc layout computation failed: {:?}", err), diff --git a/src/eval_context.rs b/src/eval_context.rs index d75f3fa7a685..e02ea09be861 100644 --- a/src/eval_context.rs +++ b/src/eval_context.rs @@ -332,7 +332,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> { StackPopCleanup::None => {}, } // deallocate all locals that are backed by an allocation - for local in frame.locals.into_iter() { + for local in frame.locals { if let Value::ByRef(ptr) = local { trace!("deallocating local"); self.memory.dump_alloc(ptr.alloc_id); @@ -1457,7 +1457,7 @@ impl IntegerExt for layout::Integer { pub fn monomorphize_field_ty<'a, 'tcx:'a >(tcx: TyCtxt<'a, 'tcx, 'tcx>, f: &ty::FieldDef, substs: &'tcx Substs<'tcx>) -> Ty<'tcx> { - let substituted = &f.ty(tcx, substs); + let substituted = f.ty(tcx, substs); tcx.normalize_associated_type(&substituted) } diff --git a/src/lib.rs b/src/lib.rs index 32925dffd740..47ed4fd0cebf 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,7 +1,6 @@ #![feature( btree_range, collections, - collections_bound, field_init_shorthand, i128_type, pub_restricted, diff --git a/src/terminator/mod.rs b/src/terminator/mod.rs index d824c16a72f5..11082c633a75 100644 --- a/src/terminator/mod.rs +++ b/src/terminator/mod.rs @@ -579,7 +579,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> { } traits::VtableFnPointer(vtable_fn_ptr) => { - if let ty::TyFnDef(did, ref substs, _) = vtable_fn_ptr.fn_ty.sty { + if let ty::TyFnDef(did, substs, _) = vtable_fn_ptr.fn_ty.sty { args.remove(0); self.unpack_fn_args(args)?; Ok((did, substs, Vec::new())) @@ -775,14 +775,14 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> { Ok(()) } - fn drop_fields< - I: Iterator, ty::layout::Size)>, - >( + fn drop_fields( &mut self, mut fields: I, lval: Lvalue<'tcx>, drop: &mut Vec<(DefId, Value, &'tcx Substs<'tcx>)>, - ) -> EvalResult<'tcx, ()> { + ) -> EvalResult<'tcx, ()> + where I: Iterator, ty::layout::Size)>, + { // FIXME: some aggregates may be represented by Value::ByValPair let (adt_ptr, extra) = self.force_allocation(lval)?.to_ptr_and_extra(); // manual iteration, because we need to be careful about the last field if it is unsized diff --git a/src/vtable.rs b/src/vtable.rs index 1c589f43175e..8e2607562b41 100644 --- a/src/vtable.rs +++ b/src/vtable.rs @@ -27,11 +27,8 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> { traits::VtableBuiltin(_) => { Vec::new().into_iter() } - traits::VtableImpl( - traits::VtableImplData { - impl_def_id: id, - substs, - nested: _ }) => { + + traits::VtableImpl(traits::VtableImplData { impl_def_id: id, substs, .. }) => { self.get_vtable_methods(id, substs) .into_iter() .map(|opt_mth| opt_mth.map(|mth| { @@ -46,18 +43,19 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> { .collect::>() .into_iter() } + traits::VtableClosure( traits::VtableClosureData { closure_def_id, substs, - nested: _ }) => { + .. + } + ) => { let closure_type = self.tcx.closure_type(closure_def_id, substs); vec![Some(self.memory.create_closure_ptr(self.tcx, closure_def_id, substs, closure_type))].into_iter() } - traits::VtableFnPointer( - traits::VtableFnPointerData { - fn_ty, - nested: _ }) => { + + traits::VtableFnPointer(traits::VtableFnPointerData { fn_ty, .. }) => { match fn_ty.sty { ty::TyFnDef(did, substs, bare_fn_ty) => { vec![Some(self.memory.create_fn_ptr(self.tcx, did, substs, bare_fn_ty))].into_iter() @@ -65,6 +63,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> { _ => bug!("bad VtableFnPointer fn_ty: {:?}", fn_ty), } } + traits::VtableObject(ref data) => { // this would imply that the Self type being erased is // an object type; this cannot happen because we @@ -72,6 +71,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> { bug!("cannot get vtable for an object type: {:?}", data); } + vtable @ traits::VtableParam(..) => { bug!("resolved vtable for {:?} to bad vtable {:?} in trans", trait_ref, @@ -100,7 +100,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> { } self.memory.write_usize(vtable.offset(ptr_size), size)?; - self.memory.write_usize(vtable.offset((ptr_size * 2)), align)?; + self.memory.write_usize(vtable.offset(ptr_size * 2), align)?; for (i, method) in methods.into_iter().enumerate() { if let Some(method) = method {