diff options
48 files changed, 102 insertions, 160 deletions
diff --git a/components/derive_common/Cargo.toml b/components/derive_common/Cargo.toml index 411219810de..d251949499f 100644 --- a/components/derive_common/Cargo.toml +++ b/components/derive_common/Cargo.toml @@ -3,6 +3,7 @@ name = "derive_common" version = "0.0.1" authors = ["The Servo Project Developers"] license = "MPL-2.0" +edition = "2018" publish = false [lib] diff --git a/components/derive_common/cg.rs b/components/derive_common/cg.rs index ab4b8e52760..93b624483c7 100644 --- a/components/derive_common/cg.rs +++ b/components/derive_common/cg.rs @@ -4,8 +4,8 @@ use darling::{FromDeriveInput, FromField, FromVariant}; use proc_macro2::{Span, TokenStream}; -use quote::TokenStreamExt; -use syn::{self, AngleBracketedGenericArguments, Binding, DeriveInput, Field}; +use quote::{quote, TokenStreamExt}; +use syn::{self, parse_quote, AngleBracketedGenericArguments, Binding, DeriveInput, Field}; use syn::{GenericArgument, GenericParam, Ident, Path}; use syn::{PathArguments, PathSegment, QSelf, Type, TypeArray, TypeGroup}; use syn::{TypeParam, TypeParen, TypePath, TypeSlice, TypeTuple}; diff --git a/components/derive_common/lib.rs b/components/derive_common/lib.rs index 14415351449..de1a5cf75b2 100644 --- a/components/derive_common/lib.rs +++ b/components/derive_common/lib.rs @@ -2,12 +2,4 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -extern crate darling; -extern crate proc_macro2; -#[macro_use] -extern crate quote; -#[macro_use] -extern crate syn; -extern crate synstructure; - pub mod cg; diff --git a/components/dom_struct/Cargo.toml b/components/dom_struct/Cargo.toml index 211ad92cbb0..4fdf253d56c 100644 --- a/components/dom_struct/Cargo.toml +++ b/components/dom_struct/Cargo.toml @@ -2,6 +2,7 @@ authors = ["The Servo Project Developers"] license = "MPL-2.0" name = "dom_struct" +edition = "2018" publish = false version = "0.0.1" diff --git a/components/dom_struct/lib.rs b/components/dom_struct/lib.rs index ff95e7d838a..8d852e8fb7c 100644 --- a/components/dom_struct/lib.rs +++ b/components/dom_struct/lib.rs @@ -2,12 +2,8 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -extern crate proc_macro; -#[macro_use] -extern crate quote; -extern crate syn; - use proc_macro::TokenStream; +use quote::quote; use syn::*; #[proc_macro_attribute] diff --git a/components/fallible/Cargo.toml b/components/fallible/Cargo.toml index bccdaaaf7c6..59d5a7519fe 100644 --- a/components/fallible/Cargo.toml +++ b/components/fallible/Cargo.toml @@ -3,6 +3,7 @@ name = "fallible" version = "0.0.1" authors = ["The Servo Project Developers"] license = "MPL-2.0" +edition = "2018" publish = false [lib] diff --git a/components/fallible/lib.rs b/components/fallible/lib.rs index 1e01e8f80e9..f7506afd510 100644 --- a/components/fallible/lib.rs +++ b/components/fallible/lib.rs @@ -2,9 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -extern crate hashglobe; -extern crate smallvec; - #[cfg(feature = "known_system_malloc")] use hashglobe::alloc; use hashglobe::FailedAllocationError; diff --git a/components/hashglobe/Cargo.toml b/components/hashglobe/Cargo.toml index b8571e68c69..895db6f3fc8 100644 --- a/components/hashglobe/Cargo.toml +++ b/components/hashglobe/Cargo.toml @@ -7,6 +7,7 @@ description = "Fork of std::HashMap with stable fallible allocation." documentation = "https://docs.rs/hashglobe" repository = "https://github.com/Manishearth/hashglobe" readme = "README.md" +edition = "2018" [dependencies] libc = "0.2" diff --git a/components/hashglobe/src/hash_map.rs b/components/hashglobe/src/hash_map.rs index d2893627e1d..33a0d7d5019 100644 --- a/components/hashglobe/src/hash_map.rs +++ b/components/hashglobe/src/hash_map.rs @@ -2218,7 +2218,7 @@ mod test_map { use super::Entry::{Occupied, Vacant}; use super::HashMap; use super::RandomState; - use cell::RefCell; + use std::cell::RefCell; #[test] fn test_zero_capacities() { diff --git a/components/hashglobe/src/hash_set.rs b/components/hashglobe/src/hash_set.rs index ef373ae3710..d81eeda7d53 100644 --- a/components/hashglobe/src/hash_set.rs +++ b/components/hashglobe/src/hash_set.rs @@ -1577,7 +1577,7 @@ mod test_set { #[test] fn test_replace() { - use hash; + use std::hash; #[derive(Debug)] struct Foo(&'static str, i32); diff --git a/components/malloc_size_of/Cargo.toml b/components/malloc_size_of/Cargo.toml index cedfb2f5200..6cccc9ae622 100644 --- a/components/malloc_size_of/Cargo.toml +++ b/components/malloc_size_of/Cargo.toml @@ -3,6 +3,7 @@ name = "malloc_size_of" version = "0.0.1" authors = ["The Servo Project Developers"] license = "MIT OR Apache-2.0" +edition = "2018" publish = false [lib] diff --git a/components/malloc_size_of/lib.rs b/components/malloc_size_of/lib.rs index 559d10e5926..6822a70702b 100644 --- a/components/malloc_size_of/lib.rs +++ b/components/malloc_size_of/lib.rs @@ -47,45 +47,6 @@ //! publishing this crate on crates.io. #[cfg(feature = "servo")] -extern crate accountable_refcell; -extern crate app_units; -#[cfg(feature = "servo")] -extern crate content_security_policy; -#[cfg(feature = "servo")] -extern crate crossbeam_channel; -extern crate cssparser; -extern crate euclid; -extern crate hashglobe; -#[cfg(feature = "servo")] -extern crate http; -#[cfg(feature = "servo")] -extern crate hyper_serde; -#[cfg(feature = "servo")] -extern crate keyboard_types; -extern crate selectors; -#[cfg(feature = "servo")] -extern crate serde; -#[cfg(feature = "servo")] -extern crate serde_bytes; -extern crate servo_arc; -extern crate smallbitvec; -extern crate smallvec; -#[cfg(feature = "servo")] -extern crate string_cache; -extern crate thin_slice; -#[cfg(feature = "servo")] -extern crate time; -#[cfg(feature = "url")] -extern crate url; -#[cfg(feature = "servo")] -extern crate uuid; -extern crate void; -#[cfg(feature = "webrender_api")] -extern crate webrender_api; -#[cfg(feature = "servo")] -extern crate xml5ever; - -#[cfg(feature = "servo")] use content_security_policy as csp; #[cfg(feature = "servo")] use serde_bytes::ByteBuf; diff --git a/components/script_plugins/Cargo.toml b/components/script_plugins/Cargo.toml index c6bc3eb2250..8bf9ce325ee 100644 --- a/components/script_plugins/Cargo.toml +++ b/components/script_plugins/Cargo.toml @@ -3,6 +3,7 @@ name = "script_plugins" version = "0.0.1" authors = ["The Servo Project Developers"] license = "MPL-2.0" +edition = "2018" publish = false [lib] diff --git a/components/selectors/Cargo.toml b/components/selectors/Cargo.toml index 08152f76ac9..73882c64273 100644 --- a/components/selectors/Cargo.toml +++ b/components/selectors/Cargo.toml @@ -9,6 +9,7 @@ readme = "README.md" keywords = ["css", "selectors"] license = "MPL-2.0" build = "build.rs" +edition = "2018" [lib] name = "selectors" diff --git a/components/selectors/attr.rs b/components/selectors/attr.rs index 4f790ff7d57..91588b3b389 100644 --- a/components/selectors/attr.rs +++ b/components/selectors/attr.rs @@ -5,6 +5,8 @@ use crate::parser::SelectorImpl; use cssparser::ToCss; use std::fmt; +#[cfg(feature = "shmem")] +use to_shmem_derive::ToShmem; #[derive(Clone, Eq, PartialEq)] #[cfg_attr(feature = "shmem", derive(ToShmem))] diff --git a/components/selectors/build.rs b/components/selectors/build.rs index c5c3803991e..a4b07b3d430 100644 --- a/components/selectors/build.rs +++ b/components/selectors/build.rs @@ -2,8 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -extern crate phf_codegen; - use std::env; use std::fs::File; use std::io::{BufWriter, Write}; diff --git a/components/selectors/builder.rs b/components/selectors/builder.rs index 58e6cbafe93..6a3f5badf2b 100644 --- a/components/selectors/builder.rs +++ b/components/selectors/builder.rs @@ -19,12 +19,16 @@ use crate::parser::{Combinator, Component, SelectorImpl}; use crate::sink::Push; +use bitflags::bitflags; +use derive_more::{Add, AddAssign}; use servo_arc::{Arc, HeaderWithLength, ThinArc}; use smallvec::{self, SmallVec}; use std::cmp; use std::iter; use std::ptr; use std::slice; +#[cfg(feature = "shmem")] +use to_shmem_derive::ToShmem; /// Top-level SelectorBuilder struct. This should be stack-allocated by the /// consumer and never moved (because it contains a lot of inline data that diff --git a/components/selectors/lib.rs b/components/selectors/lib.rs index 896a1dfbf3f..17f81c535b6 100644 --- a/components/selectors/lib.rs +++ b/components/selectors/lib.rs @@ -5,25 +5,6 @@ // Make |cargo bench| work. #![cfg_attr(feature = "bench", feature(test))] -#[macro_use] -extern crate bitflags; -#[macro_use] -extern crate cssparser; -#[macro_use] -extern crate derive_more; -extern crate fxhash; -#[macro_use] -extern crate log; -extern crate phf; -extern crate precomputed_hash; -extern crate servo_arc; -extern crate smallvec; -#[cfg(feature = "shmem")] -extern crate to_shmem; -#[cfg(feature = "shmem")] -#[macro_use] -extern crate to_shmem_derive; - pub mod attr; pub mod bloom; mod builder; diff --git a/components/selectors/matching.rs b/components/selectors/matching.rs index 1d116063240..92c13958985 100644 --- a/components/selectors/matching.rs +++ b/components/selectors/matching.rs @@ -8,6 +8,8 @@ use crate::nth_index_cache::NthIndexCacheInner; use crate::parser::{AncestorHashes, Combinator, Component, LocalName}; use crate::parser::{NonTSPseudoClass, Selector, SelectorImpl, SelectorIter, SelectorList}; use crate::tree::Element; +use bitflags::bitflags; +use log::debug; use smallvec::SmallVec; use std::borrow::Borrow; use std::iter; diff --git a/components/selectors/parser.rs b/components/selectors/parser.rs index 412658582b7..e99b1b18412 100644 --- a/components/selectors/parser.rs +++ b/components/selectors/parser.rs @@ -10,7 +10,8 @@ use crate::builder::{SelectorBuilder, SelectorFlags, SpecificityAndFlags}; use crate::context::QuirksMode; use crate::sink::Push; pub use crate::visitor::SelectorVisitor; -use cssparser::parse_nth; +use bitflags::bitflags; +use cssparser::{match_ignore_ascii_case, parse_nth, *}; use cssparser::{BasicParseError, BasicParseErrorKind, ParseError, ParseErrorKind}; use cssparser::{CowRcStr, Delimiter, SourceLocation}; use cssparser::{Parser as CssParser, ToCss, Token}; @@ -21,6 +22,8 @@ use std::borrow::{Borrow, Cow}; use std::fmt::{self, Debug}; use std::iter::Rev; use std::slice; +#[cfg(feature = "shmem")] +use to_shmem_derive::ToShmem; /// A trait that represents a pseudo-element. pub trait PseudoElement: Sized + ToCss { diff --git a/components/servo_arc/Cargo.toml b/components/servo_arc/Cargo.toml index a2cb0750f1a..f2de2d13606 100644 --- a/components/servo_arc/Cargo.toml +++ b/components/servo_arc/Cargo.toml @@ -5,6 +5,7 @@ authors = ["The Servo Project Developers"] license = "MIT OR Apache-2.0" repository = "https://github.com/servo/servo" description = "A fork of std::sync::Arc with some extra functionality and without weak references" +edition = "2018" [lib] name = "servo_arc" diff --git a/components/servo_arc/lib.rs b/components/servo_arc/lib.rs index 27ea8e9ba71..cff93a5d524 100644 --- a/components/servo_arc/lib.rs +++ b/components/servo_arc/lib.rs @@ -25,11 +25,6 @@ // duplicate those here. #![allow(missing_docs)] -extern crate nodrop; -#[cfg(feature = "servo")] -extern crate serde; -extern crate stable_deref_trait; - use nodrop::NoDrop; #[cfg(feature = "servo")] use serde::{Deserialize, Serialize}; diff --git a/components/size_of_test/Cargo.toml b/components/size_of_test/Cargo.toml index bb6c8182443..4776581cc52 100644 --- a/components/size_of_test/Cargo.toml +++ b/components/size_of_test/Cargo.toml @@ -3,6 +3,7 @@ name = "size_of_test" version = "0.0.1" authors = ["The Servo Project Developers"] license = "MPL-2.0" +edition = "2018" publish = false [lib] diff --git a/components/std_test_override/Cargo.toml b/components/std_test_override/Cargo.toml index 32ecaaa6d65..483d46c0ec4 100644 --- a/components/std_test_override/Cargo.toml +++ b/components/std_test_override/Cargo.toml @@ -3,6 +3,7 @@ name = "std_test_override" version = "0.0.1" authors = ["The Servo Project Developers"] license = "MPL-2.0" +edition = "2018" publish = false [lib] diff --git a/components/std_test_override/lib.rs b/components/std_test_override/lib.rs index 92c71a5efa0..0d3d26c2fbf 100644 --- a/components/std_test_override/lib.rs +++ b/components/std_test_override/lib.rs @@ -4,7 +4,6 @@ #![feature(test)] -extern crate embedder_traits; extern crate test; pub use test::*; diff --git a/components/style_derive/Cargo.toml b/components/style_derive/Cargo.toml index af8fa41aa75..d5b71ace70f 100644 --- a/components/style_derive/Cargo.toml +++ b/components/style_derive/Cargo.toml @@ -3,6 +3,7 @@ name = "style_derive" version = "0.0.1" authors = ["The Servo Project Developers"] license = "MPL-2.0" +edition = "2018" publish = false [lib] diff --git a/components/style_derive/animate.rs b/components/style_derive/animate.rs index 9549100ad08..daa34f56e51 100644 --- a/components/style_derive/animate.rs +++ b/components/style_derive/animate.rs @@ -3,10 +3,14 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use darling::util::PathList; +use darling::FromDeriveInput; +use darling::FromField; +use darling::FromVariant; use derive_common::cg; use proc_macro2::TokenStream; +use quote::quote; use quote::TokenStreamExt; -use syn::{DeriveInput, WhereClause}; +use syn::{parse_quote, DeriveInput, WhereClause}; use synstructure::{Structure, VariantInfo}; pub fn derive(mut input: DeriveInput) -> TokenStream { diff --git a/components/style_derive/compute_squared_distance.rs b/components/style_derive/compute_squared_distance.rs index 022ab115eea..04866b8ac7d 100644 --- a/components/style_derive/compute_squared_distance.rs +++ b/components/style_derive/compute_squared_distance.rs @@ -3,10 +3,12 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::animate::{AnimationFieldAttrs, AnimationInputAttrs, AnimationVariantAttrs}; +use darling::FromField; use derive_common::cg; use proc_macro2::TokenStream; +use quote::quote; use quote::TokenStreamExt; -use syn::{DeriveInput, WhereClause}; +use syn::{parse_quote, DeriveInput, WhereClause}; use synstructure; pub fn derive(mut input: DeriveInput) -> TokenStream { diff --git a/components/style_derive/lib.rs b/components/style_derive/lib.rs index 079db00c5a3..a2c39f84308 100644 --- a/components/style_derive/lib.rs +++ b/components/style_derive/lib.rs @@ -4,17 +4,6 @@ #![recursion_limit = "128"] -#[macro_use] -extern crate darling; -extern crate derive_common; -extern crate proc_macro; -extern crate proc_macro2; -#[macro_use] -extern crate quote; -#[macro_use] -extern crate syn; -extern crate synstructure; - use proc_macro::TokenStream; mod animate; diff --git a/components/style_derive/parse.rs b/components/style_derive/parse.rs index 345decce28c..18ff31c0526 100644 --- a/components/style_derive/parse.rs +++ b/components/style_derive/parse.rs @@ -3,8 +3,12 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::to_css::CssVariantAttrs; +use darling::FromField; +use darling::FromVariant; use derive_common::cg; use proc_macro2::TokenStream; +use quote::quote; +use syn::parse_quote; use syn::{self, DeriveInput, Path}; use synstructure::{Structure, VariantInfo}; @@ -54,7 +58,7 @@ fn parse_non_keyword_variant( } } else { quote! { - if let Ok(v) = input.try(|i| <#ty as crate::parser::Parse>::parse(context, i)) { + if let Ok(v) = input.r#try(|i| <#ty as crate::parser::Parse>::parse(context, i)) { return Ok(#name::#variant_name(v)); } } diff --git a/components/style_derive/specified_value_info.rs b/components/style_derive/specified_value_info.rs index c477f4a7cf9..d198990cca4 100644 --- a/components/style_derive/specified_value_info.rs +++ b/components/style_derive/specified_value_info.rs @@ -4,10 +4,14 @@ use crate::parse::ParseVariantAttrs; use crate::to_css::{CssFieldAttrs, CssInputAttrs, CssVariantAttrs}; +use darling::FromDeriveInput; +use darling::FromField; +use darling::FromVariant; use derive_common::cg; use proc_macro2::TokenStream; +use quote::quote; use quote::TokenStreamExt; -use syn::{Data, DeriveInput, Fields, Ident, Type}; +use syn::{parse_quote, Data, DeriveInput, Fields, Ident, Type}; pub fn derive(mut input: DeriveInput) -> TokenStream { let css_attrs = cg::parse_input_attrs::<CssInputAttrs>(&input); diff --git a/components/style_derive/to_animated_value.rs b/components/style_derive/to_animated_value.rs index 45282f0c448..e6a79e4dc7f 100644 --- a/components/style_derive/to_animated_value.rs +++ b/components/style_derive/to_animated_value.rs @@ -2,10 +2,11 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ +use crate::to_computed_value; use proc_macro2::TokenStream; -use syn::DeriveInput; +use quote::quote; +use syn::{parse_quote, DeriveInput}; use synstructure::BindStyle; -use to_computed_value; pub fn derive(input: DeriveInput) -> TokenStream { let trait_impl = |from_body, to_body| { diff --git a/components/style_derive/to_animated_zero.rs b/components/style_derive/to_animated_zero.rs index 008e94cbcfb..ea2eebc2bf2 100644 --- a/components/style_derive/to_animated_zero.rs +++ b/components/style_derive/to_animated_zero.rs @@ -5,8 +5,9 @@ use crate::animate::{AnimationFieldAttrs, AnimationInputAttrs, AnimationVariantAttrs}; use derive_common::cg; use proc_macro2::TokenStream; +use quote::quote; use quote::TokenStreamExt; -use syn; +use syn::{self, parse_quote}; use synstructure; pub fn derive(mut input: syn::DeriveInput) -> TokenStream { diff --git a/components/style_derive/to_computed_value.rs b/components/style_derive/to_computed_value.rs index 5e0f595c6b9..b14c4bc3dee 100644 --- a/components/style_derive/to_computed_value.rs +++ b/components/style_derive/to_computed_value.rs @@ -2,8 +2,11 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ +use darling::FromField; use derive_common::cg; use proc_macro2::TokenStream; +use quote::quote; +use syn::parse_quote; use syn::{DeriveInput, Ident, Path}; use synstructure::{BindStyle, BindingInfo}; diff --git a/components/style_derive/to_css.rs b/components/style_derive/to_css.rs index f939d1d0372..1f94751f889 100644 --- a/components/style_derive/to_css.rs +++ b/components/style_derive/to_css.rs @@ -3,9 +3,14 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use darling::util::Override; +use darling::FromDeriveInput; +use darling::FromField; +use darling::FromVariant; use derive_common::cg; use proc_macro2::TokenStream; +use quote::quote; use quote::{ToTokens, TokenStreamExt}; +use syn::parse_quote; use syn::{self, Data, Path, WhereClause}; use synstructure::{BindingInfo, Structure, VariantInfo}; diff --git a/components/style_derive/to_resolved_value.rs b/components/style_derive/to_resolved_value.rs index e049f91152a..47933940e8a 100644 --- a/components/style_derive/to_resolved_value.rs +++ b/components/style_derive/to_resolved_value.rs @@ -2,11 +2,13 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ +use crate::to_computed_value; +use darling::FromField; use derive_common::cg; use proc_macro2::TokenStream; -use syn::DeriveInput; +use quote::quote; +use syn::{parse_quote, DeriveInput}; use synstructure::BindStyle; -use to_computed_value; pub fn derive(input: DeriveInput) -> TokenStream { let trait_impl = |from_body, to_body| { diff --git a/components/style_traits/Cargo.toml b/components/style_traits/Cargo.toml index 041c4305f77..f7cb05c1a3a 100644 --- a/components/style_traits/Cargo.toml +++ b/components/style_traits/Cargo.toml @@ -3,6 +3,7 @@ name = "style_traits" version = "0.0.1" authors = ["The Servo Project Developers"] license = "MPL-2.0" +edition = "2018" publish = false [lib] diff --git a/components/style_traits/arc_slice.rs b/components/style_traits/arc_slice.rs index 8d55beff3c5..95afe6b3aad 100644 --- a/components/style_traits/arc_slice.rs +++ b/components/style_traits/arc_slice.rs @@ -4,12 +4,14 @@ //! A thin atomically-reference-counted slice. +use lazy_static::lazy_static; use serde::de::{Deserialize, Deserializer}; use serde::ser::{Serialize, Serializer}; use servo_arc::ThinArc; use std::ops::Deref; use std::ptr::NonNull; use std::{iter, mem}; +use to_shmem_derive::ToShmem; /// A canary that we stash in ArcSlices. /// diff --git a/components/style_traits/dom.rs b/components/style_traits/dom.rs index 03d5264abf5..78bc9e0d3fb 100644 --- a/components/style_traits/dom.rs +++ b/components/style_traits/dom.rs @@ -4,6 +4,9 @@ //! Types used to access the DOM from style calculation. +use malloc_size_of_derive::MallocSizeOf; +use serde::{Deserialize, Serialize}; + /// An opaque handle to a node, which, unlike UnsafeNode, cannot be transformed /// back into a non-opaque representation. The only safe operation that can be /// performed on this node is to compare it to another opaque handle or to another diff --git a/components/style_traits/lib.rs b/components/style_traits/lib.rs index be2d275b654..28260272d66 100644 --- a/components/style_traits/lib.rs +++ b/components/style_traits/lib.rs @@ -10,30 +10,9 @@ #![crate_type = "rlib"] #![deny(unsafe_code, missing_docs)] -extern crate app_units; -#[macro_use] -extern crate bitflags; -#[macro_use] -extern crate cssparser; -extern crate euclid; -#[macro_use] -extern crate lazy_static; -extern crate malloc_size_of; -#[macro_use] -extern crate malloc_size_of_derive; -extern crate selectors; -#[macro_use] -extern crate serde; -extern crate servo_arc; -#[cfg(feature = "servo")] -extern crate servo_atoms; -#[cfg(feature = "servo")] -extern crate servo_url; -extern crate to_shmem; -#[macro_use] -extern crate to_shmem_derive; -#[cfg(feature = "servo")] -extern crate webrender_api; +use bitflags::bitflags; +use malloc_size_of_derive::MallocSizeOf; +use serde::{Deserialize, Serialize}; #[cfg(feature = "servo")] pub use webrender_api::units::DevicePixel; diff --git a/components/style_traits/owned_str.rs b/components/style_traits/owned_str.rs index ebfdcd5e066..05a3738ac4d 100644 --- a/components/style_traits/owned_str.rs +++ b/components/style_traits/owned_str.rs @@ -7,8 +7,10 @@ //! A replacement for `Box<str>` that has a defined layout for FFI. use crate::owned_slice::OwnedSlice; +use malloc_size_of_derive::MallocSizeOf; use std::fmt; use std::ops::{Deref, DerefMut}; +use to_shmem_derive::ToShmem; /// A struct that basically replaces a Box<str>, but with a defined layout, /// suitable for FFI. diff --git a/components/style_traits/values.rs b/components/style_traits/values.rs index 05ba0b5f2a5..124626bc973 100644 --- a/components/style_traits/values.rs +++ b/components/style_traits/values.rs @@ -348,7 +348,7 @@ impl Separator for Space { let mut results = vec![parse_one(input)?]; loop { input.skip_whitespace(); // Unnecessary for correctness, but may help try() rewind less. - if let Ok(item) = input.try(&mut parse_one) { + if let Ok(item) = input.r#try(&mut parse_one) { results.push(item); } else { return Ok(results); @@ -374,9 +374,9 @@ impl Separator for CommaWithSpace { loop { input.skip_whitespace(); // Unnecessary for correctness, but may help try() rewind less. let comma_location = input.current_source_location(); - let comma = input.try(|i| i.expect_comma()).is_ok(); + let comma = input.r#try(|i| i.expect_comma()).is_ok(); input.skip_whitespace(); // Unnecessary for correctness, but may help try() rewind less. - if let Ok(item) = input.try(&mut parse_one) { + if let Ok(item) = input.r#try(&mut parse_one) { results.push(item); } else if comma { return Err(comma_location.new_unexpected_token_error(Token::Comma)); @@ -478,8 +478,9 @@ impl_to_css_for_predefined_type!(::cssparser::UnicodeRange); macro_rules! define_css_keyword_enum { (pub enum $name:ident { $($variant:ident = $css:expr,)+ }) => { #[allow(missing_docs)] - #[cfg_attr(feature = "servo", derive(Deserialize, Serialize))] - #[derive(Clone, Copy, Debug, Eq, Hash, MallocSizeOf, PartialEq, ToShmem)] + #[cfg_attr(feature = "servo", derive(serde::Deserialize, serde::Serialize))] + #[derive(Clone, Copy, Debug, Eq, Hash, + malloc_size_of_derive::MallocSizeOf, PartialEq, to_shmem_derive::ToShmem)] pub enum $name { $($variant),+ } @@ -506,7 +507,7 @@ macro_rules! define_css_keyword_enum { /// Parse this property from an already-tokenized identifier. pub fn from_ident(ident: &str) -> Result<$name, ()> { - match_ignore_ascii_case! { ident, + cssparser::match_ignore_ascii_case! { ident, $($css => Ok($name::$variant),)+ _ => Err(()) } @@ -532,11 +533,22 @@ macro_rules! define_css_keyword_enum { /// Helper types for the handling of specified values. pub mod specified { use crate::ParsingMode; + use malloc_size_of_derive::MallocSizeOf; + use serde::{Deserialize, Serialize}; /// Whether to allow negative lengths or not. #[repr(u8)] #[derive( - Clone, Copy, Debug, Deserialize, Eq, MallocSizeOf, PartialEq, PartialOrd, Serialize, ToShmem, + Clone, + Copy, + Debug, + Deserialize, + Eq, + MallocSizeOf, + PartialEq, + PartialOrd, + Serialize, + to_shmem_derive::ToShmem, )] pub enum AllowedNumericType { /// Allow all kind of numeric values. diff --git a/components/style_traits/viewport.rs b/components/style_traits/viewport.rs index eff1dfca7ad..4f59f74a764 100644 --- a/components/style_traits/viewport.rs +++ b/components/style_traits/viewport.rs @@ -5,9 +5,12 @@ //! Helper types for the `@viewport` rule. use crate::{CSSPixel, CssWriter, ParseError, PinchZoomFactor, ToCss}; -use cssparser::Parser; +use cssparser::*; use euclid::Size2D; +use malloc_size_of_derive::MallocSizeOf; +use serde::{Deserialize, Serialize}; use std::fmt::{self, Write}; +use to_shmem_derive::ToShmem; define_css_keyword_enum! { pub enum UserZoom { @@ -114,7 +117,6 @@ impl Zoom { pub fn parse<'i, 't>(input: &mut Parser<'i, 't>) -> Result<Zoom, ParseError<'i>> { use crate::values::specified::AllowedNumericType::NonNegative; use crate::ParsingMode; - use cssparser::Token; let location = input.current_source_location(); match *input.next()? { diff --git a/components/to_shmem/Cargo.toml b/components/to_shmem/Cargo.toml index ca1fd8675a1..31039d5520b 100644 --- a/components/to_shmem/Cargo.toml +++ b/components/to_shmem/Cargo.toml @@ -3,6 +3,7 @@ name = "to_shmem" version = "0.0.1" authors = ["The Servo Project Developers"] license = "MPL-2.0" +edition = "2018" publish = false [lib] diff --git a/components/to_shmem/lib.rs b/components/to_shmem/lib.rs index 47dc8d17eff..9188346eb59 100644 --- a/components/to_shmem/lib.rs +++ b/components/to_shmem/lib.rs @@ -12,14 +12,6 @@ #![crate_name = "to_shmem"] #![crate_type = "rlib"] -extern crate cssparser; -extern crate servo_arc; -extern crate smallbitvec; -extern crate smallvec; -#[cfg(feature = "string_cache")] -extern crate string_cache; -extern crate thin_slice; - use servo_arc::{Arc, ThinArc}; use smallbitvec::{InternalStorage, SmallBitVec}; use smallvec::{Array, SmallVec}; diff --git a/components/to_shmem_derive/Cargo.toml b/components/to_shmem_derive/Cargo.toml index 1ddb0974d7c..d9c2e2773c8 100644 --- a/components/to_shmem_derive/Cargo.toml +++ b/components/to_shmem_derive/Cargo.toml @@ -3,6 +3,7 @@ name = "to_shmem_derive" version = "0.0.1" authors = ["The Servo Project Developers"] license = "MPL-2.0" +edition = "2018" publish = false [lib] diff --git a/components/to_shmem_derive/lib.rs b/components/to_shmem_derive/lib.rs index b820e7f85d0..95baf513e0f 100644 --- a/components/to_shmem_derive/lib.rs +++ b/components/to_shmem_derive/lib.rs @@ -4,17 +4,6 @@ #![recursion_limit = "128"] -#[macro_use] -extern crate darling; -extern crate derive_common; -extern crate proc_macro; -extern crate proc_macro2; -#[macro_use] -extern crate quote; -#[macro_use] -extern crate syn; -extern crate synstructure; - use proc_macro::TokenStream; mod to_shmem; diff --git a/components/to_shmem_derive/to_shmem.rs b/components/to_shmem_derive/to_shmem.rs index 157730c5a51..130cece2bc9 100644 --- a/components/to_shmem_derive/to_shmem.rs +++ b/components/to_shmem_derive/to_shmem.rs @@ -2,9 +2,11 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ +use darling::{FromDeriveInput, FromField}; use derive_common::cg; use proc_macro2::TokenStream; -use syn; +use quote::quote; +use syn::{self, parse_quote}; use synstructure::{BindStyle, Structure}; pub fn derive(mut input: syn::DeriveInput) -> TokenStream { |