Skip to content

Change SwitchInt handling in dataflow analysis.#156169

Open
nnethercote wants to merge 1 commit intorust-lang:mainfrom
nnethercote:simplify-SwitchInt-stuff
Open

Change SwitchInt handling in dataflow analysis.#156169
nnethercote wants to merge 1 commit intorust-lang:mainfrom
nnethercote:simplify-SwitchInt-stuff

Conversation

@nnethercote
Copy link
Copy Markdown
Contributor

We call get_switch_int_data once for the switch and then pass that data to apply_switch_int_edge_effect for each switch target.

The only case in practice is MaybePlacesSwitchIntData which does an awkward thing, maintaining an index into the discriminants and updating it on each call to apply_switch_int_edge_effect.

This commit changes things to do more work up front in get_switch_int_data, in order to then do less work in apply_switch_int_edge_effect. This avoids the need for the variants and next_discr methods and the discriminants index. Overall it's a little simpler.

r? @cjgillot

We call `get_switch_int_data` once for the switch and then pass that
data to `apply_switch_int_edge_effect` for each switch target.

The only case in practice is `MaybePlacesSwitchIntData` which does an
awkward thing, maintaining an index into the discriminants and updating
it on each call to `apply_switch_int_edge_effect`.

This commit changes things to do more work up front in
`get_switch_int_data`, in order to then do less work in
`apply_switch_int_edge_effect`. This avoids the need for the `variants`
and `next_discr` methods and the discriminants index. Overall it's a
little simpler.
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants