Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed some clippy warnings #10

Merged
merged 2 commits into from
Apr 29, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions src/interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ impl<'a, 'tcx: 'a, 'arena> Interpreter<'a, 'tcx, 'arena> {

for stmt in &block_data.statements {
self.log(0, || print!("{:?}", stmt));
let mir::StatementKind::Assign(ref lvalue, ref rvalue) = stmt.kind;
let result = self.eval_assignment(lvalue, rvalue);
let mir::StatementKind::Assign(ref l_value, ref r_value) = stmt.kind;
let result = self.eval_assignment(l_value, r_value);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is even doing this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@llogiq Considering these names are only used on two adjacent lines, I'd rather stick with the existing names to be consistent with the rest of the code.

try!(self.maybe_report(stmt.span, result));
}

Expand Down Expand Up @@ -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),
};
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -1166,7 +1164,7 @@ impl<'a, 'tcx: 'a, 'arena> Interpreter<'a, 'tcx, 'arena> {
}
}

fn pointee_type<'tcx>(ptr_ty: ty::Ty<'tcx>) -> Option<ty::Ty<'tcx>> {
fn pointee_type(ptr_ty: ty::Ty) -> Option<ty::Ty> {
match ptr_ty.sty {
ty::TyRef(_, ty::TypeAndMut { ty, .. }) |
ty::TyRawPtr(ty::TypeAndMut { ty, .. }) |
Expand Down
4 changes: 2 additions & 2 deletions src/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down Expand Up @@ -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;
Expand Down