Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix triggering clippy::mem_forget lint in exported structs #3985

Merged
merged 1 commit into from
Jun 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a small improvement.
Also unrelated to this PR.

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;
Copy link
Collaborator Author

@daxpedda daxpedda Jun 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was missed back when it was added, its unrelated to this PR.

pub mod import_class;
pub mod imports;
pub mod intrinsics;
Expand Down