Add SwitchTargetValue.

This is much clearer than `Option<u128>`.
This commit is contained in:
Nicholas Nethercote
2025-02-14 09:54:01 +11:00
parent 23dbff88f6
commit 8403d39dce
5 changed files with 33 additions and 12 deletions

View File

@@ -4,7 +4,9 @@ use rustc_abi::VariantIdx;
use rustc_index::Idx;
use rustc_index::bit_set::{DenseBitSet, MixedBitSet};
use rustc_middle::bug;
use rustc_middle::mir::{self, Body, CallReturnPlaces, Location, TerminatorEdges};
use rustc_middle::mir::{
self, Body, CallReturnPlaces, Location, SwitchTargetValue, TerminatorEdges,
};
use rustc_middle::ty::util::Discr;
use rustc_middle::ty::{self, TyCtxt};
use tracing::{debug, instrument};
@@ -424,7 +426,7 @@ impl<'tcx> Analysis<'tcx> for MaybeInitializedPlaces<'_, 'tcx> {
state: &mut Self::Domain,
edge: SwitchIntTarget,
) {
if let Some(value) = edge.value {
if let SwitchTargetValue::Normal(value) = edge.value {
// Kill all move paths that correspond to variants we know to be inactive along this
// particular outgoing edge of a `SwitchInt`.
drop_flag_effects::on_all_inactive_variants(
@@ -537,7 +539,7 @@ impl<'tcx> Analysis<'tcx> for MaybeUninitializedPlaces<'_, 'tcx> {
state: &mut Self::Domain,
edge: SwitchIntTarget,
) {
if let Some(value) = edge.value {
if let SwitchTargetValue::Normal(value) = edge.value {
// Mark all move paths that correspond to variants other than this one as maybe
// uninitialized (in reality, they are *definitely* uninitialized).
drop_flag_effects::on_all_inactive_variants(