Uh oh!
There was an error while loading. Please reload this page.
Fix the issue of unused assignment from MIR liveness checking - #149072
Conversation
rustbot
commented
Nov 19, 2025
Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
| // If this place was dropped and has non-trivial drop, | ||
| // skip reporting field assignments. | ||
| if !is_direct && is_maybe_drop_guard { | ||
| continue; |
There was a problem hiding this comment.
this is for avoiding report unused_assign for this line of code:
https://github.com/rust-lang/rust/blob/main/library/std/src/io/mod.rs#L393
There was a problem hiding this comment.
Why would there be an unused_assign for that line irrespective of whether there is a Drop impl?
There was a problem hiding this comment.
If there's no subsequent code that explicitly reads g.len, this assignment appears "unused".
I think the liveness checking in MIR only knows that the entire g will be dropped, but doesn't know the drop process will read g.len. The is_direct here is used to distinguish this case and avoid false positives for field assignments that Drop may use.
There was a problem hiding this comment.
In the past fields weren't checked, only whole variables, right? Why was that changed?
There was a problem hiding this comment.
The indirect statement is added here:
it seems to be trying to record the access for a variable with a field:
letmut waiter_queue = .... ; ...waiter_queue.set_state_on_drop_to = ..@cjgillot correct me if I'm wrong.
There was a problem hiding this comment.
another issue which related to Drop, but this PR does not fix it:
maybe we need a more general fix.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
57c1dcf to
4930d3eCompareb7c9e8d to
00f3155Comparedavidtwco
commented
Nov 22, 2025
This seems reasonable to me, even if we want a principled fix, this is useful for the time being. @bors r+ rollup |
bors
commented
Nov 22, 2025
…0, r=davidtwco Fix the issue of unused assignment from MIR liveness checking Fixesrust-lang#148960Fixesrust-lang#148418 r? `@davidtwco` cc `@cjgillot` My first try on MIR related code, so it may not be the best fix.
Rollup of 9 pull requests Successful merges: - #148407 (Warn against calls which mutate an interior mutable `const`-item) - #149065 (Address annotate-snippets test differences) - #149072 (Fix the issue of unused assignment from MIR liveness checking) - #149077 (feat: Enable annotate-snippets' simd feature) - #149168 (Fix ICE when collecting opaques from trait method declarations) - #149180 (Couple of refactors to SharedEmitter) - #149185 (Handle cycles when checking impl candidates for `doc(hidden)`) - #149194 (Move safe computation out of unsafe block) - #149204 (Fix typo in HashMap performance comment) r? `@ghost` `@rustbot` modify labels: rollup
Uh oh!
There was an error while loading. Please reload this page.
apiraino
commented
Nov 27, 2025
[beta] backports - rustdoc: Use configured target modifiers when collecting doctests #148068 - fix(rustdoc): Color doctest errors #148834 - Fix the issue of unused assignment from MIR liveness checking #149072 - Skip unused variables warning for unreachable code #149096 - In `BTreeMap::eq`, do not compare the elements if the sizes are different. #149125 - Handle cycles when checking impl candidates for `doc(hidden)` #149185 - Generalize branch references #148395 - only the commit updating CI scripts - Change default branch references #148564 r? cuviper
Rollup of 9 pull requests Successful merges: - rust-lang/rust#148407 (Warn against calls which mutate an interior mutable `const`-item) - rust-lang/rust#149065 (Address annotate-snippets test differences) - rust-lang/rust#149072 (Fix the issue of unused assignment from MIR liveness checking) - rust-lang/rust#149077 (feat: Enable annotate-snippets' simd feature) - rust-lang/rust#149168 (Fix ICE when collecting opaques from trait method declarations) - rust-lang/rust#149180 (Couple of refactors to SharedEmitter) - rust-lang/rust#149185 (Handle cycles when checking impl candidates for `doc(hidden)`) - rust-lang/rust#149194 (Move safe computation out of unsafe block) - rust-lang/rust#149204 (Fix typo in HashMap performance comment) r? `@ghost` `@rustbot` modify labels: rollup
Fixes#148960
Fixes#148418
r? @davidtwco
cc @cjgillot
My first try on MIR related code, so it may not be the best fix.