forked from rustwasm/wasm-bindgen
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow using
'static
lifetimes in functions (rustwasm#3856)
Co-authored-by: Liam Murphy <43807659+Liamolucko@users.noreply.github.com>
- Loading branch information
1 parent
c80bf9a
commit b9ccb8f
Showing
8 changed files
with
133 additions
and
11 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,41 @@ | ||
use wasm_bindgen::prelude::*; | ||
|
||
#[wasm_bindgen] | ||
extern "C" { | ||
type A; | ||
|
||
#[wasm_bindgen(method)] | ||
fn f1(); | ||
#[wasm_bindgen(method)] | ||
fn f2(x: u32); | ||
#[wasm_bindgen(method)] | ||
fn f3(x: &&u32); | ||
#[wasm_bindgen(method)] | ||
fn f4(x: &foo::Bar); | ||
#[wasm_bindgen(method)] | ||
fn f4(x: &::Bar); | ||
#[wasm_bindgen(method)] | ||
fn f4(x: &Bar<T>); | ||
#[wasm_bindgen(method)] | ||
fn f4(x: &dyn Fn(T)); | ||
|
||
#[wasm_bindgen(constructor)] | ||
fn f(); | ||
#[wasm_bindgen(constructor)] | ||
fn f() -> ::Bar; | ||
#[wasm_bindgen(constructor)] | ||
fn f() -> &Bar; | ||
|
||
#[wasm_bindgen(catch)] | ||
fn f() -> u32; | ||
#[wasm_bindgen(catch)] | ||
fn f() -> &u32; | ||
#[wasm_bindgen(catch)] | ||
fn f() -> Result<>; | ||
#[wasm_bindgen(catch)] | ||
fn f() -> Result<'a>; | ||
#[wasm_bindgen(catch)] | ||
fn f() -> Result<&'static u32>; | ||
} | ||
|
||
fn main() {} |
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,65 @@ | ||
error: imported methods must have at least one argument | ||
--> ui-tests/invalid-imports-1.rs:8:5 | ||
| | ||
8 | fn f1(); | ||
| ^^^^^^^^ | ||
|
||
error: first argument of method must be a shared reference | ||
--> ui-tests/invalid-imports-1.rs:10:14 | ||
| | ||
10 | fn f2(x: u32); | ||
| ^^^ | ||
|
||
error: first argument of method must be a path | ||
--> ui-tests/invalid-imports-1.rs:12:15 | ||
| | ||
12 | fn f3(x: &&u32); | ||
| ^^^^ | ||
|
||
error: paths with type parameters are not supported yet | ||
--> ui-tests/invalid-imports-1.rs:18:15 | ||
| | ||
18 | fn f4(x: &Bar<T>); | ||
| ^^^^^^ | ||
|
||
error: first argument of method must be a path | ||
--> ui-tests/invalid-imports-1.rs:20:15 | ||
| | ||
20 | fn f4(x: &dyn Fn(T)); | ||
| ^^^^^^^^^ | ||
|
||
error: constructor returns must be bare types | ||
--> ui-tests/invalid-imports-1.rs:23:5 | ||
| | ||
23 | fn f(); | ||
| ^^^^^^^ | ||
|
||
error: return value of constructor must be a bare path | ||
--> ui-tests/invalid-imports-1.rs:27:5 | ||
| | ||
27 | fn f() -> &Bar; | ||
| ^^^^^^^^^^^^^^^ | ||
|
||
error: must be Result<...> | ||
--> ui-tests/invalid-imports-1.rs:30:15 | ||
| | ||
30 | fn f() -> u32; | ||
| ^^^ | ||
|
||
error: must be Result<...> | ||
--> ui-tests/invalid-imports-1.rs:32:15 | ||
| | ||
32 | fn f() -> &u32; | ||
| ^^^^ | ||
|
||
error: must have at least one generic parameter | ||
--> ui-tests/invalid-imports-1.rs:34:15 | ||
| | ||
34 | fn f() -> Result<>; | ||
| ^^^^^^^^ | ||
|
||
error: it is currently not sound to use lifetimes in function signatures | ||
--> ui-tests/invalid-imports-1.rs:36:22 | ||
| | ||
36 | fn f() -> Result<'a>; | ||
| ^^ |
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,8 @@ | ||
use wasm_bindgen::prelude::*; | ||
|
||
#[wasm_bindgen] | ||
extern "C" { | ||
fn f() -> &'static u32; | ||
} | ||
|
||
fn main() {} |
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,5 @@ | ||
error: cannot return references in #[wasm_bindgen] imports yet | ||
--> ui-tests/invalid-imports-2.rs:5:15 | ||
| | ||
5 | fn f() -> &'static u32; | ||
| ^^^^^^^^^^^^ |
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