Make clippy-suggested fixes.
This commit is contained in:
parent
53fa985fc4
commit
684f757139
5 changed files with 19 additions and 20 deletions
|
|
@ -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),
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
#![feature(
|
||||
btree_range,
|
||||
collections,
|
||||
collections_bound,
|
||||
field_init_shorthand,
|
||||
i128_type,
|
||||
pub_restricted,
|
||||
|
|
|
|||
|
|
@ -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<Item=(Ty<'tcx>, ty::layout::Size)>,
|
||||
>(
|
||||
fn drop_fields<I>(
|
||||
&mut self,
|
||||
mut fields: I,
|
||||
lval: Lvalue<'tcx>,
|
||||
drop: &mut Vec<(DefId, Value, &'tcx Substs<'tcx>)>,
|
||||
) -> EvalResult<'tcx, ()> {
|
||||
) -> EvalResult<'tcx, ()>
|
||||
where I: Iterator<Item = (Ty<'tcx>, 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
|
||||
|
|
|
|||
|
|
@ -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::<Vec<_>>()
|
||||
.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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue