rustc_mir_dataflow::rustc_peek

Function sanity_check_via_rustc_peek

source
fn sanity_check_via_rustc_peek<'tcx, A>(
    tcx: TyCtxt<'tcx>,
    cursor: ResultsCursor<'_, 'tcx, A>,
)
where A: RustcPeekAt<'tcx>,
Expand description

This function scans mir for all calls to the intrinsic rustc_peek that have the expression form rustc_peek(&expr).

For each such call, determines what the dataflow bit-state is for the L-value corresponding to expr; if the bit-state is a 1, then that call to rustc_peek is ignored by the sanity check. If the bit-state is a 0, then this pass emits an error message saying “rustc_peek: bit not set”.

The intention is that one can write unit tests for dataflow by putting code into a UI test and using rustc_peek to make observations about the results of dataflow static analyses.

(If there are any calls to rustc_peek that do not match the expression form above, then that emits an error as well, but those errors are not intended to be used for unit tests.)