rustc_mir_dataflow::impls::initialized

Function switch_on_enum_discriminant

source
fn switch_on_enum_discriminant<'mir, 'tcx>(
    tcx: TyCtxt<'tcx>,
    body: &'mir Body<'tcx>,
    block: &'mir BasicBlockData<'tcx>,
    switch_on: Place<'tcx>,
) -> Option<(Place<'tcx>, AdtDef<'tcx>)>
Expand description

Inspect a SwitchInt-terminated basic block to see if the condition of that SwitchInt is an enum discriminant.

We expect such blocks to have a call to discriminant as their last statement like so:

...
_42 = discriminant(_1)
SwitchInt(_42, ..)

If the basic block matches this pattern, this function returns the place corresponding to the enum (_1 in the example above) as well as the AdtDef of that enum.