diff options
| author | León Orell Valerian Liehr <me@fmease.dev> | 2024-12-09 23:39:07 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-12-09 23:39:07 +0100 |
| commit | cb5f03cbce798417735859d753b2b6948e6ab63d (patch) | |
| tree | 074306100ae496d951dc7fa89b17fd647f287e2d /compiler/rustc_mir_transform/src | |
| parent | e0bec9dabba3f10af97536e0872c010dca860dbc (diff) | |
| parent | d0986f45e094b011d132238563b05c09e4f1e20e (diff) | |
| download | rust-cb5f03cbce798417735859d753b2b6948e6ab63d.tar.gz rust-cb5f03cbce798417735859d753b2b6948e6ab63d.zip | |
Rollup merge of #134073 - DianQK:fix-131227, r=oli-obk
dataflow_const_prop: do not eval a ptr address in SwitchInt Fixes #131227.
Diffstat (limited to 'compiler/rustc_mir_transform/src')
| -rw-r--r-- | compiler/rustc_mir_transform/src/dataflow_const_prop.rs | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/compiler/rustc_mir_transform/src/dataflow_const_prop.rs b/compiler/rustc_mir_transform/src/dataflow_const_prop.rs index d017202f48b..b94c925b1db 100644 --- a/compiler/rustc_mir_transform/src/dataflow_const_prop.rs +++ b/compiler/rustc_mir_transform/src/dataflow_const_prop.rs @@ -534,8 +534,13 @@ impl<'a, 'tcx> ConstAnalysis<'a, 'tcx> { // This allows the set of visited edges to grow monotonically with the lattice. FlatSet::Bottom => TerminatorEdges::None, FlatSet::Elem(scalar) => { - let choice = scalar.assert_scalar_int().to_bits_unchecked(); - TerminatorEdges::Single(targets.target_for_value(choice)) + if let Ok(scalar_int) = scalar.try_to_scalar_int() { + TerminatorEdges::Single( + targets.target_for_value(scalar_int.to_bits_unchecked()), + ) + } else { + TerminatorEdges::SwitchInt { discr, targets } + } } FlatSet::Top => TerminatorEdges::SwitchInt { discr, targets }, } |
