Skip to content

Commit

Permalink
Revert "Allow using 'static lifetimes in functions (#3856)" (#3865)
Browse files Browse the repository at this point in the history
  • Loading branch information
daxpedda authored Mar 2, 2024
1 parent 983ec57 commit 807bdb4
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 133 deletions.
5 changes: 0 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@
* Allow overriding the URL used for headless tests by setting `WASM_BINDGEN_TEST_ADDRESS`.
[#3861](https://github.com/rustwasm/wasm-bindgen/pull/3861)

### Changed

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

### Fixed

* Make .wasm output deterministic when using `--reference-types`.
Expand Down
12 changes: 5 additions & 7 deletions crates/macro-support/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1652,14 +1652,12 @@ fn assert_no_lifetimes(sig: &syn::Signature) -> Result<(), Diagnostic> {
}

impl<'ast> syn::visit::Visit<'ast> for Walk {
fn visit_lifetime(&mut self, lifetime: &'ast syn::Lifetime) {
if lifetime.ident != "static" {
self.diagnostics.push(err_span!(
lifetime,
"it is currently not sound to use lifetimes in function \
fn visit_lifetime(&mut self, i: &'ast syn::Lifetime) {
self.diagnostics.push(err_span!(
i,
"it is currently not sound to use lifetimes in function \
signatures"
));
}
));
}
}
let mut walk = Walk {
Expand Down
41 changes: 0 additions & 41 deletions crates/macro/ui-tests/invalid-imports-1.rs

This file was deleted.

65 changes: 0 additions & 65 deletions crates/macro/ui-tests/invalid-imports-1.stderr

This file was deleted.

8 changes: 0 additions & 8 deletions crates/macro/ui-tests/invalid-imports-2.rs

This file was deleted.

5 changes: 0 additions & 5 deletions crates/macro/ui-tests/invalid-imports-2.stderr

This file was deleted.

2 changes: 0 additions & 2 deletions crates/macro/ui-tests/invalid-imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ extern "C" {
fn f() -> Result<>;
#[wasm_bindgen(catch)]
fn f() -> Result<'a>;
#[wasm_bindgen(catch)]
fn f() -> Result<&'static u32>;
}

fn main() {}
6 changes: 6 additions & 0 deletions crates/macro/ui-tests/invalid-imports.stderr
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
error: it is currently not sound to use lifetimes in function signatures
--> ui-tests/invalid-imports.rs:7:16
|
7 | fn f() -> &'static u32;
| ^^^^^^^

error: imported methods must have at least one argument
--> ui-tests/invalid-imports.rs:10:5
|
Expand Down

0 comments on commit 807bdb4

Please sign in to comment.