rust icon indicating copy to clipboard operation
rust copied to clipboard

Avoid duplicating StorageLive in let-else

Open dingxiangfei2009 opened this issue 2 years ago • 7 comments

cc @est31

Fix #101867 Fix #101932

#101410 introduced directives to activate storages of bindings in let-else earlier. However, since it is using the machinery of match and friends for pattern matching and binding, those storages are activated for the second time. This PR adjusts this behavior and avoid the duplicated activation for let-else statements.

dingxiangfei2009 avatar Sep 16 '22 11:09 dingxiangfei2009

r? @oli-obk

(rust-highfive has picked a reviewer for you, use r? to override)

rust-highfive avatar Sep 16 '22 11:09 rust-highfive

./x.py test src/tools/miri is now passing again after this change. You may try it out.

dingxiangfei2009 avatar Sep 16 '22 11:09 dingxiangfei2009

Please also add a mir-opt test. https://github.com/rust-lang/rust/pull/101410#issuecomment-1248806073 seems like a good candidate as it is very minimal.

oli-obk avatar Sep 16 '22 11:09 oli-obk

Preemptively beta-nominating for backport to 1.65 (into which https://github.com/rust-lang/rust/pull/101410 landed), since it seems likely this would otherwise only make 1.66. (If we reject this we'll likely want to post a revert for #101410, but this was an easier first step to track the need).

Mark-Simulacrum avatar Sep 16 '22 12:09 Mark-Simulacrum

@oli-obk Thank you! I have added that test mentioned in the #101410 thread. I have tentatively selected mir_map which is hopefully very close to the original MIR generated. Please advise better choices. :pray:

dingxiangfei2009 avatar Sep 16 '22 12:09 dingxiangfei2009

@dingxiangfei2009 now that #93628 has been merged, can you rebase this PR? Most importantly, the test files will need #![cfg_attr(bootstrap, feature(let_else))], instead of #![feature(let_else)].

Also, would it be possible to add the example from #101932 as a run-pass regression test? So add // run-pass to it as well as // issue #101932, and put it e.g. into src/test/ui/let-else/const-fn.rs.

est31 avatar Sep 17 '22 20:09 est31

@est31 branch rebased with the test case from #101932

cc @oli-obk for the relevant changes.

dingxiangfei2009 avatar Sep 18 '22 04:09 dingxiangfei2009

This issue is completely blocking Miri development, would be good to get the fix landed ASAP. :)

RalfJung avatar Sep 19 '22 06:09 RalfJung

@bors r+ p=1 (unblocks miri)

oli-obk avatar Sep 19 '22 12:09 oli-obk

:pushpin: Commit eb36f5ee5b71cbe3eb356f8e56e9c9a69b6d649d has been approved by oli-obk

It is now in the queue for this repository.

bors avatar Sep 19 '22 12:09 bors

@bors p=10

RalfJung avatar Sep 19 '22 12:09 RalfJung

:hourglass: Testing commit eb36f5ee5b71cbe3eb356f8e56e9c9a69b6d649d with merge 2019147c5642c08cdb9ad4cacd97dd1fa4ffa701...

bors avatar Sep 19 '22 17:09 bors

:sunny: Test successful - checks-actions Approved by: oli-obk Pushing 2019147c5642c08cdb9ad4cacd97dd1fa4ffa701 to master...

bors avatar Sep 19 '22 20:09 bors

Finished benchmarking commit (2019147c5642c08cdb9ad4cacd97dd1fa4ffa701): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean[^1] range count[^2]
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
2.6% [2.2%, 3.3%] 3
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Cycles

This benchmark run did not return any relevant results for this metric.

[^1]: the arithmetic mean of the percent change [^2]: number of relevant changes

rust-timer avatar Sep 19 '22 22:09 rust-timer

Beta backport approved as per compiler team on Zulip

@rustbot label +beta-accepted

apiraino avatar Sep 22 '22 14:09 apiraino

Judging from this the release team will do the beta backports so I consider this done from my end now. :)

RalfJung avatar Sep 22 '22 14:09 RalfJung