Skip to content
This repository was archived by the owner on Jul 10, 2023. It is now read-only.

Commit 90dea25

Browse files
author
bors-servo
authored
Auto merge of #67 - servo:rustup, r=nox
Update to Rust 1.15.0-nightly (ac635aa95 2016-11-18)
2 parents 87250d1 + 916d7dc commit 90dea25

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

derive/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "heapsize_derive"
3-
version = "0.1.2"
3+
version = "0.1.3"
44
authors = ["The Servo Project Developers"]
55
description = "Automatically generating infrastructure for measuring the total runtime size of an object on the heap"
66
license = "MPL-2.0"
@@ -15,6 +15,6 @@ name = "test"
1515
path = "test.rs"
1616

1717
[dependencies]
18-
syn = "0.9"
18+
syn = "0.10"
1919
quote = "0.3"
20-
synstructure = "0.2"
20+
synstructure = "0.4"

derive/lib.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ extern crate syn;
1010
extern crate synstructure;
1111

1212
#[cfg(not(test))]
13-
#[proc_macro_derive(HeapSizeOf)]
13+
#[proc_macro_derive(HeapSizeOf, attributes(ignore_heap_size_of))]
1414
pub fn expand_token_stream(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
1515
expand_string(&input.to_string()).parse().unwrap()
1616
}
@@ -20,18 +20,16 @@ fn expand_string(input: &str) -> String {
2020

2121
let style = synstructure::BindStyle::Ref.into();
2222
let match_body = synstructure::each_field(&mut type_, &style, |binding| {
23-
let mut ignore = false;
24-
binding.field.attrs.retain(|attr| match attr.value {
23+
let ignore = binding.field.attrs.iter().any(|attr| match attr.value {
2524
syn::MetaItem::Word(ref ident) |
2625
syn::MetaItem::List(ref ident, _) if ident == "ignore_heap_size_of" => {
2726
panic!("#[ignore_heap_size_of] should have an explanation, \
2827
e.g. #[ignore_heap_size_of = \"because reasons\"]");
2928
}
3029
syn::MetaItem::NameValue(ref ident, _) if ident == "ignore_heap_size_of" => {
31-
ignore = true;
32-
false // Don’t retain
30+
true
3331
}
34-
_ => true // Do retain everything else
32+
_ => false,
3533
});
3634
if ignore {
3735
None
@@ -66,8 +64,6 @@ fn expand_string(input: &str) -> String {
6664
}
6765

6866
let tokens = quote! {
69-
#type_
70-
7167
impl #impl_generics ::heapsize::HeapSizeOf for #name #ty_generics #where_clause {
7268
#[inline]
7369
#[allow(unused_variables, unused_mut, unreachable_code)]
@@ -96,7 +92,7 @@ fn test_struct() {
9692
$e, expanded)
9793
}
9894
}
99-
match_count!("struct Foo<T> { bar: Bar, baz: T, z: Arc<T> }", 1);
95+
match_count!("struct", 0);
10096
match_count!("ignore_heap_size_of", 0);
10197
match_count!("impl<T> ::heapsize::HeapSizeOf for Foo<T> where T: ::heapsize::HeapSizeOf {", 1);
10298
match_count!("sum += ::heapsize::HeapSizeOf::heap_size_of_children(", 2);

0 commit comments

Comments
 (0)