From 8157d92f5051c570575cc769bbecf6acf1f31c98 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Tue, 2 Feb 2016 14:35:08 +0100 Subject: [PATCH 1/3] Move some plugin-only feature gates behind a cfg. --- src/lib.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 971919c..a188188 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -7,10 +7,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(asm, custom_derive, plugin, repr_simd, test)] +#![feature(asm, repr_simd, test)] #![feature(augmented_assignments)] #![feature(op_assign_traits)] +#![cfg_attr(feature = "plugins", feature(custom_derive, plugin))] #![cfg_attr(feature = "plugins", plugin(heapsize_plugin))] #![cfg_attr(feature = "plugins", plugin(serde_macros))] From 8c66d2e92eb4eb3cd68b3ac444838db5dc2bf5a2 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Tue, 2 Feb 2016 14:35:13 +0100 Subject: [PATCH 2/3] Introduce an 'unstable' feature to allow building on stable (fixes #116, fixes #117). --- Cargo.toml | 1 + src/length.rs | 8 +++++++- src/lib.rs | 7 ++++--- src/side_offsets.rs | 7 +++++++ 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 23af63c..12eca71 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,6 +10,7 @@ license = "MIT / Apache-2.0" [features] default = [] plugins = ["serde", "serde_macros", "heapsize", "heapsize_plugin"] +unstable = [] [dependencies] rustc-serialize = "0.3.2" diff --git a/src/length.rs b/src/length.rs index 9676b55..519181e 100644 --- a/src/length.rs +++ b/src/length.rs @@ -15,7 +15,9 @@ use num_lib::NumCast; #[cfg(feature = "plugins")] use serde::{Deserialize, Deserializer, Serialize, Serializer}; use std::cmp::Ordering; -use std::ops::{Add, AddAssign, Sub, SubAssign, Mul, Div, Neg}; +use std::ops::{Add, Sub, Mul, Div, Neg}; +#[cfg(feature = "unstable")] +use std::ops::{AddAssign, SubAssign}; use std::marker::PhantomData; /// A one-dimensional distance, with value represented by `T` and unit of measurement `Unit`. @@ -71,6 +73,7 @@ impl> Add for Length { } // length += length +#[cfg(feature = "unstable")] impl> AddAssign for Length { fn add_assign(&mut self, other: Length) { self.0 += other.get(); @@ -86,6 +89,7 @@ impl> Sub> for Length { } // length -= length +#[cfg(feature = "unstable")] impl> SubAssign for Length { fn sub_assign(&mut self, other: Length) { self.0 -= other.get(); @@ -223,6 +227,7 @@ mod tests { assert_eq!(negative_zero_feet.get(), 0.0); } + #[cfg(feature = "unstable")] #[test] fn test_addassign() { let one_cm: Length = Length::new(10.0); @@ -233,6 +238,7 @@ mod tests { assert_eq!(measurement.get(), 15.0); } + #[cfg(feature = "unstable")] #[test] fn test_subassign() { let one_cm: Length = Length::new(10.0); diff --git a/src/lib.rs b/src/lib.rs index a188188..789847a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -7,9 +7,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(asm, repr_simd, test)] -#![feature(augmented_assignments)] -#![feature(op_assign_traits)] +#![cfg_attr(feature = "unstable", feature(asm, repr_simd, test, augmented_assignments, op_assign_traits))] #![cfg_attr(feature = "plugins", feature(custom_derive, plugin))] #![cfg_attr(feature = "plugins", plugin(heapsize_plugin))] @@ -27,6 +25,7 @@ extern crate serde; #[cfg(test)] extern crate rand; +#[cfg(feature = "unstable")] extern crate test; extern crate num as num_lib; @@ -34,7 +33,9 @@ pub use matrix::Matrix4; pub use matrix2d::Matrix2D; pub use point::{Point2D, Point3D, Point4D}; pub use rect::Rect; +#[cfg(feature = "unstable")] pub use side_offsets::SideOffsets2D; +#[cfg(feature = "unstable")] pub use side_offsets::SideOffsets2DSimdI32; pub use size::Size2D; diff --git a/src/side_offsets.rs b/src/side_offsets.rs index ddf5b67..7a71239 100644 --- a/src/side_offsets.rs +++ b/src/side_offsets.rs @@ -75,6 +75,7 @@ impl SideOffsets2D { } /// A SIMD enabled version of SideOffsets2D specialized for i32. +#[cfg(feature = "unstable")] #[derive(Clone, Copy, PartialEq)] #[repr(simd)] #[cfg_attr(feature = "plugins", derive(HeapSizeOf))] @@ -85,6 +86,7 @@ pub struct SideOffsets2DSimdI32 { pub left: i32, } +#[cfg(feature = "unstable")] impl SideOffsets2DSimdI32 { #[inline] pub fn new(top: i32, right: i32, bottom: i32, left: i32) -> SideOffsets2DSimdI32 { @@ -97,6 +99,7 @@ impl SideOffsets2DSimdI32 { } } +#[cfg(feature = "unstable")] impl SideOffsets2DSimdI32 { #[inline] pub fn new_all_same(all: i32) -> SideOffsets2DSimdI32 { @@ -104,6 +107,7 @@ impl SideOffsets2DSimdI32 { } } +#[cfg(feature = "unstable")] impl SideOffsets2DSimdI32 { #[inline] pub fn horizontal(&self) -> i32 { @@ -124,6 +128,7 @@ impl SideOffsets2DSimdI32 { } }*/ +#[cfg(feature = "unstable")] impl SideOffsets2DSimdI32 { #[inline] pub fn zero() -> SideOffsets2DSimdI32 { @@ -159,6 +164,7 @@ impl SideOffsets2DSimdI32 { } } +#[cfg(feature = "unstable")] #[cfg(test)] mod tests { use super::SideOffsets2DSimdI32; @@ -174,6 +180,7 @@ mod tests { } } +#[cfg(feature = "unstable")] #[cfg(bench)] mod bench { use test::BenchHarness; From 242cad5ff3daf2316465d2e08df7c45cae5d121f Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Tue, 2 Feb 2016 14:00:06 +0100 Subject: [PATCH 3/3] Test on all rust channels. --- .travis.yml | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7e32f47..439617a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,23 @@ language: rust -rust: - - nightly sudo: false notifications: - webhooks: http://build.servo.org:54856/travis \ No newline at end of file + webhooks: http://build.servo.org:54856/travis + +matrix: + include: + - rust: stable + env: FEATURES="" + - rust: beta + env: FEATURES="" + - rust: nightly + env: FEATURES="" + - rust: nightly + env: FEATURES="unstable" + - rust: nightly + env: FEATURES="plugins" + - rust: nightly + env: FEATURES="unstable plugins" + +script: + - cargo build --verbose --features "$FEATURES" + - cargo test --verbose --features "$FEATURES"