diff --git a/Cargo.lock b/Cargo.lock index db7f945f1d7c..c6a22873e87c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -296,7 +296,6 @@ dependencies = [ "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "malloc_size_of 0.0.1", "malloc_size_of_derive 0.0.1", - "nonzero 0.0.1", "offscreen_gl_context 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)", "serde_bytes 0.10.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -433,7 +432,6 @@ dependencies = [ "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "msg 0.0.1", "net_traits 0.0.1", - "nonzero 0.0.1", "profile_traits 0.0.1", "script_traits 0.0.1", "servo_config 0.0.1", @@ -1840,7 +1838,6 @@ dependencies = [ "bitflags 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "malloc_size_of 0.0.1", "malloc_size_of_derive 0.0.1", - "nonzero 0.0.1", "serde 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)", "size_of_test 0.0.1", "webrender_api 0.57.2 (git+https://github.com/servo/webrender)", @@ -1951,13 +1948,6 @@ name = "nom" version = "1.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "nonzero" -version = "0.0.1" -dependencies = [ - "serde 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "num-integer" version = "0.1.38" @@ -2862,7 +2852,6 @@ version = "0.0.1" dependencies = [ "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "nonzero 0.0.1", ] [[package]] diff --git a/components/canvas_traits/Cargo.toml b/components/canvas_traits/Cargo.toml index e9012c92d965..226acf76dff5 100644 --- a/components/canvas_traits/Cargo.toml +++ b/components/canvas_traits/Cargo.toml @@ -17,7 +17,6 @@ gleam = "0.5.1" lazy_static = "1" malloc_size_of = { path = "../malloc_size_of" } malloc_size_of_derive = { path = "../malloc_size_of_derive" } -nonzero = {path = "../nonzero"} offscreen_gl_context = {version = "0.17", features = ["serde"]} serde = "1.0" serde_bytes = "0.10" diff --git a/components/canvas_traits/lib.rs b/components/canvas_traits/lib.rs index 642f4ed363a4..b2147d880e6c 100644 --- a/components/canvas_traits/lib.rs +++ b/components/canvas_traits/lib.rs @@ -14,7 +14,6 @@ extern crate ipc_channel; #[macro_use] extern crate lazy_static; extern crate malloc_size_of; #[macro_use] extern crate malloc_size_of_derive; -extern crate nonzero; extern crate offscreen_gl_context; #[macro_use] extern crate serde; extern crate serde_bytes; diff --git a/components/canvas_traits/webgl.rs b/components/canvas_traits/webgl.rs index d5c7b488d594..2f39cbada27c 100644 --- a/components/canvas_traits/webgl.rs +++ b/components/canvas_traits/webgl.rs @@ -4,9 +4,9 @@ use euclid::Size2D; use gleam::gl; -use nonzero::NonZeroU32; use offscreen_gl_context::{GLContextAttributes, GLLimits}; use serde_bytes::ByteBuf; +use std::num::NonZeroU32; use webrender_api::{DocumentId, ImageKey, PipelineId}; /// Sender type used in WebGLCommands. diff --git a/components/compositing/Cargo.toml b/components/compositing/Cargo.toml index 7dbd1e286882..7a3b2910487a 100644 --- a/components/compositing/Cargo.toml +++ b/components/compositing/Cargo.toml @@ -24,7 +24,6 @@ libc = "0.2" log = "0.4" msg = {path = "../msg"} net_traits = {path = "../net_traits"} -nonzero = {path = "../nonzero"} profile_traits = {path = "../profile_traits"} script_traits = {path = "../script_traits"} servo_config = {path = "../config"} diff --git a/components/compositing/compositor.rs b/components/compositing/compositor.rs index 6275b97bb6a5..0e17b41bafd6 100644 --- a/components/compositing/compositor.rs +++ b/components/compositing/compositor.rs @@ -18,7 +18,6 @@ use msg::constellation_msg::{PipelineId, PipelineIndex, PipelineNamespaceId}; use net_traits::image::base::Image; #[cfg(feature = "gleam")] use net_traits::image::base::PixelFormat; -use nonzero::NonZeroU32; use profile_traits::time::{self, ProfilerCategory, profile}; use script_traits::{AnimationState, AnimationTickType, ConstellationMsg, LayoutControlMsg}; use script_traits::{MouseButton, MouseEventType, ScrollState, TouchEventType, TouchId}; @@ -30,6 +29,7 @@ use std::collections::HashMap; use std::env; use std::fs::{File, create_dir_all}; use std::io::Write; +use std::num::NonZeroU32; use std::rc::Rc; use std::sync::mpsc::Sender; use std::time::Instant; diff --git a/components/compositing/lib.rs b/components/compositing/lib.rs index 59c7600fcfd3..f53c98baeb44 100644 --- a/components/compositing/lib.rs +++ b/components/compositing/lib.rs @@ -17,7 +17,6 @@ extern crate libc; extern crate log; extern crate msg; extern crate net_traits; -extern crate nonzero; extern crate profile_traits; extern crate script_traits; extern crate servo_config; diff --git a/components/msg/Cargo.toml b/components/msg/Cargo.toml index 2d275b7f0274..86a9dac0aa9c 100644 --- a/components/msg/Cargo.toml +++ b/components/msg/Cargo.toml @@ -11,15 +11,11 @@ path = "lib.rs" test = false doctest = false -[features] -unstable = ["nonzero/unstable"] - [dependencies] bitflags = "1.0" malloc_size_of = { path = "../malloc_size_of" } malloc_size_of_derive = { path = "../malloc_size_of_derive" } -nonzero = {path = "../nonzero"} -serde = "1.0.14" +serde = "1.0.60" webrender_api = {git = "https://github.com/servo/webrender", features = ["ipc"]} [dev-dependencies] diff --git a/components/msg/constellation_msg.rs b/components/msg/constellation_msg.rs index 1197341d308c..26a4eb776420 100644 --- a/components/msg/constellation_msg.rs +++ b/components/msg/constellation_msg.rs @@ -5,9 +5,9 @@ //! The high-level interface from script to constellation. Using this abstract interface helps //! reduce coupling between these two components. -use nonzero::NonZeroU32; use std::cell::Cell; use std::fmt; +use std::num::NonZeroU32; use webrender_api; #[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)] @@ -390,15 +390,11 @@ impl fmt::Display for HistoryStateId { // We provide ids just for unit testing. pub const TEST_NAMESPACE: PipelineNamespaceId = PipelineNamespaceId(1234); #[allow(unsafe_code)] -#[cfg(feature = "unstable")] pub const TEST_PIPELINE_INDEX: PipelineIndex = unsafe { PipelineIndex(NonZeroU32::new_unchecked(5678)) }; -#[cfg(feature = "unstable")] pub const TEST_PIPELINE_ID: PipelineId = PipelineId { namespace_id: TEST_NAMESPACE, index: TEST_PIPELINE_INDEX }; #[allow(unsafe_code)] -#[cfg(feature = "unstable")] pub const TEST_BROWSING_CONTEXT_INDEX: BrowsingContextIndex = unsafe { BrowsingContextIndex(NonZeroU32::new_unchecked(8765)) }; -#[cfg(feature = "unstable")] pub const TEST_BROWSING_CONTEXT_ID: BrowsingContextId = BrowsingContextId { namespace_id: TEST_NAMESPACE, index: TEST_BROWSING_CONTEXT_INDEX }; diff --git a/components/msg/lib.rs b/components/msg/lib.rs index 6b256d31df49..f7dc97a82a18 100644 --- a/components/msg/lib.rs +++ b/components/msg/lib.rs @@ -8,7 +8,6 @@ extern crate bitflags; #[macro_use] extern crate malloc_size_of; #[macro_use] extern crate malloc_size_of_derive; -extern crate nonzero; #[macro_use] extern crate serde; extern crate webrender_api; diff --git a/components/nonzero/Cargo.toml b/components/nonzero/Cargo.toml deleted file mode 100644 index cddf62e3a14c..000000000000 --- a/components/nonzero/Cargo.toml +++ /dev/null @@ -1,15 +0,0 @@ -[package] -name = "nonzero" -version = "0.0.1" -authors = ["The Servo Project Developers"] -license = "MPL-2.0" -publish = false - -[lib] -path = "lib.rs" - -[features] -unstable = [] - -[dependencies] -serde = "1.0.14" diff --git a/components/nonzero/lib.rs b/components/nonzero/lib.rs deleted file mode 100644 index 3f8a45cf3591..000000000000 --- a/components/nonzero/lib.rs +++ /dev/null @@ -1,111 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * 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/. */ - -//! `NonZero*` types that are either `core::nonzero::NonZero<_>` -//! or some stable types with an equivalent API (but no memory layout optimization). - -#![cfg_attr(feature = "unstable", feature(const_fn))] - -extern crate serde; - -use std::fmt; - -macro_rules! impl_nonzero_fmt { - ( ( $( $Trait: ident ),+ ) for $Ty: ident ) => { - $( - impl fmt::$Trait for $Ty { - #[inline] - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - self.get().fmt(f) - } - } - )+ - } -} - -macro_rules! nonzero_integers { - ( $( $Ty: ident($Int: ty); )+ ) => { - $( - #[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)] - pub struct $Ty( - #[cfg(feature = "unstable")] std::num::$Ty, - #[cfg(not(feature = "unstable"))] $Int, - ); - - impl $Ty { - #[cfg(feature = "unstable")] - #[inline] - pub const unsafe fn new_unchecked(n: $Int) -> Self { - $Ty(std::num::$Ty::new_unchecked(n)) - } - - #[cfg(not(feature = "unstable"))] - #[inline] - pub unsafe fn new_unchecked(n: $Int) -> Self { - $Ty(n) - } - - #[cfg(feature = "unstable")] - #[inline] - pub fn new(n: $Int) -> Option { - std::num::$Ty::new(n).map($Ty) - } - - #[cfg(not(feature = "unstable"))] - #[inline] - pub fn new(n: $Int) -> Option { - if n != 0 { - Some($Ty(n)) - } else { - None - } - } - - #[cfg(feature = "unstable")] - #[inline] - pub fn get(self) -> $Int { - self.0.get() - } - - #[cfg(not(feature = "unstable"))] - #[inline] - pub fn get(self) -> $Int { - self.0 - } - } - - impl_nonzero_fmt! { - (Debug, Display, Binary, Octal, LowerHex, UpperHex) for $Ty - } - - impl serde::Serialize for $Ty { - fn serialize(&self, serializer: S) -> Result - where S: serde::Serializer - { - self.get().serialize(serializer) - } - } - - impl<'de> serde::Deserialize<'de> for $Ty { - fn deserialize(deserializer: D) -> Result - where D: serde::Deserializer<'de> - { - let value = <$Int>::deserialize(deserializer)?; - match <$Ty>::new(value) { - Some(nonzero) => Ok(nonzero), - None => Err(serde::de::Error::custom("expected a non-zero value")), - } - } - } - )+ - } -} - -nonzero_integers! { - NonZeroU8(u8); - NonZeroU16(u16); - NonZeroU32(u32); - NonZeroU64(u64); - NonZeroUsize(usize); -} diff --git a/components/remutex/Cargo.toml b/components/remutex/Cargo.toml index a91667e08cc7..4f471f5378da 100644 --- a/components/remutex/Cargo.toml +++ b/components/remutex/Cargo.toml @@ -14,4 +14,3 @@ doctest = false [dependencies] lazy_static = "1" log = "0.4" -nonzero = {path = "../nonzero"} diff --git a/components/remutex/lib.rs b/components/remutex/lib.rs index 2589a6d11626..cfdb1b2c7dce 100644 --- a/components/remutex/lib.rs +++ b/components/remutex/lib.rs @@ -10,12 +10,11 @@ //! It provides the same interface as https://github.com/rust-lang/rust/blob/master/src/libstd/sys/common/remutex.rs //! so if those types are ever exported, we should be able to replace this implemtation. -extern crate nonzero; #[macro_use] extern crate lazy_static; #[macro_use] extern crate log; -use nonzero::NonZeroUsize; use std::cell::{Cell, UnsafeCell}; +use std::num::NonZeroUsize; use std::ops::Deref; use std::sync::{LockResult, Mutex, MutexGuard, PoisonError, TryLockError, TryLockResult}; use std::sync::atomic::{AtomicUsize, Ordering}; diff --git a/components/servo/Cargo.toml b/components/servo/Cargo.toml index 0acd9940ebe7..139ad816783c 100644 --- a/components/servo/Cargo.toml +++ b/components/servo/Cargo.toml @@ -21,7 +21,6 @@ webrender_debugger = ["webrender/debugger"] oculusvr = ["webvr/oculusvr"] unstable = [ "euclid/unstable", - "msg/unstable", "profile/unstable", "script/unstable", ]