Use wrappers in the nonzero crate so users don’t need unstable features

This commit is contained in:
Simon Sapin 2017-10-12 17:39:31 +02:00
parent 45fd384a91
commit 4594b40238
14 changed files with 19 additions and 34 deletions

View file

@ -9,9 +9,6 @@ publish = false
name = "canvas_traits" name = "canvas_traits"
path = "lib.rs" path = "lib.rs"
[features]
unstable = ["nonzero/unstable"]
[dependencies] [dependencies]
cssparser = "0.22.0" cssparser = "0.22.0"
euclid = "0.15" euclid = "0.15"

View file

@ -5,8 +5,6 @@
#![crate_name = "canvas_traits"] #![crate_name = "canvas_traits"]
#![crate_type = "rlib"] #![crate_type = "rlib"]
#![cfg_attr(feature = "unstable", feature(nonzero))]
#![deny(unsafe_code)] #![deny(unsafe_code)]
extern crate cssparser; extern crate cssparser;

View file

@ -9,9 +9,6 @@ publish = false
name = "compositing" name = "compositing"
path = "lib.rs" path = "lib.rs"
[features]
unstable = ["nonzero/unstable"]
[dependencies] [dependencies]
euclid = "0.15" euclid = "0.15"
gfx_traits = {path = "../gfx_traits"} gfx_traits = {path = "../gfx_traits"}

View file

@ -3,7 +3,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#![deny(unsafe_code)] #![deny(unsafe_code)]
#![cfg_attr(feature = "unstable", feature(nonzero))]
extern crate euclid; extern crate euclid;
extern crate gfx_traits; extern crate gfx_traits;

View file

@ -9,9 +9,6 @@ publish = false
name = "constellation" name = "constellation"
path = "lib.rs" path = "lib.rs"
[features]
unstable = ["servo_remutex/unstable"]
[dependencies] [dependencies]
backtrace = "0.3" backtrace = "0.3"
bluetooth_traits = { path = "../bluetooth_traits" } bluetooth_traits = { path = "../bluetooth_traits" }

View file

@ -5,7 +5,6 @@
#![deny(unsafe_code)] #![deny(unsafe_code)]
#![feature(box_patterns)] #![feature(box_patterns)]
#![feature(conservative_impl_trait)] #![feature(conservative_impl_trait)]
#![feature(nonzero)]
#![feature(raw)] #![feature(raw)]
extern crate app_units; extern crate app_units;

View file

@ -6,7 +6,6 @@
//! painted. //! painted.
#![feature(mpsc_select)] #![feature(mpsc_select)]
#![cfg_attr(feature = "unstable", feature(nonzero))]
extern crate app_units; extern crate app_units;
extern crate atomic_refcell; extern crate atomic_refcell;

View file

@ -2,9 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#![cfg_attr(feature = "unstable", feature(nonzero))]
#![cfg_attr(feature = "unstable", feature(const_fn))]
#![cfg_attr(feature = "unstable", feature(const_nonzero_new))]
#![deny(unsafe_code)] #![deny(unsafe_code)]
#[macro_use] #[macro_use]

View file

@ -6,8 +6,9 @@
//! or some stable types with an equivalent API (but no memory layout optimization). //! or some stable types with an equivalent API (but no memory layout optimization).
#![cfg_attr(feature = "unstable", feature(nonzero))] #![cfg_attr(feature = "unstable", feature(nonzero))]
#![cfg_attr(feature = "unstable", feature(const_fn))]
#![cfg_attr(feature = "unstable", feature(const_nonzero_new))]
#[cfg(not(feature = "unstable"))]
#[macro_use] #[macro_use]
extern crate serde; extern crate serde;
@ -18,8 +19,23 @@ mod imp {
extern crate core; extern crate core;
use self::core::nonzero::NonZero; use self::core::nonzero::NonZero;
pub type NonZeroU32 = NonZero<u32>; #[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)]
pub type NonZeroUsize = NonZero<usize>; pub struct NonZeroU32(NonZero<u32>);
#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)]
pub struct NonZeroUsize(NonZero<usize>);
impl NonZeroU32 {
#[inline] pub const unsafe fn new_unchecked(x: u32) -> Self { NonZeroU32(NonZero::new_unchecked(x)) }
#[inline] pub fn new(x: u32) -> Option<Self> { NonZero::new(x).map(NonZeroU32) }
#[inline] pub fn get(self) -> u32 { self.0.get() }
}
impl NonZeroUsize {
#[inline] pub const unsafe fn new_unchecked(x: usize) -> Self { NonZeroUsize(NonZero::new_unchecked(x)) }
#[inline] pub fn new(x: usize) -> Option<Self> { NonZero::new(x).map(NonZeroUsize) }
#[inline] pub fn get(self) -> usize { self.0.get() }
}
} }
#[cfg(not(feature = "unstable"))] #[cfg(not(feature = "unstable"))]

View file

@ -9,9 +9,6 @@ publish = false
name = "servo_remutex" name = "servo_remutex"
path = "lib.rs" path = "lib.rs"
[features]
unstable = ["nonzero/unstable"]
[dependencies] [dependencies]
lazy_static = "0.2" lazy_static = "0.2"
log = "0.3.5" log = "0.3.5"

View file

@ -10,8 +10,6 @@
//! It provides the same interface as https://github.com/rust-lang/rust/blob/master/src/libstd/sys/common/remutex.rs //! 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. //! so if those types are ever exported, we should be able to replace this implemtation.
#![cfg_attr(feature = "unstable", feature(nonzero))]
extern crate nonzero; extern crate nonzero;
#[macro_use] extern crate lazy_static; #[macro_use] extern crate lazy_static;
#[macro_use] extern crate log; #[macro_use] extern crate log;

View file

@ -9,9 +9,6 @@ publish = false
name = "script_layout_interface" name = "script_layout_interface"
path = "lib.rs" path = "lib.rs"
[features]
unstable = ["nonzero/unstable"]
[dependencies] [dependencies]
app_units = "0.5" app_units = "0.5"
atomic_refcell = "0.1" atomic_refcell = "0.1"

View file

@ -7,7 +7,6 @@
//! to depend on script. //! to depend on script.
#![deny(unsafe_code)] #![deny(unsafe_code)]
#![cfg_attr(feature = "unstable", feature(nonzero))]
extern crate app_units; extern crate app_units;
extern crate atomic_refcell; extern crate atomic_refcell;

View file

@ -20,14 +20,9 @@ googlevr = ["webvr/googlevr"]
oculusvr = ["webvr/oculusvr"] oculusvr = ["webvr/oculusvr"]
unstable = [ unstable = [
"euclid/unstable", "euclid/unstable",
"layout_thread/unstable",
"msg/unstable", "msg/unstable",
"canvas_traits/unstable",
"compositing/unstable",
"constellation/unstable",
"gfx/unstable", "gfx/unstable",
"profile/unstable", "profile/unstable",
"script_layout_interface/unstable",
] ]
[dependencies] [dependencies]