diff --git a/components/hashglobe/Cargo.toml b/components/hashglobe/Cargo.toml index e92b7fc77945..cffb48919cfc 100644 --- a/components/hashglobe/Cargo.toml +++ b/components/hashglobe/Cargo.toml @@ -14,4 +14,4 @@ libc = "0.2" heapsize = "0.4" [dev-dependencies] -rand = "0.3" \ No newline at end of file +rand = "0.3" diff --git a/components/hashglobe/src/fake.rs b/components/hashglobe/src/fake.rs index baf06ab0470b..a19931f95ecc 100644 --- a/components/hashglobe/src/fake.rs +++ b/components/hashglobe/src/fake.rs @@ -1,16 +1,25 @@ +// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + //! This module contains shims around the stdlib HashMap //! that add fallible methods //! //! These methods are a lie. They are not actually fallible. This is just to make //! it smooth to switch between hashmap impls in a codebase. -use std::hash::{BuildHasher, Hash}; +use heapsize::HeapSizeOf; use std::collections::HashMap as StdMap; use std::collections::HashSet as StdSet; -use std::ops::{Deref, DerefMut}; use std::fmt; - -use heapsize::HeapSizeOf; +use std::hash::{BuildHasher, Hash}; +use std::ops::{Deref, DerefMut}; pub use std::collections::hash_map::{Entry, RandomState, Iter as MapIter, IterMut as MapIterMut}; pub use std::collections::hash_set::{Iter as SetIter, IntoIter as SetIntoIter}; @@ -25,17 +34,16 @@ impl Deref for HashMap { type Target = StdMap; fn deref(&self) -> &Self::Target { &self.0 - } + } } impl DerefMut for HashMap { fn deref_mut(&mut self) -> &mut Self::Target { &mut self.0 - } + } } impl HashMap { - #[inline] pub fn new() -> HashMap { HashMap(StdMap::new()) @@ -63,7 +71,9 @@ impl HashMap } #[inline] - pub fn try_with_capacity_and_hasher(capacity: usize, hash_builder: S) -> Result, FailedAllocationError> { + pub fn try_with_capacity_and_hasher(capacity: usize, + hash_builder: S) + -> Result, FailedAllocationError> { Ok(HashMap(StdMap::with_capacity_and_hasher(capacity, hash_builder))) } @@ -99,17 +109,16 @@ impl Deref for HashSet { type Target = StdSet; fn deref(&self) -> &Self::Target { &self.0 - } + } } impl DerefMut for HashSet { fn deref_mut(&mut self) -> &mut Self::Target { &mut self.0 - } + } } impl HashSet { - #[inline] pub fn new() -> HashSet { HashSet(StdSet::new()) @@ -126,7 +135,6 @@ impl HashSet where T: Eq + Hash, S: BuildHasher { - #[inline] pub fn with_hasher(hasher: S) -> HashSet { HashSet(StdSet::with_hasher(hasher)) @@ -158,10 +166,11 @@ impl HashSet // We can't derive these since the bounds are not obvious to the derive macro -impl HeapSizeOf for HashMap { +impl + HeapSizeOf for HashMap { fn heap_size_of_children(&self) -> usize { self.0.heap_size_of_children() - } + } } impl Default for HashMap { @@ -224,7 +233,7 @@ impl<'a, K, V, S> IntoIterator for &'a mut HashMap impl HeapSizeOf for HashSet { fn heap_size_of_children(&self) -> usize { self.0.heap_size_of_children() - } + } } impl Default for HashSet { diff --git a/components/hashglobe/src/lib.rs b/components/hashglobe/src/lib.rs index 4bd32e59e96f..4dc683d023d5 100644 --- a/components/hashglobe/src/lib.rs +++ b/components/hashglobe/src/lib.rs @@ -1,12 +1,22 @@ +// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + pub use std::*; extern crate heapsize; -mod table; -mod shim; mod alloc; pub mod hash_map; pub mod hash_set; +mod shim; +mod table; pub mod fake; diff --git a/components/style/custom_properties.rs b/components/style/custom_properties.rs index a318fce8b805..6d72bb7b369e 100644 --- a/components/style/custom_properties.rs +++ b/components/style/custom_properties.rs @@ -8,13 +8,13 @@ use Atom; use cssparser::{Delimiter, Parser, ParserInput, SourcePosition, Token, TokenSerializationType}; +use hash::{HashMap, HashSet}; use parser::ParserContext; use properties::{CSSWideKeyword, DeclaredValue}; use selectors::parser::SelectorParseError; use servo_arc::Arc; use std::ascii::AsciiExt; use std::borrow::{Borrow, Cow}; -use hash::{HashMap, HashSet}; use std::fmt; use std::hash::Hash; use style_traits::{ToCss, StyleParseError, ParseError}; diff --git a/components/style/gecko/wrapper.rs b/components/style/gecko/wrapper.rs index d3c6f82bc32d..591657c4be76 100644 --- a/components/style/gecko/wrapper.rs +++ b/components/style/gecko/wrapper.rs @@ -66,6 +66,7 @@ use gecko_bindings::structs::nsChangeHint; use gecko_bindings::structs::nsIDocument_DocumentTheme as DocumentTheme; use gecko_bindings::structs::nsRestyleHint; use gecko_bindings::sugar::ownership::{HasArcFFI, HasSimpleFFI}; +use hash::HashMap; use logical_geometry::WritingMode; use media_queries::Device; use properties::{ComputedValues, parse_style_attribute}; @@ -83,7 +84,6 @@ use selectors::sink::Push; use servo_arc::{Arc, ArcBorrow, RawOffsetArc}; use shared_lock::Locked; use std::cell::RefCell; -use hash::HashMap; use std::fmt; use std::hash::{Hash, Hasher}; use std::mem; diff --git a/components/style/selector_map.rs b/components/style/selector_map.rs index 6b0f386b1503..f61e5ec462b6 100644 --- a/components/style/selector_map.rs +++ b/components/style/selector_map.rs @@ -9,6 +9,8 @@ use {Atom, LocalName}; use applicable_declarations::ApplicableDeclarationBlock; use context::QuirksMode; use dom::TElement; +use hash::{HashMap, HashSet}; +use hash::map as hash_map; use pdqsort::sort_by; use precomputed_hash::PrecomputedHash; use rule_tree::CascadeLevel; @@ -16,8 +18,6 @@ use selector_parser::SelectorImpl; use selectors::matching::{matches_selector, MatchingContext, ElementSelectorFlags}; use selectors::parser::{Component, Combinator, SelectorIter}; use smallvec::{SmallVec, VecLike}; -use hash::{HashMap, HashSet}; -use hash::map as hash_map; use std::hash::{BuildHasherDefault, Hash, Hasher}; use stylist::Rule; diff --git a/servo-tidy.toml b/servo-tidy.toml index 9059379a1014..b7e48d8f424c 100644 --- a/servo-tidy.toml +++ b/servo-tidy.toml @@ -15,6 +15,7 @@ lint-scripts = [ rand = [ "deque", "gaol", + "hashglobe", # only uses in tests "ipc-channel", "num-bigint", "parking_lot_core", @@ -74,6 +75,7 @@ directories = [ "./components/script/dom/bindings/codegen/parser", "./components/script/dom/bindings/codegen/ply", "./python/_virtualenv", + "./components/hashglobe/src", # Generated and upstream code combined with our own. Could use cleanup "./target", "./ports/cef",