Function rustc_mir_dataflow::impls::switch_on_enum_discriminant[][src]

fn switch_on_enum_discriminant<'tcx, 'mir>(
    tcx: TyCtxt<'tcx>,
    body: &'mir Body<'tcx>,
    block: &'mir BasicBlockData<'tcx>,
    switch_on: Place<'tcx>
) -> Option<(Place<'tcx>, &'tcx AdtDef)>
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.