mirror of
https://github.com/servo/servo.git
synced 2025-07-25 16:20:36 +01:00
Auto merge of #18340 - servo:dom-struct-errors, r=SimonSapin
Use the better TokenStream API in dom_struct Before: ```rust error[E0412]: cannot find type `SourceBuffer` in this scope --> /Users/nox/src/servo/components/script/dom/mediasource.rs:25:1 | 25 | #[dom_struct] | ^^^^^^^^^^^^^ did you mean `SourceBufferList`? ``` After: ```rust error[E0412]: cannot find type `SourceBuffer` in this scope --> /Users/nox/src/servo/components/script/dom/mediasource.rs:28:39 | 28 | source_buffers: DOMRefCell<Vec<JS<SourceBuffer>>>, | ^^^^^^^^^^^^ did you mean `SourceBufferList`? ``` <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/18340) <!-- Reviewable:end -->
This commit is contained in:
commit
32b04b3f51
3 changed files with 5 additions and 16 deletions
3
Cargo.lock
generated
3
Cargo.lock
generated
|
@ -743,9 +743,6 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dom_struct"
|
name = "dom_struct"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
dependencies = [
|
|
||||||
"quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "domobject_derive"
|
name = "domobject_derive"
|
||||||
|
|
|
@ -8,6 +8,3 @@ publish = false
|
||||||
[lib]
|
[lib]
|
||||||
path = "lib.rs"
|
path = "lib.rs"
|
||||||
proc-macro = true
|
proc-macro = true
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
quote = "0.3.15"
|
|
||||||
|
|
|
@ -5,24 +5,19 @@
|
||||||
#![feature(proc_macro)]
|
#![feature(proc_macro)]
|
||||||
|
|
||||||
extern crate 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]
|
#[proc_macro_attribute]
|
||||||
pub fn dom_struct(args: TokenStream, input: TokenStream) -> TokenStream {
|
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");
|
panic!("#[dom_struct] takes no arguments");
|
||||||
}
|
}
|
||||||
expand_string(&input.to_string()).parse().unwrap()
|
let attributes = quote! {
|
||||||
}
|
|
||||||
|
|
||||||
fn expand_string(input: &str) -> String {
|
|
||||||
let mut tokens = quote! {
|
|
||||||
#[derive(DenyPublicFields, DomObject, HeapSizeOf, JSTraceable)]
|
#[derive(DenyPublicFields, DomObject, HeapSizeOf, JSTraceable)]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
};
|
};
|
||||||
tokens.append(input);
|
iter::once(attributes).chain(iter::once(input)).collect()
|
||||||
tokens.to_string()
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue