aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMs2ger <ms2ger@gmail.com>2015-02-13 11:42:13 +0100
committerMs2ger <ms2ger@gmail.com>2015-02-13 11:42:13 +0100
commit830e6741c76a5eef85096d0378484d62f70c911a (patch)
tree5bb71d7f842bcceaabb44878724b027123f4e224
parentb25564440ddeab1fdcb3dec2b069130759bc4f41 (diff)
downloadservo-830e6741c76a5eef85096d0378484d62f70c911a.tar.gz
servo-830e6741c76a5eef85096d0378484d62f70c911a.zip
Fix warnings in util.
-rw-r--r--components/util/debug_utils.rs12
-rw-r--r--components/util/deque/mod.rs2
-rw-r--r--components/util/lib.rs20
-rw-r--r--components/util/memory.rs2
-rw-r--r--components/util/opts.rs4
-rw-r--r--components/util/resource_files.rs15
-rw-r--r--components/util/smallvec.rs6
-rw-r--r--components/util/str.rs2
-rw-r--r--components/util/tid.rs4
9 files changed, 35 insertions, 32 deletions
diff --git a/components/util/debug_utils.rs b/components/util/debug_utils.rs
index 1eaa5085c8b..8d9789de029 100644
--- a/components/util/debug_utils.rs
+++ b/components/util/debug_utils.rs
@@ -10,25 +10,25 @@ use std::slice;
fn hexdump_slice(buf: &[u8]) {
let mut stderr = io::stderr();
- stderr.write(b" ").unwrap();
+ stderr.write_all(b" ").unwrap();
for (i, &v) in buf.iter().enumerate() {
let output = format!("{:02X} ", v as uint);
- stderr.write(output.as_bytes()).unwrap();
+ stderr.write_all(output.as_bytes()).unwrap();
match i % 16 {
- 15 => { stderr.write(b"\n ").unwrap(); },
- 7 => { stderr.write(b" ").unwrap(); },
+ 15 => { stderr.write_all(b"\n ").unwrap(); },
+ 7 => { stderr.write_all(b" ").unwrap(); },
_ => ()
}
stderr.flush().unwrap();
}
- stderr.write(b"\n").unwrap();
+ stderr.write_all(b"\n").unwrap();
}
pub fn hexdump<T>(obj: &T) {
unsafe {
let buf: *const u8 = mem::transmute(obj);
debug!("dumping at {:p}", buf);
- let from_buf = slice::from_raw_buf(&buf, size_of::<T>());
+ let from_buf = slice::from_raw_parts(buf, size_of::<T>());
hexdump_slice(from_buf);
}
}
diff --git a/components/util/deque/mod.rs b/components/util/deque/mod.rs
index 04d8ab76f39..6dce728679b 100644
--- a/components/util/deque/mod.rs
+++ b/components/util/deque/mod.rs
@@ -42,8 +42,6 @@
//! let mut stealer2 = stealer.clone();
//! stealer2.steal();
-#![experimental]
-
// NB: the "buffer pool" strategy is not done for speed, but rather for
// correctness. For more info, see the comment on `swap_buffer`
diff --git a/components/util/lib.rs b/components/util/lib.rs
index 045760a037d..36b61f6ed6a 100644
--- a/components/util/lib.rs
+++ b/components/util/lib.rs
@@ -2,16 +2,24 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-#![feature(unsafe_destructor)]
-#![feature(plugin)]
-#![feature(int_uint)]
+#![feature(alloc)]
#![feature(box_syntax)]
+#![feature(collections)]
+#![feature(core)]
+#![feature(env)]
+#![feature(hash)]
+#![feature(int_uint)]
+#![feature(io)]
+#![feature(libc)]
#![feature(optin_builtin_traits)]
-#![feature(core, rustc_private, hash, alloc)]
-#![feature(collections, libc, std_misc)]
+#![feature(path)]
+#![feature(plugin)]
+#![feature(rustc_private)]
+#![feature(std_misc)]
+#![feature(unicode)]
+#![feature(unsafe_destructor)]
#![allow(missing_copy_implementations)]
-#![allow(unstable)]
#[macro_use] extern crate log;
diff --git a/components/util/memory.rs b/components/util/memory.rs
index 566b6ad3590..d52500b62a3 100644
--- a/components/util/memory.rs
+++ b/components/util/memory.rs
@@ -13,7 +13,7 @@ use std::old_io::File;
use std::mem;
use std::mem::size_of;
#[cfg(target_os="linux")]
-use std::os::page_size;
+use std::env::page_size;
use std::ptr::null_mut;
use std::sync::mpsc::{Sender, channel, Receiver};
use std::time::duration::Duration;
diff --git a/components/util/opts.rs b/components/util/opts.rs
index 26f0651580f..aeee40ac249 100644
--- a/components/util/opts.rs
+++ b/components/util/opts.rs
@@ -13,9 +13,9 @@ use layers::geometry::DevicePixel;
use getopts;
use std::collections::HashSet;
use std::cmp;
+use std::env;
use std::old_io as io;
use std::mem;
-use std::os;
use std::ptr;
use std::rt;
@@ -137,7 +137,7 @@ pub fn print_debug_usage(app: &str) {
fn args_fail(msg: &str) {
io::stderr().write_line(msg).unwrap();
- os::set_exit_status(1);
+ env::set_exit_status(1);
}
// Always use CPU painting on android.
diff --git a/components/util/resource_files.rs b/components/util/resource_files.rs
index 2df0d059d95..c1defd887f0 100644
--- a/components/util/resource_files.rs
+++ b/components/util/resource_files.rs
@@ -5,14 +5,6 @@
use std::old_io::{File, IoResult};
use std::old_path::Path;
-#[cfg(not(target_os = "android"))]
-use opts;
-
-#[cfg(not(target_os = "android"))]
-use std::old_io::fs::PathExtensions;
-#[cfg(not(target_os = "android"))]
-use std::os;
-
#[cfg(target_os = "android")]
pub fn resources_dir_path() -> Path {
Path::new("/sdcard/servo/")
@@ -20,13 +12,18 @@ pub fn resources_dir_path() -> Path {
#[cfg(not(target_os = "android"))]
pub fn resources_dir_path() -> Path {
+ use opts;
+ use std::env;
+ use std::old_io::fs::PathExtensions;
+
match opts::get().resources_path {
Some(ref path) => Path::new(path),
None => {
// FIXME: Find a way to not rely on the executable being
// under `<servo source>/components/servo/target`
// or `<servo source>/components/servo/target/release`.
- let mut path = os::self_exe_path().expect("can't get exe path");
+ let mut path = env::current_exe().ok().expect("can't get exe path");
+ path.pop();
path.pop();
path.pop();
path.pop();
diff --git a/components/util/smallvec.rs b/components/util/smallvec.rs
index 1707c0a6eba..14d983376e8 100644
--- a/components/util/smallvec.rs
+++ b/components/util/smallvec.rs
@@ -44,7 +44,7 @@ impl<T> VecLike<T> for Vec<T> {
#[inline]
fn vec_slice_mut<'a>(&'a mut self, start: uint, end: uint) -> &'a mut [T] {
- self.slice_mut(start, end)
+ &mut self[start..end]
}
}
@@ -410,7 +410,7 @@ macro_rules! def_small_vector(
}
impl<T> FromIterator<T> for $name<T> {
- fn from_iter<I: Iterator<Item=T>>(mut iter: I) -> $name<T> {
+ fn from_iter<I: Iterator<Item=T>>(iter: I) -> $name<T> {
let mut v = $name::new();
let (lower_size_bound, _) = iter.size_hint();
@@ -428,7 +428,7 @@ macro_rules! def_small_vector(
}
impl<T> $name<T> {
- pub fn extend<I: Iterator<Item=T>>(&mut self, mut iter: I) {
+ pub fn extend<I: Iterator<Item=T>>(&mut self, iter: I) {
let (lower_size_bound, _) = iter.size_hint();
let target_len = self.len() + lower_size_bound;
diff --git a/components/util/str.rs b/components/util/str.rs
index 4b785de0a3b..80cdd1ae230 100644
--- a/components/util/str.rs
+++ b/components/util/str.rs
@@ -273,7 +273,7 @@ pub fn parse_legacy_color(mut input: &str) -> Result<RGBA,()> {
// Step 12.
let mut length = input.len() / 3;
- let (mut red, mut green, mut blue) = (input.slice_to(length),
+ let (mut red, mut green, mut blue) = (&input[..length],
&input[length..length * 2],
&input[length * 2..]);
diff --git a/components/util/tid.rs b/components/util/tid.rs
index e52dbf7fd61..7351f85f085 100644
--- a/components/util/tid.rs
+++ b/components/util/tid.rs
@@ -2,11 +2,11 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-use std::sync::atomic::{AtomicUint, ATOMIC_UINT_INIT, Ordering};
+use std::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering};
use std::rc::Rc;
use std::cell::RefCell;
-static mut next_tid: AtomicUint = ATOMIC_UINT_INIT;
+static mut next_tid: AtomicUsize = ATOMIC_USIZE_INIT;
thread_local!(static TASK_LOCAL_TID: Rc<RefCell<Option<uint>>> = Rc::new(RefCell::new(None)));