From 95ac7eabc3536866d8af6bbf9db1f156bcdc2bfe Mon Sep 17 00:00:00 2001 From: Tpt Date: Wed, 13 Apr 2016 09:40:13 +0200 Subject: [PATCH] Fix some warning on Rust 1.7 --- .gitignore | 1 + src/marshal/mod.rs | 3 +-- src/objects/mod.rs | 7 +++---- src/processor/instructions.rs | 4 +--- src/processor/mod.rs | 4 ++-- src/sandbox/mod.rs | 5 ++--- 6 files changed, 10 insertions(+), 14 deletions(-) diff --git a/.gitignore b/.gitignore index 300760a..6c9c861 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ target Cargo.lock *.swp *~ +*.iml \ No newline at end of file diff --git a/src/marshal/mod.rs b/src/marshal/mod.rs index a1c6afb..4bea80e 100644 --- a/src/marshal/mod.rs +++ b/src/marshal/mod.rs @@ -2,8 +2,7 @@ pub mod common; pub mod decode; use std::io; -use std::collections::HashSet; -use super::objects::{Code, ObjectContent, Object, ObjectRef, ObjectStore}; +use super::objects::{Code, ObjectContent, ObjectRef, ObjectStore}; use self::common::Object as MarshalObject; use self::common::Code as MarshalCode; diff --git a/src/objects/mod.rs b/src/objects/mod.rs index 8103078..3999de6 100644 --- a/src/objects/mod.rs +++ b/src/objects/mod.rs @@ -1,6 +1,5 @@ use std::collections::HashMap; -use std::sync::Mutex; -use std::sync::atomic::{AtomicUsize, Ordering}; +use std::sync::atomic::{AtomicUsize, Ordering, ATOMIC_USIZE_INIT}; #[derive(Debug)] #[derive(Clone)] @@ -51,7 +50,7 @@ pub struct ObjectRef { id: usize, } -static current_ref_id: AtomicUsize = ::std::sync::atomic::ATOMIC_USIZE_INIT; +static CURRENT_REF_ID: AtomicUsize = ATOMIC_USIZE_INIT; #[derive(Debug)] pub struct ObjectStore { @@ -64,7 +63,7 @@ impl ObjectStore { } pub fn allocate(&mut self, obj: ObjectContent) -> ObjectRef { - let obj_ref = ObjectRef { id: current_ref_id.fetch_add(1, Ordering::SeqCst) }; + let obj_ref = ObjectRef { id: CURRENT_REF_ID.fetch_add(1, Ordering::SeqCst) }; self.all_objects.insert(obj_ref.clone(), Object { content: obj }); obj_ref } diff --git a/src/processor/instructions.rs b/src/processor/instructions.rs index 24362f3..bea1718 100644 --- a/src/processor/instructions.rs +++ b/src/processor/instructions.rs @@ -1,6 +1,4 @@ -use std::str::Bytes; - -#[derive(PartialEq)] + #[derive(PartialEq)] #[derive(Debug)] pub enum Instruction { PopTop, diff --git a/src/processor/mod.rs b/src/processor/mod.rs index 3d8834b..a3b3f79 100644 --- a/src/processor/mod.rs +++ b/src/processor/mod.rs @@ -1,6 +1,6 @@ pub mod instructions; -use super::objects::{Object, Code, ObjectStore, ObjectRef, ObjectContent}; +use super::objects::{Code, ObjectStore, ObjectRef, ObjectContent}; use super::sandbox::EnvProxy; use super::stack::{Stack, VectorStack}; use self::instructions::Instruction; @@ -29,7 +29,7 @@ fn run_code(envproxy: &mut EP, store: &mut ObjectStore, code: Code let instructions: Vec = instructions::InstructionDecoder::new(bytecode.iter()).into_iter().collect(); let mut program_counter = 0 as usize; let mut stack = VectorStack::new(); - while true { + loop { let instruction = try!(instructions.get(program_counter).ok_or(ProcessorError::InvalidProgramCounter)); program_counter += 1; match *instruction { diff --git a/src/sandbox/mod.rs b/src/sandbox/mod.rs index 1e238b6..c674356 100644 --- a/src/sandbox/mod.rs +++ b/src/sandbox/mod.rs @@ -10,12 +10,11 @@ pub trait EnvProxy { /// An EnvProxy that exposes the real environment -pub struct RealEnvProxy { -} +pub struct RealEnvProxy; impl RealEnvProxy { pub fn new() -> RealEnvProxy { - RealEnvProxy { } + RealEnvProxy } }