rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
98.76k stars 12.76k forks source link

Simplify `SwitchInt` handling #133328

Open nnethercote opened 9 hours ago

nnethercote commented 9 hours ago

Dataflow handling of SwitchInt is currently complicated. This PR simplifies it.

r? @cjgillot

nnethercote commented 8 hours ago

Details in the individual commits.

Let me know if I am sending you too many reviews, I can reassign if necessary.

It's worth noting my motivation for this change. I wanted to try making Borrowck a normal analysis whose results are computed with iterate_to_fixpoint instead of being cobbled together from the results of Borrows/MaybeUninitializedPlaces/EverInitializedPlaces. When I tried to do this the complexity of SwitchInt handling completely blocked me from doing it. After doing the simplification in this PR, it was not just possible, but fairly easy. In the end, making Borrowck a normal analysis turned out to not work well -- it slowed compile times noticeably -- but it was a good proof of concept that the new structure is simpler and more flexible.