diff --git a/Cargo.lock b/Cargo.lock index ee8a17753dd..77ebe5633f7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -473,6 +473,7 @@ dependencies = [ "log 0.3.8 (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", @@ -1907,6 +1908,7 @@ dependencies = [ "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "heapsize 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "heapsize_derive 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "nonzero 0.0.1", "serde 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)", "webrender_api 0.52.0 (git+https://github.com/servo/webrender)", ] @@ -2046,6 +2048,13 @@ 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.14 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "nsstring_vendor" version = "0.1.0" diff --git a/components/compositing/Cargo.toml b/components/compositing/Cargo.toml index 51d48fd00ca..236cf14443c 100644 --- a/components/compositing/Cargo.toml +++ b/components/compositing/Cargo.toml @@ -9,6 +9,9 @@ publish = false name = "compositing" path = "lib.rs" +[features] +unstable = ["nonzero/unstable"] + [dependencies] euclid = "0.15" gfx_traits = {path = "../gfx_traits"} @@ -18,6 +21,7 @@ ipc-channel = "0.8" log = "0.3.5" 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 35e8a9340ef..7e77157b845 100644 --- a/components/compositing/compositor.rs +++ b/components/compositing/compositor.rs @@ -6,7 +6,6 @@ use CompositionPipeline; use SendableFrameTree; use compositor_thread::{CompositorProxy, CompositorReceiver}; use compositor_thread::{InitialCompositorState, Msg, RenderListener}; -use core::nonzero::NonZero; use euclid::{Point2D, TypedPoint2D, TypedVector2D, ScaleFactor}; use gfx_traits::Epoch; use gleam::gl; @@ -14,6 +13,7 @@ use image::{DynamicImage, ImageFormat, RgbImage}; use ipc_channel::ipc::{self, IpcSharedMemory}; use msg::constellation_msg::{PipelineId, PipelineIndex, PipelineNamespaceId}; use net_traits::image::base::{Image, PixelFormat}; +use nonzero::NonZeroU32; use profile_traits::time::{self, ProfilerCategory, profile}; use script_traits::{AnimationState, AnimationTickType, ConstellationControlMsg}; use script_traits::{ConstellationMsg, LayoutControlMsg, MouseButton}; @@ -62,7 +62,7 @@ impl ConvertPipelineIdFromWebRender for webrender_api::PipelineId { fn from_webrender(&self) -> PipelineId { PipelineId { namespace_id: PipelineNamespaceId(self.0), - index: PipelineIndex(NonZero::new(self.1).expect("Webrender pipeline zero?")), + index: PipelineIndex(NonZeroU32::new(self.1).expect("Webrender pipeline zero?")), } } } diff --git a/components/compositing/lib.rs b/components/compositing/lib.rs index 4e2af3b02f1..ee053c47182 100644 --- a/components/compositing/lib.rs +++ b/components/compositing/lib.rs @@ -3,9 +3,8 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #![deny(unsafe_code)] -#![feature(nonzero)] +#![cfg_attr(feature = "unstable", feature(nonzero))] -extern crate core; extern crate euclid; extern crate gfx_traits; extern crate gleam; @@ -15,6 +14,7 @@ extern crate ipc_channel; 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 3cb93c28572..0f1e39e8182 100644 --- a/components/msg/Cargo.toml +++ b/components/msg/Cargo.toml @@ -9,9 +9,13 @@ publish = false name = "msg" path = "lib.rs" +[features] +unstable = ["nonzero/unstable"] + [dependencies] bitflags = "0.7" heapsize = "0.4" heapsize_derive = "0.1" -serde = { version = "1.0.14", features = [ "unstable" ] } +nonzero = {path = "../nonzero"} +serde = "1.0.14" webrender_api = {git = "https://github.com/servo/webrender", features = ["ipc"]} diff --git a/components/msg/constellation_msg.rs b/components/msg/constellation_msg.rs index 823db993b38..da9bb3ea0cb 100644 --- a/components/msg/constellation_msg.rs +++ b/components/msg/constellation_msg.rs @@ -5,7 +5,7 @@ //! The high-level interface from script to constellation. Using this abstract interface helps //! reduce coupling between these two components. -use core::nonzero::NonZero; +use nonzero::NonZeroU32; use std::cell::Cell; use std::fmt; use webrender_api; @@ -195,9 +195,9 @@ impl PipelineNamespace { }); } - fn next_index(&mut self) -> NonZero { + fn next_index(&mut self) -> NonZeroU32 { self.index += 1; - NonZero::new(self.index).expect("pipeline id index wrapped!") + NonZeroU32::new(self.index).expect("pipeline id index wrapped!") } fn next_pipeline_id(&mut self) -> PipelineId { @@ -221,7 +221,7 @@ thread_local!(pub static PIPELINE_NAMESPACE: Cell> = C pub struct PipelineNamespaceId(pub u32); #[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)] -pub struct PipelineIndex(pub NonZero); +pub struct PipelineIndex(pub NonZeroU32); known_heap_size!(0, PipelineIndex); #[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, HeapSizeOf, Ord, PartialEq, PartialOrd, Serialize)] @@ -264,7 +264,7 @@ impl fmt::Display for PipelineId { } #[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)] -pub struct BrowsingContextIndex(pub NonZero); +pub struct BrowsingContextIndex(pub NonZeroU32); known_heap_size!(0, BrowsingContextIndex); #[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, HeapSizeOf, Ord, PartialEq, PartialOrd, Serialize)] @@ -339,11 +339,15 @@ impl PartialEq for TopLevelBrowsingContextId { // We provide ids just for unit testing. pub const TEST_NAMESPACE: PipelineNamespaceId = PipelineNamespaceId(1234); #[allow(unsafe_code)] -pub const TEST_PIPELINE_INDEX: PipelineIndex = unsafe { PipelineIndex(NonZero::new_unchecked(5678)) }; +#[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(NonZero::new_unchecked(8765)) }; + 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 0876603c1a5..b1743ad02a9 100644 --- a/components/msg/lib.rs +++ b/components/msg/lib.rs @@ -2,16 +2,16 @@ * 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(const_fn)] -#![feature(const_nonzero_new)] -#![feature(nonzero)] +#![cfg_attr(feature = "unstable", feature(nonzero))] +#![cfg_attr(feature = "unstable", feature(const_fn))] +#![cfg_attr(feature = "unstable", feature(const_nonzero_new))] #![deny(unsafe_code)] #[macro_use] extern crate bitflags; -extern crate core; #[macro_use] extern crate heapsize; #[macro_use] extern crate heapsize_derive; +extern crate nonzero; #[macro_use] extern crate serde; extern crate webrender_api; diff --git a/components/servo/Cargo.toml b/components/servo/Cargo.toml index 86994a945d1..ddfb938850b 100644 --- a/components/servo/Cargo.toml +++ b/components/servo/Cargo.toml @@ -18,7 +18,12 @@ energy-profiling = ["profile_traits/energy-profiling"] debugmozjs = ["script/debugmozjs"] googlevr = ["webvr/googlevr"] oculusvr = ["webvr/oculusvr"] -unstable = ["euclid/unstable", "layout_thread/unstable"] +unstable = [ + "euclid/unstable", + "layout_thread/unstable", + "msg/unstable", + "compositing/unstable" +] [dependencies] bluetooth_traits = {path = "../bluetooth_traits"}