Make it possible to build the style_traits crate with a stable compiler.

Testing this on CI to make sure we don’t regress it is blocked on #11806
This commit is contained in:
Simon Sapin 2016-06-21 13:55:50 +02:00
parent b9b289c4be
commit ea73c8efac
20 changed files with 145 additions and 89 deletions

View file

@ -8,28 +8,30 @@ publish = false
name = "util"
path = "lib.rs"
[features]
# servo as opposed to geckolib
servo = ["serde", "serde_macros", "backtrace", "ipc-channel", "bitflags"]
[dependencies]
app_units = {version = "0.2.3", features = ["plugins"]}
backtrace = "0.2.1"
bitflags = "0.7"
app_units = {version = "0.2.3"}
backtrace = {version = "0.2.1", optional = true}
bitflags = {version = "0.7", optional = true}
deque = "0.3.1"
euclid = {version = "0.6.4", features = ["unstable", "plugins"]}
euclid = {version = "0.6.4"}
getopts = "0.2.11"
heapsize = "0.3.0"
heapsize_plugin = "0.1.2"
ipc-channel = {git = "https://github.com/servo/ipc-channel"}
ipc-channel = {git = "https://github.com/servo/ipc-channel", optional = true}
lazy_static = "0.2"
libc = "0.2"
log = "0.3.5"
num_cpus = "0.2.2"
num-traits = "0.1.32"
plugins = {path = "../plugins"}
rand = "0.3"
rustc-serialize = "0.3"
serde = "0.7"
serde_macros = "0.7"
serde = {version = "0.7", optional = true}
serde_macros = {version = "0.7", optional = true}
smallvec = "0.1"
url = {version = "1.0.0", features = ["heap_size", "serde"]}
url = {version = "1.0.0"}
[target.'cfg(all(unix, not(target_os = "macos"), not(target_os = "ios"), not(target_os = "android")))'.dependencies]
xdg = "2.0"

View file

@ -23,7 +23,7 @@ use std::i32;
///
/// The ratio between ScreenPx and DevicePixel for a given display be found by calling
/// `servo::windowing::WindowMethods::hidpi_factor`.
#[derive(Clone, Copy, Debug, HeapSizeOf)]
#[derive(Clone, Copy, Debug)]
pub enum ScreenPx {}
/// One CSS "px" in the coordinate system of the "initial viewport":
@ -35,7 +35,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(Clone, Copy, Debug, HeapSizeOf)]
#[derive(Clone, Copy, Debug)]
pub enum ViewportPx {}
/// One CSS "px" in the root coordinate system for the content document.
@ -44,9 +44,11 @@ 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(Clone, Copy, Debug, HeapSizeOf)]
#[derive(Clone, Copy, Debug)]
pub enum PagePx {}
known_heap_size!(0, ScreenPx, ViewportPx, PagePx);
// In summary, the hierarchy of pixel units and the factors to convert from one to the next:
//
// DevicePixel

View file

