-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
False positive "field is never read" warnings #81626
Comments
Seems like this is a regression from d3c69a4. |
cc @sanxiyn |
Oops, sorry! Technically, I think restricting the lint to non-reference fields should work, and will submit a PR to do so quickly. Please double check whether my thinking is correct. |
Ah, yeah, I somehow thought that the macro was needed to trigger the bug but it is not. That sounds good. Writes to mutable references have side effects so doing that seems ok. |
Would that also cover this case here, in the idna crate? (The https://github.com/servo/rust-url/pull/674/checks?check_run_id=1855869353 |
Yeah, I think it's the same. |
Consider auto derefs before warning about write only fields Changes from rust-lang#81473 extended the dead code lint with an ability to detect fields that are written to but never read from. The implementation skips over fields on the left hand side of an assignment, without marking them as live. A field access might involve an automatic dereference and de-facto read the field. Conservatively mark expressions with deref adjustments as live to avoid generating false positive warnings. Closes rust-lang#81626.
Consider auto derefs before warning about write only fields Changes from rust-lang#81473 extended the dead code lint with an ability to detect fields that are written to but never read from. The implementation skips over fields on the left hand side of an assignment, without marking them as live. A field access might involve an automatic dereference and de-facto read the field. Conservatively mark expressions with deref adjustments as live to avoid generating false positive warnings. Closes rust-lang#81626.
Ah, this was closed, but the bug leaked into beta (as mentioned in #81658) while the fix is only in nightly. Reopening and tagging as stable-to-beta regression |
Assigning |
As noted on #81473 (comment) , we're going to resolve the beta issue by reverting PR #81473 on beta (which I have assigned myself to take care of). |
…-fields, r=Mark-Simulacrum Revert PR 81473 to resolve (on beta) issues 81626 and 81658. Revert PR rust-lang#81473 to resolve (on beta) issues rust-lang#81626 and rust-lang#81658. Revert "Add missing brace" This reverts commit 85ad773. Revert "Simplify base_expr" This reverts commit 899aae4. Revert "Warn write-only fields" This reverts commit d3c69a4.
This was a regression affecting beta 1.51, closing this. |
Here's a reduced test-case from Firefox source code:
Compiling that program warns with:
Which is obviously not true.
Meta
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: