-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix consuming a struct and returning a slice
This came up in a [recent comment][1] and it turns out we're accidentally generating two `const ptr = ...` declarations, invalid JS! While Node doesn't catch this it looks like firefox does. [1]: #329 (comment)
- Loading branch information
1 parent
b6a6dee
commit 0d18c8c
Showing
3 changed files
with
40 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#![cfg(target_arch = "wasm32")] | ||
#![feature(use_extern_macros)] | ||
|
||
extern crate wasm_bindgen_test; | ||
extern crate wasm_bindgen; | ||
|
||
use wasm_bindgen_test::*; | ||
use wasm_bindgen::prelude::*; | ||
|
||
wasm_bindgen_test_configure!(run_in_browser); | ||
|
||
#[wasm_bindgen] | ||
pub struct ConsumeRetString; | ||
|
||
#[wasm_bindgen] | ||
impl ConsumeRetString { | ||
// https://github.com/rustwasm/wasm-bindgen/issues/329#issuecomment-411082013 | ||
// | ||
// This used to cause two `const ptr = ...` declarations, which is invalid | ||
// JS. | ||
pub fn consume(self) -> String { String::new() } | ||
} | ||
|
||
#[wasm_bindgen_test] | ||
fn works() { | ||
ConsumeRetString.consume(); | ||
} |