@ -2,39 +2,31 @@
* 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(box_syntax)]
#![feature(core_intrinsics)]
#![feature(custom_derive)]
#![feature(fnbox)]
#![feature(plugin)]
#![feature(reflect_marker)]
#![feature(step_by)]
#![plugin(heapsize_plugin, plugins, serde_macros)]
#![cfg_attr(feature = "servo", feature(core_intrinsics))]
#![cfg_attr(feature = "servo", feature(custom_derive))]
#![cfg_attr(feature = "servo", feature(fnbox))]
#![cfg_attr(feature = "servo", feature(plugin))]
#![cfg_attr(feature = "servo", feature(reflect_marker))]
#![cfg_attr(feature = "servo", plugin(serde_macros))]
#![deny(unsafe_code)]
extern crate app_units;
extern crate backtrace;
#[allow(unused_extern_crates)]
#[macro_use]
extern crate bitflags;
#[cfg(feature = "servo")] extern crate backtrace;
#[cfg(feature = "servo")] #[allow(unused_extern_crates)] #[macro_use] extern crate bitflags;
extern crate deque;
extern crate euclid;
extern crate getopts;
extern crate heapsize;
extern crate ipc_channel;
#[allow(unused_extern_crates)]
#[macro_use]
extern crate lazy_static;
#[macro_use] extern crate heapsize;
#[cfg(feature = "servo")] extern crate ipc_channel;
#[allow(unused_extern_crates)] #[macro_use] extern crate lazy_static;
extern crate libc;
#[macro_use]
extern crate log;
#[macro_use] extern crate log;
extern crate num_cpus;
extern crate num_traits;
extern crate rand;
extern crate rustc_serialize;
extern crate serde;
#[cfg(feature = "servo")] extern crate serde;
extern crate smallvec;
extern crate url;
#[cfg(all(unix, not(target_os = "macos"), not(target_os = "ios"), not(target_os = "android")))]
@ -44,28 +36,24 @@ use std::sync::Arc;
pub mod basedir;
pub mod cache;
#[allow(unsafe_code)]
pub mod debug_utils;
#[allow(unsafe_code)] pub mod debug_utils;
pub mod geometry;
#[allow(unsafe_code)]
pub mod ipc;
pub mod linked_list;
#[allow(unsafe_code)]
pub mod opts;
pub mod panicking;
#[cfg(feature = "servo")] #[allow(unsafe_code)] pub mod ipc;
#[cfg(feature = "servo")] pub mod linked_list;
#[allow(unsafe_code)] pub mod opts;
#[cfg(feature = "servo")] pub mod panicking;
pub mod prefs;
pub mod print_tree;
#[cfg(feature = "servo")] pub mod print_tree;
pub mod resource_files;
#[allow(unsafe_code)]
pub mod str;
pub mod thread;
pub mod thread_state;
#[cfg(feature = "servo")] pub mod thread;
#[cfg(feature = "servo")] pub mod thread_state;
pub mod tid;
pub mod time;
#[cfg(feature = "servo")] pub mod time;
pub mod vec;
#[allow(unsafe_code)]
pub mod workqueue;
#[cfg(feature = "servo")] #[allow(unsafe_code)] pub mod workqueue;
#[cfg(feature = "servo")]
#[allow(unsafe_code)]
pub fn breakpoint() {
unsafe { ::std::intrinsics::breakpoint() };

View file

@ -23,7 +23,8 @@ use url::{self, Url};
/// Global flags for Servo, currently set on the command line.
#[derive(Clone, Deserialize, Serialize)]
#[derive(Clone)]
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
pub struct Opts {
pub is_running_problem_test: bool,
@ -379,7 +380,8 @@ pub fn print_debug_usage(app: &str) -> ! {
process::exit(0)
}
#[derive(Clone, Deserialize, Serialize)]
#[derive(Clone)]
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
pub enum OutputOptions {
FileName(String),
Stdout(f64)
@ -404,7 +406,8 @@ enum UserAgent {
Android,
}
#[derive(Clone, Debug, Eq, Deserialize, PartialEq, Serialize)]
#[derive(Clone, Debug, Eq, PartialEq)]
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
pub enum RenderApi {
GL,
ES2,
@ -858,7 +861,7 @@ pub fn set_defaults(opts: Opts) {
unsafe {
assert!(DEFAULT_OPTIONS.is_null());
assert!(DEFAULT_OPTIONS != INVALID_OPTIONS);
let box_opts = box opts;
let box_opts = Box::new(opts);
DEFAULT_OPTIONS = Box::into_raw(box_opts);
}
}

View file

@ -20,7 +20,8 @@ lazy_static! {
};
}
#[derive(PartialEq, Clone, Debug, Deserialize, Serialize)]
#[derive(PartialEq, Clone, Debug)]
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
pub enum PrefValue {
Boolean(bool),
String(String),
@ -91,7 +92,8 @@ impl ToJson for PrefValue {
}
}
#[derive(Clone, Debug, Deserialize, Serialize)]
#[derive(Clone, Debug)]
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
pub enum Pref {
NoDefault(Arc<PrefValue>),
WithDefault(Arc<PrefValue>, Option<Arc<PrefValue>>)

View file

@ -9,10 +9,13 @@ use super::smallvec::VecLike;
// TODO(pcwalton): Speed up with SIMD, or better yet, find some way to not do this.
pub fn byte_swap(data: &mut [u8]) {
let length = data.len();
for i in (0..length).step_by(4) {
// FIXME(rust #27741): Range::step_by is not stable yet as of this writing.
let mut i = 0;
while i < length {
let r = data[i + 2];
data[i + 2] = data[i + 0];
data[i + 0] = r;
i += 4;
}
}