Auto merge of #11816 - servo:stable-style, r=nox

Make the style crate (almost) build with a stable compiler

<!-- Please describe your changes on the following line: -->

The bulk of this is adding cargo features to make derived implementations of `heapsize` and `serde` traits optional.

"Almost" because `std::intrinsics::discriminant_value` is currently unstable and doesn’t have any stable replacement that I know of. For now, this PR conditionally replaces it with `unimplemented!()`.

r? @nox

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes <s>fix</s> are part of #11815 (github issue number if applicable).

<!-- Either: -->
- [ ] There are tests for these changes OR
- [x] These changes do not <s>require tests</s> *have tests yet* because that requires https://github.com/servo/servo/issues/11806, but I still want to land this before it bitrots. (Tests should check that the build succeeds with a stable compiler.)

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11816)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2016-06-22 09:43:20 -05:00 committed by GitHub
commit 0fb5d634a0
63 changed files with 506 additions and 348 deletions

4
ports/cef/Cargo.lock generated
View file

@ -2100,7 +2100,6 @@ dependencies = [
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)",
"plugins 0.0.1",
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
"selectors 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 0.7.10 (registry+https://github.com/rust-lang/crates.io-index)",
@ -2122,7 +2121,6 @@ dependencies = [
"euclid 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)",
"heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"heapsize_plugin 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"plugins 0.0.1",
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 0.7.10 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_macros 0.7.10 (registry+https://github.com/rust-lang/crates.io-index)",
@ -2307,7 +2305,6 @@ dependencies = [
"euclid 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)",
"getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
"heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"heapsize_plugin 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"ipc-channel 0.2.3 (git+https://github.com/servo/ipc-channel)",
"kernel32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
@ -2315,7 +2312,6 @@ dependencies = [
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)",
"num_cpus 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)",
"plugins 0.0.1",
"rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 0.7.10 (registry+https://github.com/rust-lang/crates.io-index)",

View file

@ -8,12 +8,10 @@ dependencies = [
"euclid 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)",
"gecko_bindings 0.0.1",
"heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"heapsize_plugin 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"num_cpus 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)",
"plugins 0.0.1",
"selectors 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"smallvec 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
"string_cache 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)",
@ -76,7 +74,7 @@ dependencies = [
[[package]]
name = "bincode"
version = "0.5.6"
version = "0.5.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"byteorder 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)",
@ -257,15 +255,14 @@ dependencies = [
[[package]]
name = "ipc-channel"
version = "0.2.3"
source = "git+https://github.com/servo/ipc-channel#48137d69955f5460da586c552de275ecdc3f4efe"
version = "0.2.4"
source = "git+https://github.com/servo/ipc-channel#8411eeabf3a712006ad1b47637b2d8fe71177f85"
dependencies = [
"bincode 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)",
"bincode 0.5.7 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 0.7.10 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_macros 0.7.10 (registry+https://github.com/rust-lang/crates.io-index)",
"uuid 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -319,13 +316,6 @@ dependencies = [
"libc 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "plugins"
version = "0.0.1"
dependencies = [
"tenacious 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "quasi"
version = "0.12.0"
@ -468,7 +458,6 @@ dependencies = [
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)",
"plugins 0.0.1",
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
"selectors 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 0.7.10 (registry+https://github.com/rust-lang/crates.io-index)",
@ -490,18 +479,12 @@ dependencies = [
"euclid 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)",
"heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"heapsize_plugin 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"plugins 0.0.1",
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 0.7.10 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_macros 0.7.10 (registry+https://github.com/rust-lang/crates.io-index)",
"util 0.0.1",
]
[[package]]
name = "tenacious"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "thread-id"
version = "2.0.0"
@ -581,15 +564,13 @@ dependencies = [
"euclid 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)",
"getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
"heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"heapsize_plugin 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"ipc-channel 0.2.3 (git+https://github.com/servo/ipc-channel)",
"ipc-channel 0.2.4 (git+https://github.com/servo/ipc-channel)",
"kernel32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)",
"num_cpus 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)",
"plugins 0.0.1",
"rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 0.7.10 (registry+https://github.com/rust-lang/crates.io-index)",

View file

@ -17,6 +17,8 @@ default = ["servo_features"]
# in the full Servo build. Enabling this reduces the number of things
# recompiled when building both Servo and geckolib in the same source tree.
servo_features = [
"heapsize",
"style/servo",
"time",
"url/query_encoding",
"url/rustc-serialize",
@ -28,8 +30,7 @@ app_units = "0.2.3"
cssparser = "0.5.4"
euclid = "0.6.4"
gecko_bindings = {version = "0.0.1", path = "gecko_bindings"}
heapsize = "0.3.0"
heapsize_plugin = "0.1.2"
heapsize = {version = "0.3.0", optional = true}
lazy_static = "0.2"
libc = "0.2"
num_cpus = "0.2.2"
@ -38,7 +39,6 @@ smallvec = "0.1"
string_cache = {version = "0.2.20", features = ["unstable"]}
url = "1.0.0"
log = {version = "0.3.5", features = ["release_max_level_info"]}
plugins = {path = "../../components/plugins"}
time = {version = "0.1", optional = true, features = ["rustc-serialize"]}
util = {path = "../../components/util"}
uuid = {version = "0.2", optional = true, features = ["v4", "serde"]}

View file

@ -3,8 +3,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#![feature(const_fn)]
#![feature(concat_idents)]
#![feature(type_macros)]
extern crate heapsize;

View file

@ -10,7 +10,7 @@ use std::fmt::{self, Debug};
// in a ThreadSafeFooHolder smart pointer. Used in tandem with the
// NS_DECL_HOLDER_FFI_REFCOUNTING-defined types and functions in Gecko.
macro_rules! define_holder_arc {
($arc_type:ident, $name:ident, $holder_type:ident) => (
($arc_type:ident, $name:ident, $holder_type:ident, $addref: ident, $release: ident) => (
#[derive(PartialEq)]
pub struct $arc_type {
ptr: *mut $holder_type,
@ -19,7 +19,7 @@ macro_rules! define_holder_arc {
impl $arc_type {
pub fn new(data: *mut $holder_type) -> $arc_type {
debug_assert!(!data.is_null());
unsafe { concat_idents!(Gecko_AddRef, $name, ArbitraryThread)(data); }
unsafe { $addref(data); }
$arc_type {
ptr: data
}
@ -39,7 +39,7 @@ macro_rules! define_holder_arc {
impl Drop for $arc_type {
fn drop(&mut self) {
unsafe { concat_idents!(Gecko_Release, $name, ArbitraryThread)(self.ptr); }
unsafe { $release(self.ptr); }
}
}
@ -55,5 +55,7 @@ macro_rules! define_holder_arc {
)
}
define_holder_arc!(GeckoArcPrincipal, Principal, ThreadSafePrincipalHolder);
define_holder_arc!(GeckoArcURI, URI, ThreadSafeURIHolder);
define_holder_arc!(GeckoArcPrincipal, Principal, ThreadSafePrincipalHolder,
Gecko_AddRefPrincipalArbitraryThread, Gecko_ReleasePrincipalArbitraryThread);
define_holder_arc!(GeckoArcURI, URI, ThreadSafeURIHolder,
Gecko_AddRefURIArbitraryThread, Gecko_ReleaseURIArbitraryThread);

View file

@ -3,13 +3,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#![feature(as_unsafe_cell)]
#![feature(box_syntax)]
#![feature(custom_attribute)]
#![feature(custom_derive)]
#![feature(plugin)]
#![plugin(heapsize_plugin)]
#![plugin(plugins)]
extern crate app_units;
#[macro_use]
@ -17,7 +10,7 @@ extern crate cssparser;
extern crate env_logger;
extern crate euclid;
extern crate gecko_bindings;
extern crate heapsize;
#[cfg(feature = "servo_features")] #[macro_use] extern crate heapsize;
#[macro_use]
extern crate lazy_static;
extern crate libc;

View file

@ -136,7 +136,6 @@ impl ComputedValues for GeckoComputedValues {
}
<%def name="declare_style_struct(style_struct)">
#[derive(HeapSizeOf)]
pub struct ${style_struct.gecko_struct_name} {
gecko: ${style_struct.gecko_ffi_name},
}

View file

@ -13,9 +13,12 @@ pub type Stylesheet = style::stylesheets::Stylesheet<GeckoSelectorImpl>;
pub type SharedStyleContext = style::context::SharedStyleContext<GeckoSelectorImpl>;
pub type PrivateStyleData = style::data::PrivateStyleData<GeckoSelectorImpl, GeckoComputedValues>;
#[cfg(feature = "servo_features")]
known_heap_size!(0, GeckoSelectorImpl, PseudoElement, NonTSPseudoClass);
pub struct GeckoSelectorImpl;
#[derive(Clone, Debug, PartialEq, Eq, HeapSizeOf, Hash)]
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub enum PseudoElement {
Before,
After,
@ -46,7 +49,7 @@ pub enum PseudoElement {
}
// https://mxr.mozilla.org/mozilla-central/source/layout/style/nsCSSAnonBoxList.h
#[derive(Clone, Debug, PartialEq, Eq, HeapSizeOf, Hash)]
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub enum AnonBoxPseudoElement {
MozNonElement,
MozAnonymousBlock,
@ -114,7 +117,7 @@ pub enum AnonBoxPseudoElement {
MozSVGText,
}
#[derive(Clone, Debug, PartialEq, Eq, HeapSizeOf, Hash)]
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub enum NonTSPseudoClass {
AnyLink,
Link,

View file

@ -85,7 +85,7 @@ impl<'ln> GeckoNode<'ln> {
pub fn initialize_data(self) {
unsafe {
if self.get_node_data().is_null() {
let ptr: NonOpaqueStyleData = Box::into_raw(box RefCell::new(PrivateStyleData::new()));
let ptr: NonOpaqueStyleData = Box::into_raw(Box::new(RefCell::new(PrivateStyleData::new())));
Gecko_SetNodeData(self.node, ptr as *mut ServoNodeData);
}
}