diff --git a/README.md b/README.md index 05da8f39..bfe26c72 100644 --- a/README.md +++ b/README.md @@ -76,7 +76,7 @@ wasm-bindgen = "0.1" Next up our actual code! We'll write this in `src/lib.rs`: ```rust -#![feature(proc_macro)] +#![feature(proc_macro, wasm_custom_section, wasm_import_module)] extern crate wasm_bindgen; @@ -261,7 +261,7 @@ Much more! Here's a taste of various features you can use in this project: ```rust // src/lib.rs -#![feature(proc_macro)] +#![feature(proc_macro, wasm_custom_section, wasm_import_module)] extern crate wasm_bindgen; diff --git a/crates/wasm-bindgen-cli-support/src/js.rs b/crates/wasm-bindgen-cli-support/src/js.rs index 26920a47..89764958 100644 --- a/crates/wasm-bindgen-cli-support/src/js.rs +++ b/crates/wasm-bindgen-cli-support/src/js.rs @@ -16,7 +16,6 @@ pub struct Context<'a> { pub required_internal_exports: HashSet<&'static str>, pub config: &'a Bindgen, pub module: &'a mut Module, - pub imports_to_rewrite: HashSet, pub custom_type_names: HashMap, pub imported_names: HashSet, pub exported_classes: HashMap, @@ -288,18 +287,7 @@ impl<'a> Context<'a> { .flat_map(|s| s.entries_mut()); for import in imports { - if import.field().starts_with("__wbindgen") { - import.module_mut().truncate(0); - import.module_mut().push_str("./"); - import.module_mut().push_str(module_name); - continue - } - - // rustc doesn't have support for importing from anything other - // than the module `env` so let's use the metadata here to - // rewrite the imports if they import from `env` until it's - // fixed upstream. - if self.imports_to_rewrite.contains(import.field()) { + if import.module() == "__wbindgen_placeholder__" { import.module_mut().truncate(0); import.module_mut().push_str("./"); import.module_mut().push_str(module_name); @@ -954,7 +942,7 @@ impl<'a> Context<'a> { }; imports.entries().iter().any(|i| { - i.module() == "env" && i.field() == name + i.module() == "__wbindgen_placeholder__" && i.field() == name }) } @@ -1336,7 +1324,6 @@ impl<'a, 'b> SubContext<'a, 'b> { info: &shared::Import, import: &shared::ImportStatic) { // TODO: should support more types to import here - self.cx.imports_to_rewrite.insert(import.shim.clone()); let obj = self.import_name(info, &import.name); self.cx.expose_add_heap_object(); self.cx.globals.push_str(&format!(" @@ -1349,8 +1336,6 @@ impl<'a, 'b> SubContext<'a, 'b> { pub fn generate_import_function(&mut self, info: &shared::Import, import: &shared::ImportFunction) { - self.cx.imports_to_rewrite.insert(import.shim.clone()); - let mut dst = String::new(); dst.push_str(&format!("function {}(", import.shim)); diff --git a/crates/wasm-bindgen-cli-support/src/lib.rs b/crates/wasm-bindgen-cli-support/src/lib.rs index 089372cd..bd143ef5 100644 --- a/crates/wasm-bindgen-cli-support/src/lib.rs +++ b/crates/wasm-bindgen-cli-support/src/lib.rs @@ -6,7 +6,6 @@ extern crate wasm_gc; use std::char; use std::fs::File; use std::io::Write; -use std::ops::{Deref, DerefMut}; use std::path::{Path, PathBuf}; use std::slice; @@ -90,7 +89,6 @@ impl Bindgen { typescript: format!("/* tslint:disable */\n"), exposed_globals: Default::default(), required_internal_exports: Default::default(), - imports_to_rewrite: Default::default(), custom_type_names: Default::default(), imported_names: Default::default(), exported_classes: Default::default(), @@ -133,40 +131,33 @@ impl Bindgen { fn extract_programs(module: &mut Module) -> Vec { let version = shared::version(); - let data = module.sections_mut() - .iter_mut() - .filter_map(|s| { - match *s { - Section::Data(ref mut s) => Some(s), - _ => None, - } - }) - .next(); - let mut ret = Vec::new(); - let data = match data { - Some(data) => data, - None => return ret, - }; - for entry in data.entries_mut() { - let mut value = bytes_to_u32(entry.value_mut()); - let mut tmp = &mut *value; - loop { - let value = tmp; - let start = match value.iter().position(|i| i.0 == 0x30d97887) { - Some(i) => i, - None => break, - }; - if value.get(start + 1).map(|c| c.0) != Some(0xd4182f61) { - tmp = &mut value[1..]; - continue - } - let cnt = value[start + 2].0 as usize; - let (a, b) = value[start..].split_at_mut(cnt + 3); - tmp = b; - let json = a[3..].iter() - .map(|i| char::from_u32(i.0).unwrap()) + #[repr(packed)] + struct Unaligned(u32); + + module.sections_mut().retain(|s| { + let custom = match *s { + Section::Custom(ref s) => s, + _ => return true, + }; + if custom.name() != "__wasm_bindgen_unstable" { + return true + } + + assert!(custom.payload().len() % 4 == 0); + let mut payload = unsafe { + slice::from_raw_parts(custom.payload().as_ptr() as *const Unaligned, + custom.payload().len() / 4) + }; + + while payload.len() > 0 { + let len = payload[0].0.to_le(); + assert!(len % 4 == 0); + let (a, b) = payload[1..].split_at((len / 4) as usize); + payload = b; + let json = a.iter() + .map(|i| char::from_u32(i.0.to_le()).unwrap()) .collect::(); let p: shared::Program = match serde_json::from_str(&json) { Ok(f) => f, @@ -200,57 +191,9 @@ to open an issue at https://github.com/alexcrichton/wasm-bindgen/issues! p.version, version); } ret.push(p); - - for slot in a { - slot.0 = 0; - } } - } + + false + }); return ret } - -#[repr(packed)] -struct Unaligned(u32); - -struct FutzWithAlign<'a> { - data: &'a mut Vec, - len: usize, -} - -fn bytes_to_u32(a: &mut Vec) -> FutzWithAlign { - let prev_len = a.len(); - // Data implicitly contains zeros after it and it looks like LLD exploits - // this. Pad our view into the vector with zeros to make sure that we read - // off everything when we iterate. After we're done iterating though we put - // this back as we found it, hence the newtype wrapper w/ a dtor. - while a.len() % 4 != 0 { - a.push(0); - } - FutzWithAlign { data: a, len: prev_len } -} - -impl<'a> Deref for FutzWithAlign<'a> { - type Target = [Unaligned]; - - fn deref(&self) -> &[Unaligned] { - unsafe { - slice::from_raw_parts(self.data.as_ptr() as *const Unaligned, - self.data.len() / 4) - } - } -} - -impl<'a> DerefMut for FutzWithAlign<'a> { - fn deref_mut(&mut self) -> &mut [Unaligned] { - unsafe { - slice::from_raw_parts_mut(self.data.as_mut_ptr() as *mut Unaligned, - self.data.len() / 4) - } - } -} - -impl<'a> Drop for FutzWithAlign<'a> { - fn drop(&mut self) { - self.data.truncate(self.len); - } -} diff --git a/crates/wasm-bindgen-macro/src/ast.rs b/crates/wasm-bindgen-macro/src/ast.rs index 099101fe..a38094de 100644 --- a/crates/wasm-bindgen-macro/src/ast.rs +++ b/crates/wasm-bindgen-macro/src/ast.rs @@ -404,12 +404,13 @@ impl Program { }; let cnt = cnt as u32; (quote! { - 0x30d97887, - 0xd4182f61, - #cnt, + (#cnt >> 0) as u8, + (#cnt >> 8) as u8, + (#cnt >> 16) as u8, + (#cnt >> 24) as u8 }).to_tokens(dst); tmp.to_tokens(dst); - (cnt as usize) + 3 + (cnt as usize) + 4 } } diff --git a/crates/wasm-bindgen-macro/src/lib.rs b/crates/wasm-bindgen-macro/src/lib.rs index d7209b8c..9499772a 100755 --- a/crates/wasm-bindgen-macro/src/lib.rs +++ b/crates/wasm-bindgen-macro/src/lib.rs @@ -110,9 +110,9 @@ impl ToTokens for ast::Program { let generated_static_length = self.literal(&mut generated_static_value); (my_quote! { - #[no_mangle] #[allow(non_upper_case_globals)] - pub static #generated_static_name: [u32; #generated_static_length] = + #[wasm_custom_section = "__wasm_bindgen_unstable"] + const #generated_static_name: [u8; #generated_static_length] = [#generated_static_value]; }).to_tokens(tokens); } @@ -565,6 +565,7 @@ impl ToTokens for ast::ImportFunction { #[allow(bad_style)] #vis extern #fn_token #rust_name(#me #(#arguments),*) #ret { ::wasm_bindgen::__rt::link_this_library(); + #[wasm_import_module = "__wbindgen_placeholder__"] extern { fn #import_name(#(#abi_arguments),*) -> #abi_ret; } @@ -638,6 +639,7 @@ impl ToTokens for ast::ImportStatic { #[allow(bad_style)] #vis static #name: ::wasm_bindgen::JsStatic<#ty> = { fn init() -> #ty { + #[wasm_import_module = "__wbindgen_placeholder__"] extern { fn #shim_name() -> u32; } diff --git a/crates/wasm-bindgen-macro/src/literal.rs b/crates/wasm-bindgen-macro/src/literal.rs index 00b4d177..c44046bf 100644 --- a/crates/wasm-bindgen-macro/src/literal.rs +++ b/crates/wasm-bindgen-macro/src/literal.rs @@ -21,12 +21,18 @@ impl<'a> LiteralBuilder<'a> { self.cnt } - fn char_lit(&mut self, c: char) { - if self.cnt > 0 { - ::syn::token::Comma::default().to_tokens(self.dst); - } + fn byte(&mut self, b: u8) { + ::syn::token::Comma::default().to_tokens(self.dst); self.cnt += 1; - (c as u32).to_tokens(self.dst); + b.to_tokens(self.dst); + } + + fn char_lit(&mut self, c: char) { + let c = c as u32; + self.byte(c as u8); + self.byte((c >> 8) as u8); + self.byte((c >> 16) as u8); + self.byte((c >> 24) as u8); } fn append(&mut self, s: &str) { @@ -57,9 +63,13 @@ impl<'a> LiteralBuilder<'a> { fn as_char(&mut self, tokens: Tokens) { self.append("\""); - ::syn::token::Comma::default().to_tokens(self.dst); - tokens.to_tokens(self.dst); - self.cnt += 1; + (quote! { + , (((#tokens) as u32) >> 0) as u8 + , (((#tokens) as u32) >> 8) as u8 + , (((#tokens) as u32) >> 16) as u8 + , (((#tokens) as u32) >> 24) as u8 + }).to_tokens(self.dst); + self.cnt += 4; self.append("\""); } diff --git a/examples/console_log/src/lib.rs b/examples/console_log/src/lib.rs index 8b8d28b4..27a203dd 100644 --- a/examples/console_log/src/lib.rs +++ b/examples/console_log/src/lib.rs @@ -1,4 +1,4 @@ -#![feature(proc_macro)] +#![feature(proc_macro, wasm_custom_section, wasm_import_module)] extern crate wasm_bindgen; diff --git a/examples/dom/src/lib.rs b/examples/dom/src/lib.rs index 24c539f2..5fd85916 100644 --- a/examples/dom/src/lib.rs +++ b/examples/dom/src/lib.rs @@ -1,4 +1,4 @@ -#![feature(proc_macro)] +#![feature(proc_macro, wasm_custom_section, wasm_import_module)] extern crate wasm_bindgen; diff --git a/examples/hello_world/src/lib.rs b/examples/hello_world/src/lib.rs index d4fb8e90..6a83b6bf 100644 --- a/examples/hello_world/src/lib.rs +++ b/examples/hello_world/src/lib.rs @@ -1,4 +1,4 @@ -#![feature(proc_macro)] +#![feature(proc_macro, wasm_custom_section, wasm_import_module)] extern crate wasm_bindgen; diff --git a/examples/math/src/lib.rs b/examples/math/src/lib.rs index c10b9ae5..d970aa0c 100644 --- a/examples/math/src/lib.rs +++ b/examples/math/src/lib.rs @@ -1,4 +1,4 @@ -#![feature(proc_macro)] +#![feature(proc_macro, wasm_custom_section, wasm_import_module)] extern crate wasm_bindgen; diff --git a/examples/performance/src/lib.rs b/examples/performance/src/lib.rs index 77b01c8c..612bf51f 100644 --- a/examples/performance/src/lib.rs +++ b/examples/performance/src/lib.rs @@ -1,4 +1,4 @@ -#![feature(proc_macro)] +#![feature(proc_macro, wasm_custom_section, wasm_import_module)] extern crate wasm_bindgen; extern crate humantime; diff --git a/examples/smorgasboard/src/lib.rs b/examples/smorgasboard/src/lib.rs index f68232c5..d73cc566 100644 --- a/examples/smorgasboard/src/lib.rs +++ b/examples/smorgasboard/src/lib.rs @@ -1,4 +1,4 @@ -#![feature(proc_macro)] +#![feature(proc_macro, wasm_custom_section, wasm_import_module)] extern crate wasm_bindgen; diff --git a/examples/wasm-in-wasm/src/lib.rs b/examples/wasm-in-wasm/src/lib.rs index 6620aa8a..3cd6304a 100644 --- a/examples/wasm-in-wasm/src/lib.rs +++ b/examples/wasm-in-wasm/src/lib.rs @@ -1,4 +1,4 @@ -#![feature(proc_macro)] +#![feature(proc_macro, wasm_custom_section, wasm_import_module)] extern crate wasm_bindgen; diff --git a/src/lib.rs b/src/lib.rs index deb1e076..7087cfd0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -5,7 +5,7 @@ //! this crate and this crate also provides JS bindings through the `JsValue` //! interface. -#![feature(use_extern_macros, try_reserve)] +#![feature(use_extern_macros, wasm_import_module, try_reserve)] extern crate wasm_bindgen_macro; @@ -213,6 +213,7 @@ macro_rules! numbers { numbers! { i8 u8 i16 u16 i32 u32 f32 f64 } +#[wasm_import_module = "__wbindgen_placeholder__"] extern { fn __wbindgen_object_clone_ref(idx: u32) -> u32; fn __wbindgen_object_drop_ref(idx: u32); @@ -228,6 +229,7 @@ extern { fn __wbindgen_symbol_new(ptr: *const u8, len: usize) -> u32; fn __wbindgen_is_symbol(idx: u32) -> u32; fn __wbindgen_string_get(idx: u32, len: *mut usize) -> *mut u8; + fn __wbindgen_throw(a: *const u8, b: usize) -> !; } impl Clone for JsValue { @@ -298,9 +300,6 @@ impl Deref for JsStatic { #[cold] #[inline(never)] pub fn throw(s: &str) -> ! { - extern { - fn __wbindgen_throw(a: *const u8, b: usize) -> !; - } unsafe { __wbindgen_throw(s.as_ptr(), s.len()); } diff --git a/tests/api.rs b/tests/api.rs index 7ced0009..26509564 100644 --- a/tests/api.rs +++ b/tests/api.rs @@ -5,7 +5,7 @@ fn works() { test_support::project() .detect_node(true) .file("src/lib.rs", r#" - #![feature(proc_macro)] + #![feature(proc_macro, wasm_custom_section)] extern crate wasm_bindgen; diff --git a/tests/classes.rs b/tests/classes.rs index 1c7ebd96..13e03b26 100644 --- a/tests/classes.rs +++ b/tests/classes.rs @@ -4,7 +4,7 @@ extern crate test_support; fn simple() { test_support::project() .file("src/lib.rs", r#" - #![feature(proc_macro)] + #![feature(proc_macro, wasm_custom_section)] extern crate wasm_bindgen; @@ -56,7 +56,7 @@ fn simple() { fn strings() { test_support::project() .file("src/lib.rs", r#" - #![feature(proc_macro)] + #![feature(proc_macro, wasm_custom_section)] extern crate wasm_bindgen; @@ -114,7 +114,7 @@ fn strings() { fn exceptions() { test_support::project() .file("src/lib.rs", r#" - #![feature(proc_macro)] + #![feature(proc_macro, wasm_custom_section)] extern crate wasm_bindgen; @@ -179,7 +179,7 @@ fn exceptions() { fn pass_one_to_another() { test_support::project() .file("src/lib.rs", r#" - #![feature(proc_macro)] + #![feature(proc_macro, wasm_custom_section)] extern crate wasm_bindgen; @@ -229,7 +229,7 @@ fn pass_one_to_another() { fn pass_into_js() { test_support::project() .file("src/lib.rs", r#" - #![feature(proc_macro)] + #![feature(proc_macro, wasm_custom_section, wasm_import_module)] extern crate wasm_bindgen; @@ -276,7 +276,7 @@ fn pass_into_js() { fn issue_27() { test_support::project() .file("src/lib.rs", r#" - #![feature(proc_macro)] + #![feature(proc_macro, wasm_custom_section)] extern crate wasm_bindgen; use wasm_bindgen::prelude::*; diff --git a/tests/dependencies.rs b/tests/dependencies.rs index 36ac6fda..174ab985 100644 --- a/tests/dependencies.rs +++ b/tests/dependencies.rs @@ -6,7 +6,7 @@ fn dependencies_work() { .file( "src/lib.rs", r#" - #![feature(proc_macro)] + #![feature(proc_macro, wasm_custom_section)] extern crate wasm_bindgen; extern crate dependency; use wasm_bindgen::prelude::*; @@ -51,7 +51,7 @@ fn dependencies_work() { .file( "vendor/dependency/src/lib.rs", r#" - #![feature(proc_macro)] + #![feature(proc_macro, wasm_custom_section)] extern crate wasm_bindgen; use wasm_bindgen::prelude::*; diff --git a/tests/enums.rs b/tests/enums.rs index 2455f28e..5d7c8e91 100644 --- a/tests/enums.rs +++ b/tests/enums.rs @@ -4,7 +4,7 @@ extern crate test_support; fn c_style_enum() { test_support::project() .file("src/lib.rs", r#" - #![feature(proc_macro)] + #![feature(proc_macro, wasm_custom_section)] extern crate wasm_bindgen; @@ -46,7 +46,7 @@ fn c_style_enum() { fn c_style_enum_with_custom_values() { test_support::project() .file("src/lib.rs", r#" - #![feature(proc_macro)] + #![feature(proc_macro, wasm_custom_section)] extern crate wasm_bindgen; diff --git a/tests/import-class.rs b/tests/import-class.rs index ed2fadf9..da829ba7 100644 --- a/tests/import-class.rs +++ b/tests/import-class.rs @@ -4,7 +4,7 @@ extern crate test_support; fn simple() { test_support::project() .file("src/lib.rs", r#" - #![feature(proc_macro)] + #![feature(proc_macro, wasm_custom_section, wasm_import_module)] extern crate wasm_bindgen; @@ -44,7 +44,7 @@ fn simple() { fn import_class() { test_support::project() .file("src/lib.rs", r#" - #![feature(proc_macro)] + #![feature(proc_macro, wasm_custom_section, wasm_import_module)] extern crate wasm_bindgen; @@ -87,7 +87,7 @@ fn import_class() { fn construct() { test_support::project() .file("src/lib.rs", r#" - #![feature(proc_macro)] + #![feature(proc_macro, wasm_custom_section, wasm_import_module)] extern crate wasm_bindgen; @@ -159,7 +159,7 @@ fn construct() { fn new_constructors() { test_support::project() .file("src/lib.rs", r#" - #![feature(proc_macro)] + #![feature(proc_macro, wasm_custom_section, wasm_import_module)] extern crate wasm_bindgen; @@ -204,7 +204,7 @@ fn new_constructors() { fn switch_methods() { test_support::project() .file("src/lib.rs", r#" - #![feature(proc_macro)] + #![feature(proc_macro, wasm_custom_section, wasm_import_module)] extern crate wasm_bindgen; @@ -283,7 +283,7 @@ fn switch_methods() { fn properties() { test_support::project() .file("src/lib.rs", r#" - #![feature(proc_macro)] + #![feature(proc_macro, wasm_custom_section, wasm_import_module)] extern crate wasm_bindgen; @@ -340,7 +340,7 @@ fn properties() { fn rename_setter_getter() { test_support::project() .file("src/lib.rs", r#" - #![feature(proc_macro)] + #![feature(proc_macro, wasm_custom_section, wasm_import_module)] extern crate wasm_bindgen; diff --git a/tests/imports.rs b/tests/imports.rs index 97e27067..3ebebdb5 100644 --- a/tests/imports.rs +++ b/tests/imports.rs @@ -4,7 +4,7 @@ extern crate test_support; fn simple() { test_support::project() .file("src/lib.rs", r#" - #![feature(proc_macro)] + #![feature(proc_macro, wasm_custom_section, wasm_import_module)] extern crate wasm_bindgen; @@ -86,7 +86,7 @@ fn simple() { fn unused() { test_support::project() .file("src/lib.rs", r#" - #![feature(proc_macro)] + #![feature(proc_macro, wasm_custom_section, wasm_import_module)] extern crate wasm_bindgen; @@ -116,7 +116,7 @@ fn unused() { fn strings() { test_support::project() .file("src/lib.rs", r#" - #![feature(proc_macro)] + #![feature(proc_macro, wasm_custom_section, wasm_import_module)] extern crate wasm_bindgen; @@ -157,7 +157,7 @@ fn strings() { fn exceptions() { test_support::project() .file("src/lib.rs", r#" - #![feature(proc_macro)] + #![feature(proc_macro, wasm_custom_section, wasm_import_module)] extern crate wasm_bindgen; @@ -215,7 +215,7 @@ fn exceptions() { fn exn_caught() { test_support::project() .file("src/lib.rs", r#" - #![feature(proc_macro)] + #![feature(proc_macro, wasm_custom_section, wasm_import_module)] extern crate wasm_bindgen; @@ -253,7 +253,7 @@ fn exn_caught() { fn free_imports() { test_support::project() .file("src/lib.rs", r#" - #![feature(proc_macro)] + #![feature(proc_macro, wasm_custom_section, wasm_import_module)] extern crate wasm_bindgen; @@ -283,7 +283,7 @@ fn free_imports() { fn import_a_field() { test_support::project() .file("src/lib.rs", r#" - #![feature(proc_macro)] + #![feature(proc_macro, wasm_custom_section, wasm_import_module)] extern crate wasm_bindgen; @@ -315,7 +315,7 @@ fn import_a_field() { fn rename() { test_support::project() .file("src/lib.rs", r#" - #![feature(proc_macro)] + #![feature(proc_macro, wasm_custom_section, wasm_import_module)] extern crate wasm_bindgen; diff --git a/tests/jsobjects.rs b/tests/jsobjects.rs index f6b7fded..d929584e 100644 --- a/tests/jsobjects.rs +++ b/tests/jsobjects.rs @@ -4,7 +4,7 @@ extern crate test_support; fn simple() { test_support::project() .file("src/lib.rs", r#" - #![feature(proc_macro)] + #![feature(proc_macro, wasm_custom_section, wasm_import_module)] extern crate wasm_bindgen; @@ -45,7 +45,7 @@ fn simple() { fn owned() { test_support::project() .file("src/lib.rs", r#" - #![feature(proc_macro)] + #![feature(proc_macro, wasm_custom_section, wasm_import_module)] extern crate wasm_bindgen; @@ -86,7 +86,7 @@ fn owned() { fn clone() { test_support::project() .file("src/lib.rs", r#" - #![feature(proc_macro)] + #![feature(proc_macro, wasm_custom_section, wasm_import_module)] extern crate wasm_bindgen; @@ -133,7 +133,7 @@ fn clone() { fn promote() { test_support::project() .file("src/lib.rs", r#" - #![feature(proc_macro)] + #![feature(proc_macro, wasm_custom_section, wasm_import_module)] extern crate wasm_bindgen; @@ -177,7 +177,7 @@ fn promote() { fn returning_vector() { test_support::project() .file("src/lib.rs", r#" - #![feature(proc_macro)] + #![feature(proc_macro, wasm_custom_section, wasm_import_module)] extern crate wasm_bindgen; diff --git a/tests/math.rs b/tests/math.rs index 1087b912..c5ac6493 100644 --- a/tests/math.rs +++ b/tests/math.rs @@ -4,7 +4,7 @@ extern crate test_support; fn auto_bind_math() { test_support::project() .file("src/lib.rs", r#" - #![feature(proc_macro)] + #![feature(proc_macro, wasm_custom_section)] extern crate wasm_bindgen; diff --git a/tests/non-debug.rs b/tests/non-debug.rs index 3b8056c6..cff3a6b4 100644 --- a/tests/non-debug.rs +++ b/tests/non-debug.rs @@ -5,7 +5,7 @@ fn works() { test_support::project() .debug(false) .file("src/lib.rs", r#" - #![feature(proc_macro)] + #![feature(proc_macro, wasm_custom_section)] extern crate wasm_bindgen; diff --git a/tests/simple.rs b/tests/simple.rs index 33ba47df..5496cf83 100644 --- a/tests/simple.rs +++ b/tests/simple.rs @@ -4,7 +4,7 @@ extern crate test_support; fn add() { test_support::project() .file("src/lib.rs", r#" - #![feature(proc_macro)] + #![feature(proc_macro, wasm_custom_section)] extern crate wasm_bindgen; @@ -57,7 +57,7 @@ fn add() { fn string_arguments() { test_support::project() .file("src/lib.rs", r#" - #![feature(proc_macro)] + #![feature(proc_macro, wasm_custom_section)] extern crate wasm_bindgen; @@ -89,7 +89,7 @@ fn string_arguments() { fn return_a_string() { test_support::project() .file("src/lib.rs", r#" - #![feature(proc_macro)] + #![feature(proc_macro, wasm_custom_section)] extern crate wasm_bindgen; @@ -123,7 +123,7 @@ fn return_a_string() { fn exceptions() { test_support::project() .file("src/lib.rs", r#" - #![feature(proc_macro)] + #![feature(proc_macro, wasm_custom_section)] extern crate wasm_bindgen; @@ -154,7 +154,7 @@ fn exceptions() { // fn other_imports() { // test_support::project() // .file("src/lib.rs", r#" -// #![feature(proc_macro)] +// #![feature(proc_macro, wasm_custom_section)] // // extern crate wasm_bindgen; // diff --git a/tests/slice.rs b/tests/slice.rs index a66bd919..343e05a1 100644 --- a/tests/slice.rs +++ b/tests/slice.rs @@ -4,7 +4,7 @@ extern crate test_support; fn export() { test_support::project() .file("src/lib.rs", r#" - #![feature(proc_macro)] + #![feature(proc_macro, wasm_custom_section)] extern crate wasm_bindgen; @@ -84,7 +84,7 @@ fn export() { fn import() { test_support::project() .file("src/lib.rs", r#" - #![feature(proc_macro)] + #![feature(proc_macro, wasm_custom_section, wasm_import_module)] extern crate wasm_bindgen; diff --git a/tests/structural.rs b/tests/structural.rs index bd3a5494..7840d43d 100644 --- a/tests/structural.rs +++ b/tests/structural.rs @@ -5,7 +5,7 @@ fn works() { test_support::project() .detect_node(true) .file("src/lib.rs", r#" - #![feature(proc_macro)] + #![feature(proc_macro, wasm_custom_section, wasm_import_module)] extern crate wasm_bindgen;