-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Unneeded Unit Expression Warning From Clippy #2774
Comments
same here, this breaks my CIs |
Example input: #[wasm_bindgen(js_name = "setTimeout")]
pub fn set_timeout(&mut self, timeout: u16) -> u16 {
let old = self.timeout;
self.timeout = timeout;
old
} Expanded output: pub fn set_timeout(&mut self, timeout: u16) -> u16 {
#[automatically_derived]
const __wasm_bindgen_generated_StructName_setTimeout__const: () = {
pub extern "C" fn __wasm_bindgen_generated_StructName_setTimeout(
me: u32,
arg1: <u16 as wasm_bindgen::convert::FromWasmAbi>::Abi,
) -> <u16 as wasm_bindgen::convert::ReturnWasmAbi>::Abi {
let _ret = {
let mut me = unsafe {
< WasmStructName as wasm_bindgen :: convert :: RefMutFromWasmAbi > :: ref_mut_from_abi (me)
};
let me = &mut *me;
let arg1 =
unsafe { <u16 as wasm_bindgen::convert::FromWasmAbi>::from_abi(arg1) };
me.set_timeout(arg1)
};
<u16 as wasm_bindgen::convert::ReturnWasmAbi>::return_abi(_ret)
}
()
};
let old = self.timeout;
self.timeout = timeout;
old
} That |
I can confirm that this error comes with the update from 0.2.78 to 0.2.79. |
There is an `unused-unit` lint that will fail for now, but this is regarded as a false positive and should eventualy get fixed: rustwasm/wasm-bindgen#2774
* Fix wasm client * Re-enable CI on wasm client There is an `unused-unit` lint that will fail for now, but this is regarded as a false positive and should eventualy get fixed: rustwasm/wasm-bindgen#2774 * The wasm tests would be run under native arch
Add #[allow(dead_code)] for a field that is only available in feature = "rust_signer". Skip wasm-bindgen version 0.2.79 per rustwasm/wasm-bindgen#2774.
Add #[allow(dead_code)] for a field that is only available in feature = "rust_signer". Skip wasm-bindgen version 0.2.79 per rustwasm/wasm-bindgen#2774.
Currently wasm-bindgen has an unresolved bug that generates code that emits a clippy warning. So we'll just pin it until rustwasm/wasm-bindgen#2774 is fixed
Add #[allow(dead_code)] for a field that is only available in feature = "rust_signer". Skip wasm-bindgen version 0.2.79 per rustwasm/wasm-bindgen#2774.
* Feature-locked unused imports * Reverted wasam-bindgen to 0.2.78 to temporarily bypass rustwasm/wasm-bindgen#2774 * Reorganised imports
@alexcrichton would it be possible to release a new version with the fix? |
Sorry but no I would prefer to not make a release simply for clippy. |
lint errors due to rustwasm/wasm-bindgen#2774
I'm facing a similar issue. As a new developer working on Rust, I thought this was caused by a bug on my side, and sad to see that even though the maintainer acknowledges the issue, he does not prefer to "make a release simply for clippy". Can you at least point us to a solution/explanation for this? |
As I understand these things (being somewhat new to Rust as well), normally you wouldn't see a warning for code that is in another crate. However in this case it's being caused by something inside macro generated code... which is in a sense actually in your crate. Still not your fault, and still an annoying bummer. If you want to suppress the warning while waiting for the next release, you should be able to add this to the top of the affected file: See https://github.com/rust-lang/rust-clippy#allowingdenying-lints |
These are caused by rustwasm/wasm-bindgen#2774 while we wait for a new release on their end.
`wasm_bindgen` sometimes generates an orphaned unit expression as part of its macro expansion. This is relatively harmless, but is flagged by clippy, this codebase's choice for Rust linter. We have no real control on how `#[wasm_bindgen]` expands, and no real way to avoid this from happening in the expanded code, so we opt to disable the `clippy::unused_unit` lint check on affected files. Definitely not ideal, but spotting unused units on code we're writing ourselves are relatively easy to spot anyway. @see: rustwasm/wasm-bindgen#2774
Is there any ETA of the release? Or any argument why it's not being considered significant? Changing the linting (or update) policies because of a misbehaving 3rd party macro is quite a red flag to us. I'm more concerned about this than the bug itself. |
The remaining "unneeded unit expression" is not out fault: rustwasm/wasm-bindgen#2774
* CHANGELOG update * dding triple masking code to ledger and query server package * integrating finutils and all non-src * additions and fixes in wasm, query server and ledger (#173) also dependencies and misc changes * Added functionality to return list of randomizer strings through wasm * Adding WASM wrappers to triple masking key serialization/deserialization functions * anon pub key randomizer wasm * Returning Randomized AXfr pub key as string * ruc fixes and integration test scripts improvements * adding wasmcat into this branch * remove auto wasm build from pull request to main branch * Integrate zei arkworks backend (#192) switched to zei develop, added ark patch and fixes for BLSScalar bytes, changed anon keys * Nullifier hash, wasm oabar and integrate new setup params (#210) * added a function in wasm for nullifier hash generation * added to query server a way to check if a nullifier hash exists or not * added a wasm function to get oabar * made some changes to support new zei setup parameters * update positive unit test on txn_builder with anon fees (#208) * modified axfr_create_verify_unit_positive_tests() by adding fee input Author: hridambasu Co-authored-by: Serge-Juarez Co-authored-by: akhilpeddireddy Co-authored-by: Harshad Patil * wasm randomize AXfrKeyPair fn and fix lint lint errors due to rustwasm/wasm-bindgen#2774 * sync with zei updates * Fix node reset and start in devnet * fix compile error caused by yanked anomaly * Wasm function to deserialize ABAR * Fix nullifier hash serialization * Adding serialization, deserialization for AnonKeys object * Removing fee for non-Fra assets in bar2abar for testing * Fix AnonKeys serialization * Fix FeeInputs Vector capacity limit * Fix added capacity for FeeInputs * Integrating anon transfer fee and remainder with txn builder and CLI (#231) Co-authored-by: akhilpeddireddy <akhilpeddireddy@gmail.com> * cli abar spent status, handle randomizer for axfr remainder * fix build after zei merkle tree optimization * Abar to bar integration (#213) * Added abar_to_bar integration to the platform 1. made changes to ledger to handle the conv ops 2. added script to test abar_to_bar conversion on fresh local net * Wasm bindingg for abar_to_bar conversion operation * FeeOp for Abar - Bar conversions * change axfr public key in integration/demo script new keys are used after the arkworks switch in zei * fix compile error caused by yanked anomaly * Removing Rocksdb patch as the bug in librocksdb is fixed * Removed invalid short flags for fn commands * Fix public key and address CLI flags Co-authored-by: akhilpeddireddy <akhilpeddireddy@gmail.com> Co-authored-by: charlie <charlie@findora.org> * Fix FeeInputs multiple insert call * Fix build error * Fix new merkle tree depth and abar to bar demo script * adding wasm support for anon fee and remainder * fix storage version, lint and wasm build * fix clippy errors in smt * add back wasm_bindgen were removed in v3 when develop got merged in * Change names of wasm functions * Apply precompute verifier parameters (#246) * Apply precompute verifier parameters * hotfix verifier test code * Fix add_input bug in add_fee of transaction builder (#245) * Fix add_input bug in add_fee of transaction builder * fix fmt * Anon assets mixing (#244) * check abar unspent before transfer * update anon-transfer CLI to support assets * update anon-transfer-batch CLI to support assets * add test shell for anon assets mixing * fix multi_axfr_test shell * cleanup test tmp_file * cut down test shell sleep time * This includes the function descibed in FO-887 (#251) * This includes the function descibed in FO-887 * dding wasm interface to fee estimation Co-authored-by: Harshad Patil <harshad0402@gmail.com> * Anon Fee for ABAR to BAR (#249) * Updating zei library version * Regression tests for triple masking (#254) * Regression tests for - bar to abar - abar transfer - abar to bar * fix binary path * Anon fee for abar to bar conversion * Updating the zei library version * Upgrade zei version & hotfix unwrap * randomizer map and remove amount.rs (#256) * Update zei version for anon_fee * Triple masking docs (#258) * Adding docs for Abar conversions * fix SID pick in bar to abar conversion * Fix: user param generation after fee calculation in anon transfer * Fix algo for FRA fee estimation for some corner cases (#262) * Fix algo for FRA fee estimation for some corner cases * Fix fmt * Fix anon transfer transaction build * Fix build failure & txn serialization * Fix handle AXfrKeypair pointer in abar_to_bar conversion * Fix wasm Key null pointer issue Clonig all the signing and encryption keys to avoid moving of pointer in rust-wasm code. Co-authored-by: charlie <charlie@findora.org> Co-authored-by: Harshad Patil <harshad0402@gmail.com> Co-authored-by: tommady <tommady@users.noreply.github.com> Co-authored-by: Hridam Basu <hridam.basu@gmail.com> Co-authored-by: findora-crypto <weikeng@findora.org> Co-authored-by: Serge-Juarez <86990655+Serge-Juarez@users.noreply.github.com> Co-authored-by: Findora-Sun <94740291+findora-sun@users.noreply.github.com> Co-authored-by: Sun <sun@findora.org>
seeing this in our CI as well |
This eliminates the Clippy complaint about redundant unit expression, see rustwasm/wasm-bindgen#2774
Describe the Bug
wasm-bindgen 0.2.79 released not long ago triggered a workflow error in our repository, which doesn't exist before.
A local run of
cargo +nightly clippy -- -Z macro-backtrace
withclippy 0.1.60 (5e57faa 2022-01-19)
prints the following:Steps to Reproduce
git clone https://github.com/iotaledger/iota.rs
cd iota.rs/bindings/wasm/native
cargo clippy
(version of toolchain doesn't actually matter)Expected Behavior
No warning should be given.
Actual Behavior
client-wasm
(lib) generated 100 warnings (90 duplicates).Additional Context
We haven't tried to identify whether this is a problem from our side yet.
The text was updated successfully, but these errors were encountered: