diff options
author | Simon Sapin <simon.sapin@exyr.org> | 2015-01-31 14:36:05 +0100 |
---|---|---|
committer | Matt Brubeck <mbrubeck@limpet.net> | 2015-02-11 14:48:34 -0800 |
commit | d5dd1d658e5d79701fb9d028479a0fcb26a033fa (patch) | |
tree | 0c243afe9d7d82695d16bd43d72e88600e4414ef /components/util | |
parent | bc6882bdefc318402a46ede1494eb79339705c21 (diff) | |
download | servo-d5dd1d658e5d79701fb9d028479a0fcb26a033fa.tar.gz servo-d5dd1d658e5d79701fb9d028479a0fcb26a033fa.zip |
Upgrade to rustc ba2f13ef0 2015-02-04
Diffstat (limited to 'components/util')
-rw-r--r-- | components/util/Cargo.toml | 7 | ||||
-rw-r--r-- | components/util/cache.rs | 2 | ||||
-rw-r--r-- | components/util/cursor.rs | 2 | ||||
-rw-r--r-- | components/util/debug_utils.rs | 4 | ||||
-rw-r--r-- | components/util/deque/mod.rs | 13 | ||||
-rw-r--r-- | components/util/geometry.rs | 8 | ||||
-rw-r--r-- | components/util/lib.rs | 4 | ||||
-rw-r--r-- | components/util/logical_geometry.rs | 14 | ||||
-rw-r--r-- | components/util/memory.rs | 6 | ||||
-rw-r--r-- | components/util/opts.rs | 4 | ||||
-rw-r--r-- | components/util/range.rs | 6 | ||||
-rw-r--r-- | components/util/resource_files.rs | 6 | ||||
-rw-r--r-- | components/util/smallvec.rs | 4 | ||||
-rw-r--r-- | components/util/str.rs | 38 | ||||
-rw-r--r-- | components/util/task_state.rs | 2 | ||||
-rw-r--r-- | components/util/time.rs | 4 | ||||
-rw-r--r-- | components/util/vec.rs | 4 | ||||
-rw-r--r-- | components/util/workqueue.rs | 3 |
18 files changed, 70 insertions, 61 deletions
diff --git a/components/util/Cargo.toml b/components/util/Cargo.toml index 6b640290596..2f4cf2c568b 100644 --- a/components/util/Cargo.toml +++ b/components/util/Cargo.toml @@ -36,7 +36,12 @@ git = "https://github.com/servo/string-cache" [dependencies.string_cache_macros] git = "https://github.com/servo/string-cache" +[dependencies.lazy_static] +git = "https://github.com/Kimundi/lazy-static.rs" + [dependencies] text_writer = "0.1.1" url = "0.2.16" -time = "0.1.12"
\ No newline at end of file +time = "0.1.12" +bitflags = "*" +rand = "*" diff --git a/components/util/cache.rs b/components/util/cache.rs index 8ab2ad690ef..b3f2aaf55c4 100644 --- a/components/util/cache.rs +++ b/components/util/cache.rs @@ -10,7 +10,7 @@ use std::collections::hash_state::DefaultState; use rand::Rng; use std::hash::{Hash, Hasher, SipHasher}; use std::iter::repeat; -use std::rand; +use rand; use std::slice::Iter; #[cfg(test)] diff --git a/components/util/cursor.rs b/components/util/cursor.rs index ff203f1a0e7..4c6b61b38fe 100644 --- a/components/util/cursor.rs +++ b/components/util/cursor.rs @@ -10,7 +10,7 @@ use text_writer::TextWriter; macro_rules! define_cursor { ($( $css: expr => $variant: ident = $value: expr, )+) => { - #[derive(Clone, Copy, PartialEq, Eq, FromPrimitive, Show)] + #[derive(Clone, Copy, PartialEq, Eq, FromPrimitive, Debug)] #[repr(u8)] pub enum Cursor { $( $variant = $value ),+ diff --git a/components/util/debug_utils.rs b/components/util/debug_utils.rs index e43b1d11363..1eaa5085c8b 100644 --- a/components/util/debug_utils.rs +++ b/components/util/debug_utils.rs @@ -2,8 +2,8 @@ * 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::io; -use std::io::Writer; +use std::old_io as io; +use std::old_io::Writer; use std::mem; use std::mem::size_of; use std::slice; diff --git a/components/util/deque/mod.rs b/components/util/deque/mod.rs index 505b09ab021..04d8ab76f39 100644 --- a/components/util/deque/mod.rs +++ b/components/util/deque/mod.rs @@ -86,19 +86,21 @@ struct Deque<T> { /// There may only be one worker per deque. pub struct Worker<T> { deque: Arc<Deque<T>>, - _noshare: marker::NoSync, } +impl<T> !marker::Sync for Worker<T> {} + /// The stealing half of the work-stealing deque. Stealers have access to the /// opposite end of the deque from the worker, and they only have access to the /// `steal` method. pub struct Stealer<T> { deque: Arc<Deque<T>>, - _noshare: marker::NoSync, } +impl<T> !marker::Sync for Stealer<T> {} + /// When stealing some data, this is an enumeration of the possible outcomes. -#[derive(PartialEq, Show)] +#[derive(PartialEq, Debug)] pub enum Stolen<T> { /// The deque was empty at the time of stealing Empty, @@ -156,8 +158,7 @@ impl<T: Send> BufferPool<T> { pub fn deque(&self) -> (Worker<T>, Stealer<T>) { let a = Arc::new(Deque::new(self.clone())); let b = a.clone(); - (Worker { deque: a, _noshare: marker::NoSync }, - Stealer { deque: b, _noshare: marker::NoSync }) + (Worker { deque: a }, Stealer { deque: b }) } fn alloc(&mut self, bits: uint) -> Box<Buffer<T>> { @@ -218,7 +219,7 @@ impl<T: Send> Stealer<T> { impl<T: Send> Clone for Stealer<T> { fn clone(&self) -> Stealer<T> { - Stealer { deque: self.deque.clone(), _noshare: marker::NoSync } + Stealer { deque: self.deque.clone() } } } diff --git a/components/util/geometry.rs b/components/util/geometry.rs index a30849eaf5d..59f61c5afc0 100644 --- a/components/util/geometry.rs +++ b/components/util/geometry.rs @@ -31,7 +31,7 @@ use rustc_serialize::{Encoder, Encodable}; /// /// The ratio between ScreenPx and DevicePixel for a given display be found by calling /// `servo::windowing::WindowMethods::hidpi_factor`. -#[derive(Show, Copy)] +#[derive(Debug, Copy)] pub enum ScreenPx {} /// One CSS "px" in the coordinate system of the "initial viewport": @@ -43,7 +43,7 @@ pub enum ScreenPx {} /// /// At the default zoom level of 100%, one PagePx is equal to one ScreenPx. However, if the /// document is zoomed in or out then this scale may be larger or smaller. -#[derive(RustcEncodable, Show, Copy)] +#[derive(RustcEncodable, Debug, Copy)] pub enum ViewportPx {} /// One CSS "px" in the root coordinate system for the content document. @@ -52,7 +52,7 @@ pub enum ViewportPx {} /// This is the mobile-style "pinch zoom" that enlarges content without reflowing it. When the /// viewport zoom is not equal to 1.0, then the layout viewport is no longer the same physical size /// as the viewable area. -#[derive(RustcEncodable, Show, Copy)] +#[derive(RustcEncodable, Debug, Copy)] pub enum PagePx {} // In summary, the hierarchy of pixel units and the factors to convert from one to the next: @@ -120,7 +120,7 @@ impl Encodable for Au { } } -impl fmt::Show for Au { +impl fmt::Debug for Au { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}px", to_frac_px(*self)) }} diff --git a/components/util/lib.rs b/components/util/lib.rs index a1d356a4645..045760a037d 100644 --- a/components/util/lib.rs +++ b/components/util/lib.rs @@ -6,6 +6,9 @@ #![feature(plugin)] #![feature(int_uint)] #![feature(box_syntax)] +#![feature(optin_builtin_traits)] +#![feature(core, rustc_private, hash, alloc)] +#![feature(collections, libc, std_misc)] #![allow(missing_copy_implementations)] #![allow(unstable)] @@ -13,6 +16,7 @@ #[macro_use] extern crate log; extern crate alloc; +#[macro_use] extern crate bitflags; extern crate collections; extern crate cssparser; extern crate geom; diff --git a/components/util/logical_geometry.rs b/components/util/logical_geometry.rs index a76bd1ca21e..f464412fb46 100644 --- a/components/util/logical_geometry.rs +++ b/components/util/logical_geometry.rs @@ -7,7 +7,7 @@ use geom::{Size2D, Point2D, SideOffsets2D, Rect}; use geom::num::Zero; use std::cmp::{min, max}; -use std::fmt::{Show, Formatter, Error}; +use std::fmt::{Debug, Formatter, Error}; use std::ops::{Add, Sub}; bitflags!( @@ -49,7 +49,7 @@ impl WritingMode { } } -impl Show for WritingMode { +impl Debug for WritingMode { fn fmt(&self, formatter: &mut Formatter) -> Result<(), Error> { if self.is_vertical() { try!(write!(formatter, "V")); @@ -121,7 +121,7 @@ impl DebugWritingMode { } } -impl Show for DebugWritingMode { +impl Debug for DebugWritingMode { #[cfg(ndebug)] fn fmt(&self, formatter: &mut Formatter) -> Result<(), Error> { write!(formatter, "?") @@ -142,7 +142,7 @@ pub struct LogicalSize<T> { debug_writing_mode: DebugWritingMode, } -impl<T: Show> Show for LogicalSize<T> { +impl<T: Debug> Debug for LogicalSize<T> { fn fmt(&self, formatter: &mut Formatter) -> Result<(), Error> { write!(formatter, "LogicalSize({:?}, i{:?}×b{:?})", self.debug_writing_mode, self.inline, self.block) @@ -278,7 +278,7 @@ pub struct LogicalPoint<T> { debug_writing_mode: DebugWritingMode, } -impl<T: Show> Show for LogicalPoint<T> { +impl<T: Debug> Debug for LogicalPoint<T> { fn fmt(&self, formatter: &mut Formatter) -> Result<(), Error> { write!(formatter, "LogicalPoint({:?} (i{:?}, b{:?}))", self.debug_writing_mode, self.i, self.b) @@ -452,7 +452,7 @@ pub struct LogicalMargin<T> { debug_writing_mode: DebugWritingMode, } -impl<T: Show> Show for LogicalMargin<T> { +impl<T: Debug> Debug for LogicalMargin<T> { fn fmt(&self, formatter: &mut Formatter) -> Result<(), Error> { write!(formatter, "LogicalMargin({:?}, inline: {:?}..{:?} block: {:?}..{:?})", @@ -738,7 +738,7 @@ pub struct LogicalRect<T> { debug_writing_mode: DebugWritingMode, } -impl<T: Show> Show for LogicalRect<T> { +impl<T: Debug> Debug for LogicalRect<T> { fn fmt(&self, formatter: &mut Formatter) -> Result<(), Error> { write!(formatter, "LogicalRect({:?}, i{:?}×b{:?}, @ (i{:?},b{:?}))", diff --git a/components/util/memory.rs b/components/util/memory.rs index c555dc8af81..566b6ad3590 100644 --- a/components/util/memory.rs +++ b/components/util/memory.rs @@ -7,9 +7,9 @@ use libc::{c_char,c_int,c_void,size_t}; use std::borrow::ToOwned; use std::ffi::CString; -use std::io::timer::sleep; +use std::old_io::timer::sleep; #[cfg(target_os="linux")] -use std::io::File; +use std::old_io::File; use std::mem; use std::mem::size_of; #[cfg(target_os="linux")] @@ -222,7 +222,7 @@ fn get_proc_self_statm_field(field: uint) -> Option<u64> { match f.read_to_string() { Ok(contents) => { let s = option_try!(contents.as_slice().words().nth(field)); - let npages: u64 = option_try!(s.parse()); + let npages: u64 = option_try!(s.parse().ok()); Some(npages * (page_size() as u64)) } Err(_) => None diff --git a/components/util/opts.rs b/components/util/opts.rs index ae19723b975..26f0651580f 100644 --- a/components/util/opts.rs +++ b/components/util/opts.rs @@ -13,7 +13,7 @@ use layers::geometry::DevicePixel; use getopts; use std::collections::HashSet; use std::cmp; -use std::io; +use std::old_io as io; use std::mem; use std::os; use std::ptr; @@ -219,11 +219,11 @@ pub fn from_cmdline_args(args: &[String]) -> bool { return false; }; - let mut debug_options = HashSet::new(); let debug_string = match opt_match.opt_str("Z") { Some(string) => string, None => String::new() }; + let mut debug_options = HashSet::new(); for split in debug_string.as_slice().split(',') { debug_options.insert(split.clone()); } diff --git a/components/util/range.rs b/components/util/range.rs index 8c217beb218..dba80b458f2 100644 --- a/components/util/range.rs +++ b/components/util/range.rs @@ -9,7 +9,7 @@ use std::num; use std::num::Int; /// An index type to be used by a `Range` -pub trait RangeIndex: Int + fmt::Show { +pub trait RangeIndex: Int + fmt::Debug { type Index; fn new(x: Self::Index) -> Self; fn get(self) -> Self::Index; @@ -28,7 +28,7 @@ impl RangeIndex for int { #[macro_export] macro_rules! int_range_index { ($(#[$attr:meta])* struct $Self:ident($T:ty)) => ( - #[derive(Clone, PartialEq, PartialOrd, Eq, Ord, Show, Copy)] + #[derive(Clone, PartialEq, PartialOrd, Eq, Ord, Debug, Copy)] $(#[$attr])* pub struct $Self(pub $T); @@ -194,7 +194,7 @@ pub struct Range<I> { length: I, } -impl<I: RangeIndex> fmt::Show for Range<I> { +impl<I: RangeIndex> fmt::Debug for Range<I> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "[{:?} .. {:?})", self.begin(), self.end()) } diff --git a/components/util/resource_files.rs b/components/util/resource_files.rs index c5afbaeee56..2df0d059d95 100644 --- a/components/util/resource_files.rs +++ b/components/util/resource_files.rs @@ -2,14 +2,14 @@ * 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::io::{File, IoResult}; -use std::path::Path; +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::io::fs::PathExtensions; +use std::old_io::fs::PathExtensions; #[cfg(not(target_os = "android"))] use std::os; diff --git a/components/util/smallvec.rs b/components/util/smallvec.rs index efd1bfc7f35..1707c0a6eba 100644 --- a/components/util/smallvec.rs +++ b/components/util/smallvec.rs @@ -325,7 +325,7 @@ impl<'a, T: 'a> Iterator for SmallVecMoveIterator<'a,T> { impl<'a, T: 'a> Drop for SmallVecMoveIterator<'a,T> { fn drop(&mut self) { // Destroy the remaining elements. - for _ in *self {} + for _ in self.by_ref() {} match self.allocation { None => {} @@ -443,7 +443,7 @@ macro_rules! def_small_vector( } } - impl<T: fmt::Show> fmt::Show for $name<T> { + impl<T: fmt::Debug> fmt::Debug for $name<T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{:?}", self.as_slice()) } diff --git a/components/util/str.rs b/components/util/str.rs index e0642abdffe..4b785de0a3b 100644 --- a/components/util/str.rs +++ b/components/util/str.rs @@ -68,7 +68,7 @@ pub static HTML_SPACE_CHARACTERS: StaticCharVec = &[ ]; pub fn split_html_space_chars<'a>(s: &'a str) -> - Filter<&'a str, Split<'a, StaticCharVec>, fn(&&str) -> bool> { + Filter<Split<'a, StaticCharVec>, fn(&&str) -> bool> { fn not_empty(&split: &&str) -> bool { !split.is_empty() } s.split(HTML_SPACE_CHARACTERS).filter(not_empty as fn(&&str) -> bool) } @@ -149,7 +149,7 @@ pub fn parse_length(mut value: &str) -> LengthOrPercentageOrAuto { return LengthOrPercentageOrAuto::Auto } if value.starts_with("+") { - value = value.slice_from(1) + value = &value[1..] } value = value.trim_left_matches('0'); if value.len() == 0 { @@ -176,19 +176,19 @@ pub fn parse_length(mut value: &str) -> LengthOrPercentageOrAuto { } } } - value = value.slice_to(end_index); + value = &value[..end_index]; if found_percent { - let result: Option<f64> = FromStr::from_str(value); + let result: Result<f64, _> = FromStr::from_str(value); match result { - Some(number) => return LengthOrPercentageOrAuto::Percentage((number as f64) / 100.0), - None => return LengthOrPercentageOrAuto::Auto, + Ok(number) => return LengthOrPercentageOrAuto::Percentage((number as f64) / 100.0), + Err(_) => return LengthOrPercentageOrAuto::Auto, } } match FromStr::from_str(value) { - Some(number) => LengthOrPercentageOrAuto::Length(Au::from_px(number)), - None => LengthOrPercentageOrAuto::Auto, + Ok(number) => LengthOrPercentageOrAuto::Length(Au::from_px(number)), + Err(_) => LengthOrPercentageOrAuto::Auto, } } @@ -245,14 +245,14 @@ pub fn parse_legacy_color(mut input: &str) -> Result<RGBA,()> { // Step 8. for (char_count, (index, _)) in input.char_indices().enumerate() { if char_count == 128 { - input = input.slice_to(index); + input = &input[..index]; break } } // Step 9. if input.char_at(0) == '#' { - input = input.slice_from(1) + input = &input[1..] } // Step 10. @@ -274,22 +274,22 @@ 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), - input.slice(length, length * 2), - input.slice_from(length * 2)); + &input[length..length * 2], + &input[length * 2..]); // Step 13. if length > 8 { - red = red.slice_from(length - 8); - green = green.slice_from(length - 8); - blue = blue.slice_from(length - 8); + red = &red[length - 8..]; + green = &green[length - 8..]; + blue = &blue[length - 8..]; length = 8 } // Step 14. while length > 2 && red[0] == b'0' && green[0] == b'0' && blue[0] == b'0' { - red = red.slice_from(1); - green = green.slice_from(1); - blue = blue.slice_from(1); + red = &red[1..]; + green = &green[1..]; + blue = &blue[1..]; length -= 1 } @@ -324,7 +324,7 @@ pub fn parse_legacy_color(mut input: &str) -> Result<RGBA,()> { } -#[derive(Clone, Eq, PartialEq, Hash, Show)] +#[derive(Clone, Eq, PartialEq, Hash, Debug)] pub struct LowercaseString { inner: String, } diff --git a/components/util/task_state.rs b/components/util/task_state.rs index ef1dbb2ed3e..290f2a08166 100644 --- a/components/util/task_state.rs +++ b/components/util/task_state.rs @@ -11,7 +11,7 @@ pub use self::imp::{initialize, get, enter, exit}; bitflags! { - #[derive(Show)] + #[derive(Debug)] flags TaskState: u32 { const SCRIPT = 0x01, const LAYOUT = 0x02, diff --git a/components/util/time.rs b/components/util/time.rs index 8165d316f9e..0a255f45bea 100644 --- a/components/util/time.rs +++ b/components/util/time.rs @@ -8,7 +8,7 @@ use collections::BTreeMap; use std::borrow::ToOwned; use std::cmp::Ordering; use std::f64; -use std::io::timer::sleep; +use std::old_io::timer::sleep; use std::iter::AdditiveIterator; use std::num::Float; use std::sync::mpsc::{Sender, channel, Receiver}; @@ -46,7 +46,7 @@ impl Formatable for Option<TimerMetadata> { &Some(ref meta) => { let url = meta.url.as_slice(); let url = if url.len() > 30 { - url.slice_to(30) + &url[..30] } else { url }; diff --git a/components/util/vec.rs b/components/util/vec.rs index a902a3133df..f612726d129 100644 --- a/components/util/vec.rs +++ b/components/util/vec.rs @@ -5,7 +5,7 @@ use std::cmp::{PartialOrd, PartialEq, Ordering}; #[cfg(test)] -use std::fmt::Show; +use std::fmt::Debug; /// FIXME(pcwalton): Workaround for lack of unboxed closures. This is called in /// performance-critical code, so a closure is insufficient. @@ -74,7 +74,7 @@ fn test_find_all_elems<T: PartialEq + PartialOrd + Eq + Ord>(arr: &[T]) { } #[cfg(test)] -fn test_miss_all_elems<T: PartialEq + PartialOrd + Eq + Ord + Show>(arr: &[T], misses: &[T]) { +fn test_miss_all_elems<T: PartialEq + PartialOrd + Eq + Ord + Debug>(arr: &[T], misses: &[T]) { let mut i = 0; while i < misses.len() { let res = arr.binary_search_(&misses[i]); diff --git a/components/util/workqueue.rs b/components/util/workqueue.rs index 5cac6d71d70..69fbce97b7e 100644 --- a/components/util/workqueue.rs +++ b/components/util/workqueue.rs @@ -11,9 +11,8 @@ use task::spawn_named; use task_state; use libc::funcs::posix88::unistd::usleep; -use rand::{Rng, XorShiftRng}; use std::mem; -use std::rand::weak_rng; +use rand::{Rng, weak_rng, XorShiftRng}; use std::sync::atomic::{AtomicUint, Ordering}; use std::sync::mpsc::{channel, Sender, Receiver}; use deque::{Abort, BufferPool, Data, Empty, Stealer, Worker}; |