aboutsummaryrefslogtreecommitdiffstats
path: root/components/plugins
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2016-02-05 03:40:36 +0530
committerbors-servo <lbergstrom+bors@mozilla.com>2016-02-05 03:40:36 +0530
commit2a6707ce58df27d93e865bffb6b44d396b810c99 (patch)
tree849afb2986272f67b1abfc8720b8f530dc1c2227 /components/plugins
parent9e68285d35a2e7b72c9edfd9e5e37399e724c4e6 (diff)
parentcb5cd8d881c39f549381e078b44f341dea733e68 (diff)
downloadservo-2a6707ce58df27d93e865bffb6b44d396b810c99.tar.gz
servo-2a6707ce58df27d93e865bffb6b44d396b810c99.zip
Auto merge of #9532 - nox:dedup-heapsize, r=Manishearth
Say farewell to in-tree HeapSizeOf <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.svg" height="40" alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9532) <!-- Reviewable:end -->
Diffstat (limited to 'components/plugins')
-rw-r--r--components/plugins/Cargo.toml2
-rw-r--r--components/plugins/heap_size.rs82
-rw-r--r--components/plugins/lib.rs3
3 files changed, 1 insertions, 86 deletions
diff --git a/components/plugins/Cargo.toml b/components/plugins/Cargo.toml
index 172a0d3adf3..d5d1f0246b0 100644
--- a/components/plugins/Cargo.toml
+++ b/components/plugins/Cargo.toml
@@ -17,7 +17,7 @@ rev = "9dca15de3e8ea266d3e7e868c0f358ed4fa5f195"
optional = true
[dependencies]
-url = "0.5.4"
+url = {version = "0.5.4", features = ["heap_size"]}
[features]
default = []
diff --git a/components/plugins/heap_size.rs b/components/plugins/heap_size.rs
deleted file mode 100644
index 0f8ea67fa62..00000000000
--- a/components/plugins/heap_size.rs
+++ /dev/null
@@ -1,82 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * 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/. */
-
-//! Handles the auto-deriving for `#[derive(HeapSizeOf)]`
-//!
-//! This provides the `#[derive(HeapSizeOf)]` decorator, which
-//! generates a `HeapSizeOf` implementation that adds up
-//! calls to heap_size_of_children() for all the fields
-//! of a struct or enum variant.
-//!
-//! Fields marked `#[ignore_heap_size_of = "reason"]` will
-//! be ignored in this calculation. Providing a reason is compulsory.
-
-
-use syntax::ast::*;
-use syntax::attr::AttrMetaMethods;
-use syntax::codemap::Span;
-use syntax::ext::base::{Annotatable, ExtCtxt};
-use syntax::ext::build::AstBuilder;
-use syntax::ptr::P;
-use syntax_ext::deriving::generic::*;
-
-pub fn expand_heap_size(cx: &mut ExtCtxt, span: Span, mitem: &MetaItem,
- item: &Annotatable, push: &mut FnMut(Annotatable)) {
- let trait_def = TraitDef {
- is_unsafe: false,
- span: span,
- attributes: Vec::new(),
- path: ty::Path::new(vec!("util", "mem", "HeapSizeOf")),
- additional_bounds: Vec::new(),
- generics: ty::LifetimeBounds::empty(),
- methods: vec![
- MethodDef {
- name: "heap_size_of_children",
- generics: ty::LifetimeBounds::empty(),
- explicit_self: ty::borrowed_explicit_self(),
- args: vec!(),
- ret_ty: ty::Literal(ty::Path::new_local("usize")),
- attributes: vec!(),
- is_unsafe: false,
- combine_substructure: combine_substructure(Box::new(heap_size_substructure))
- }
- ],
- associated_types: vec![],
- };
- trait_def.expand(cx, mitem, item, push)
-}
-
-/// Defines how the implementation for `heap_size_of_children()` is to be generated.
-fn heap_size_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substructure) -> P<Expr> {
- let fields = match *substr.fields {
- Struct(ref fs) | EnumMatching(_, _, ref fs) => fs,
- _ => cx.span_bug(trait_span, "impossible substructure in `#[derive(HeapSizeOf)]`")
- };
-
- fields.iter().fold(cx.expr_usize(trait_span, 0), |acc, ref item| {
- if item.attrs.iter()
- .find(|ref a| {
- if a.check_name("ignore_heap_size_of") {
- match a.node.value.node {
- MetaNameValue(..) => (),
- _ => cx.span_err(a.span, "#[ignore_heap_size_of] \
- should have an explanation, \
- e.g. #[ignore_heap_size_of = \"\"]")
- }
- true
- } else {
- false
- }
- })
- .is_some() {
- acc
- } else {
- cx.expr_binary(item.span, BiAdd, acc,
- cx.expr_method_call(item.span,
- item.self_.clone(),
- substr.method_ident,
- Vec::new()))
- }
- })
-}
diff --git a/components/plugins/lib.rs b/components/plugins/lib.rs
index b1d701e6aec..25181f2197c 100644
--- a/components/plugins/lib.rs
+++ b/components/plugins/lib.rs
@@ -36,8 +36,6 @@ use syntax::parse::token::intern;
// Public for documentation to show up
/// Handles the auto-deriving for `#[derive(JSTraceable)]`
pub mod jstraceable;
-/// Handles the auto-deriving for `#[derive(HeapSizeOf)]`
-pub mod heap_size;
pub mod lints;
/// Autogenerates implementations of Reflectable on DOM structs
pub mod reflector;
@@ -51,7 +49,6 @@ pub fn plugin_registrar(reg: &mut Registry) {
reg.register_syntax_extension(intern("dom_struct"), MultiModifier(box jstraceable::expand_dom_struct));
reg.register_syntax_extension(intern("derive_JSTraceable"), MultiDecorator(box jstraceable::expand_jstraceable));
reg.register_syntax_extension(intern("_generate_reflector"), MultiDecorator(box reflector::expand_reflector));
- reg.register_syntax_extension(intern("derive_HeapSizeOf"), MultiDecorator(box heap_size::expand_heap_size));
reg.register_macro("to_lower", casing::expand_lower);
reg.register_macro("to_upper", casing::expand_upper);
reg.register_macro("url", url_plugin::expand_url);