Skip to content

Commit 807bdb4

Browse files
authored
Revert "Allow using 'static lifetimes in functions (#3856)" (#3865)
1 parent 983ec57 commit 807bdb4

8 files changed

+11
-133
lines changed

CHANGELOG.md

-5
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,6 @@
2121
* Allow overriding the URL used for headless tests by setting `WASM_BINDGEN_TEST_ADDRESS`.
2222
[#3861](https://github.com/rustwasm/wasm-bindgen/pull/3861)
2323

24-
### Changed
25-
26-
* Allow using `'static` lifetimes in functions marked with `#[wasm_bindgen]`. This does not allow references where they were not allowed before!
27-
[#3856](https://github.com/rustwasm/wasm-bindgen/pull/3856)
28-
2924
### Fixed
3025

3126
* Make .wasm output deterministic when using `--reference-types`.

crates/macro-support/src/parser.rs

+5-7
Original file line numberDiff line numberDiff line change
@@ -1652,14 +1652,12 @@ fn assert_no_lifetimes(sig: &syn::Signature) -> Result<(), Diagnostic> {
16521652
}
16531653

16541654
impl<'ast> syn::visit::Visit<'ast> for Walk {
1655-
fn visit_lifetime(&mut self, lifetime: &'ast syn::Lifetime) {
1656-
if lifetime.ident != "static" {
1657-
self.diagnostics.push(err_span!(
1658-
lifetime,
1659-
"it is currently not sound to use lifetimes in function \
1655+
fn visit_lifetime(&mut self, i: &'ast syn::Lifetime) {
1656+
self.diagnostics.push(err_span!(
1657+
i,
1658+
"it is currently not sound to use lifetimes in function \
16601659
signatures"
1661-
));
1662-
}
1660+
));
16631661
}
16641662
}
16651663
let mut walk = Walk {

crates/macro/ui-tests/invalid-imports-1.rs

-41
This file was deleted.

crates/macro/ui-tests/invalid-imports-1.stderr

-65
This file was deleted.

crates/macro/ui-tests/invalid-imports-2.rs

-8
This file was deleted.

crates/macro/ui-tests/invalid-imports-2.stderr

-5
This file was deleted.

crates/macro/ui-tests/invalid-imports.rs

-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ extern "C" {
3636
fn f() -> Result<>;
3737
#[wasm_bindgen(catch)]
3838
fn f() -> Result<'a>;
39-
#[wasm_bindgen(catch)]
40-
fn f() -> Result<&'static u32>;
4139
}
4240

4341
fn main() {}

crates/macro/ui-tests/invalid-imports.stderr

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
error: it is currently not sound to use lifetimes in function signatures
2+
--> ui-tests/invalid-imports.rs:7:16
3+
|
4+
7 | fn f() -> &'static u32;
5+
| ^^^^^^^
6+
17
error: imported methods must have at least one argument
28
--> ui-tests/invalid-imports.rs:10:5
39
|

0 commit comments

Comments
 (0)