diff --git a/Cargo.lock b/Cargo.lock index 70f090910b6..fb1e0982b0b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -743,9 +743,6 @@ dependencies = [ [[package]] name = "dom_struct" version = "0.0.1" -dependencies = [ - "quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", -] [[package]] name = "domobject_derive" diff --git a/components/dom_struct/Cargo.toml b/components/dom_struct/Cargo.toml index 4f3593db66b..7a76375ac06 100644 --- a/components/dom_struct/Cargo.toml +++ b/components/dom_struct/Cargo.toml @@ -8,6 +8,3 @@ publish = false [lib] path = "lib.rs" proc-macro = true - -[dependencies] -quote = "0.3.15" diff --git a/components/dom_struct/lib.rs b/components/dom_struct/lib.rs index f74427789db..33801de8c8d 100644 --- a/components/dom_struct/lib.rs +++ b/components/dom_struct/lib.rs @@ -5,24 +5,19 @@ #![feature(proc_macro)] extern crate proc_macro; -#[macro_use] extern crate quote; -use proc_macro::TokenStream; +use proc_macro::{TokenStream, quote}; +use std::iter; #[proc_macro_attribute] pub fn dom_struct(args: TokenStream, input: TokenStream) -> TokenStream { - if !args.to_string().is_empty() { + if !args.is_empty() { panic!("#[dom_struct] takes no arguments"); } - expand_string(&input.to_string()).parse().unwrap() -} - -fn expand_string(input: &str) -> String { - let mut tokens = quote! { + let attributes = quote! { #[derive(DenyPublicFields, DomObject, HeapSizeOf, JSTraceable)] #[must_root] #[repr(C)] }; - tokens.append(input); - tokens.to_string() + iter::once(attributes).chain(iter::once(input)).collect() }