-
Notifications
You must be signed in to change notification settings - Fork 940
Refactor: Remove unused variable assignments for fallible functions #8247
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
User @andrzejSulkowski, please sign the CLA here. |
serban300
approved these changes
Apr 15, 2025
bkchr
approved these changes
Apr 17, 2025
@andrzejSulkowski please sign the CLA. |
@bkchr signed |
Krayt78
pushed a commit
to Krayt78/polkadot-sdk
that referenced
this pull request
Apr 18, 2025
…aritytech#8247) # Description This PR resolves issue paritytech#8236. I recently graduated from PBA, and during one of our sessions, [@shawntabrizi](https://github.com/shawntabrizi) pointed out an important issue related to error handling in Rust. When using let _ = some_fallible_function();, if the result is not followed by a ?, the error is silently swallowed without any warning or compiler feedback. In contrast, if we don’t use let _ = and forget to add a ?, the compiler will correctly emit a warning or error — helping the developer catch the issue early. This behavior can easily lead to bugs going unnoticed and makes error handling less reliable, especially for beginners following examples. ## Integration This PR introduces no functional or logical changes, and therefore can safely be integrated into existing downstream projects without additional adjustments. From my point of view, this issue can be classified as something like `I4-Silent`. ## Review Notes I went through all occurrences of `let _ =` with a fallible function. Some of them return values tagged as `#[must_use]`. In these cases, I retained the underscore operator intentionally _(see: `polkadot/node/core/av-store/src/lib.rs` lines: 1099 & 1108, `polkadot/xcm/xcm-builder/src/currency_adapter.rs` line: 217, `substrate/frame/contracts/src/wasm/mod.rs` line: 360, `substrate/frame/revive/src/wasm/mod.rs` line: 307)_. Co-authored-by: Shawn Tabrizi <[email protected]> Co-authored-by: Bastian Köcher <[email protected]>
castillax
pushed a commit
that referenced
this pull request
May 12, 2025
…8247) # Description This PR resolves issue #8236. I recently graduated from PBA, and during one of our sessions, [@shawntabrizi](https://github.com/shawntabrizi) pointed out an important issue related to error handling in Rust. When using let _ = some_fallible_function();, if the result is not followed by a ?, the error is silently swallowed without any warning or compiler feedback. In contrast, if we don’t use let _ = and forget to add a ?, the compiler will correctly emit a warning or error — helping the developer catch the issue early. This behavior can easily lead to bugs going unnoticed and makes error handling less reliable, especially for beginners following examples. ## Integration This PR introduces no functional or logical changes, and therefore can safely be integrated into existing downstream projects without additional adjustments. From my point of view, this issue can be classified as something like `I4-Silent`. ## Review Notes I went through all occurrences of `let _ =` with a fallible function. Some of them return values tagged as `#[must_use]`. In these cases, I retained the underscore operator intentionally _(see: `polkadot/node/core/av-store/src/lib.rs` lines: 1099 & 1108, `polkadot/xcm/xcm-builder/src/currency_adapter.rs` line: 217, `substrate/frame/contracts/src/wasm/mod.rs` line: 360, `substrate/frame/revive/src/wasm/mod.rs` line: 307)_. Co-authored-by: Shawn Tabrizi <[email protected]> Co-authored-by: Bastian Köcher <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR resolves issue #8236.
I recently graduated from PBA, and during one of our sessions, @shawntabrizi pointed out an important issue related to error handling in Rust.
When using let _ = some_fallible_function();, if the result is not followed by a ?, the error is silently swallowed without any warning or compiler feedback.
In contrast, if we don’t use let _ = and forget to add a ?, the compiler will correctly emit a warning or error — helping the developer catch the issue early.
This behavior can easily lead to bugs going unnoticed and makes error handling less reliable, especially for beginners following examples.
Integration
This PR introduces no functional or logical changes, and therefore can safely be integrated into existing downstream projects without additional adjustments.
From my point of view, this issue can be classified as something like
I4-Silent
.Review Notes
I went through all occurrences of
let _ =
with a fallible function. Some of them return values tagged as#[must_use]
. In these cases, I retained the underscore operator intentionally (see:polkadot/node/core/av-store/src/lib.rs
lines: 1099 & 1108,polkadot/xcm/xcm-builder/src/currency_adapter.rs
line: 217,substrate/frame/contracts/src/wasm/mod.rs
line: 360,substrate/frame/revive/src/wasm/mod.rs
line: 307).