Skip to content

Commit

Permalink
Revert "Allow using 'static lifetimes in functions (rustwasm#3856)"
Browse files Browse the repository at this point in the history
This reverts commit b9ccb8f.
  • Loading branch information
daxpedda committed Mar 2, 2024
1 parent 0023077 commit d22cff5
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 @@ -17,11 +17,6 @@
* Add support for `Option<*const T>`, `Option<*mut T>` and `NonNull<T>`.
[#3852](https://github.com/rustwasm/wasm-bindgen/pull/3852)

### 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 d22cff5

Please sign in to comment.