From 805738608dd34d44cf3e0989cd13369d9efb1a6c Mon Sep 17 00:00:00 2001 From: ibaryshnikov Date: Sun, 19 May 2019 14:42:53 +0300 Subject: [PATCH 1/2] expose forget to wasm --- crates/cli-support/src/js/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/cli-support/src/js/mod.rs b/crates/cli-support/src/js/mod.rs index 3bc66cbf..18213433 100644 --- a/crates/cli-support/src/js/mod.rs +++ b/crates/cli-support/src/js/mod.rs @@ -249,7 +249,7 @@ impl<'a> Context<'a> { format!("{}{}\n", export, contents) } else { assert_eq!(export_name, definition_name); - format!("{}const {} = {};\n", export, export_name, contents) + format!("{}const {name} = {};\n__exports.{name} = {name};", export, contents, name = export_name) } } }; From a68cdc594d9173ee495edc85b2930dec41a617b4 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 20 May 2019 09:32:37 -0700 Subject: [PATCH 2/2] Add a test that `Callback::forget` works --- tests/headless/main.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/headless/main.rs b/tests/headless/main.rs index 88bffc75..c2b2ed2d 100755 --- a/tests/headless/main.rs +++ b/tests/headless/main.rs @@ -51,3 +51,11 @@ pub mod snippets; pub mod modules; pub mod anyref_heap_live_count; pub mod strings; + +#[wasm_bindgen_test] +fn closures_work() { + let x = Closure::wrap(Box::new(|| {}) as Box); + drop(x); + let x = Closure::wrap(Box::new(|| {}) as Box); + x.forget(); +}