Skip to content

Commit

Permalink
Fix triggering clippy::mem_forget lint
Browse files Browse the repository at this point in the history
  • Loading branch information
daxpedda committed Jun 12, 2024
1 parent f1c840f commit 02e1605
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@
* Fixed Rust values not getting GC'd if they were created via. a constructor.
[#3940](https://github.com/rustwasm/wasm-bindgen/pull/3940)

* Fix triggering `clippy::mem_forget` lint in exported structs.
[#3985](https://github.com/rustwasm/wasm-bindgen/pull/3985)

--------------------------------------------------------------------------------

## [0.2.92](https://github.com/rustwasm/wasm-bindgen/compare/0.2.91...0.2.92)
Expand Down
1 change: 1 addition & 0 deletions crates/backend/src/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,7 @@ impl ToTokens for ast::Struct {
#wasm_bindgen::__rt::std::result::Result::Err(value)
} else {
// Don't run `JsValue`'s destructor, `unwrap_fn` already did that for us.
#[allow(clippy::mem_forget)]
#wasm_bindgen::__rt::std::mem::forget(value);
unsafe {
#wasm_bindgen::__rt::std::result::Result::Ok(
Expand Down
6 changes: 6 additions & 0 deletions tests/wasm/3944.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#![deny(clippy::mem_forget)]

use wasm_bindgen::prelude::*;

#[wasm_bindgen]
struct Foo2;
2 changes: 1 addition & 1 deletion tests/wasm/closures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ fn drop_during_call_ok() {
assert_eq!(x, 3);

// make sure `A` is bound to our closure environment.
drop(&a);
let _a = &a;
unsafe {
assert!(!HIT);
}
Expand Down
2 changes: 2 additions & 0 deletions tests/wasm/ignore.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use wasm_bindgen_test::wasm_bindgen_test;

#[wasm_bindgen_test]
#[ignore]
fn should_panic() {
Expand Down
3 changes: 3 additions & 0 deletions tests/wasm/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ extern crate serde_derive;

use wasm_bindgen::prelude::*;

#[path = "3944.rs"]
pub mod _3944;
pub mod api;
pub mod arg_names;
pub mod async_vecs;
Expand All @@ -31,6 +33,7 @@ pub mod final_;
pub mod futures;
pub mod gc;
pub mod getters_and_setters;
pub mod ignore;
pub mod import_class;
pub mod imports;
pub mod intrinsics;
Expand Down

0 comments on commit 02e1605

Please sign in to comment.