about summary refs log tree commit diff
path: root/compiler/rustc_mir_transform/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-12-10 03:48:20 +0000
committerbors <bors@rust-lang.org>2024-12-10 03:48:20 +0000
commitff7906bfe1ed264bf9c4d3abe1940e357b7e61dd (patch)
tree1802a49b083991db4938697ebc05ff1e5d7ff97f /compiler/rustc_mir_transform/src
parent974ccc12e6b4fdf38407258071e3d794d383ce3a (diff)
parent5a33ab0d7160e1d0facf5cdea4a1039c12eed229 (diff)
downloadrust-ff7906bfe1ed264bf9c4d3abe1940e357b7e61dd.tar.gz
rust-ff7906bfe1ed264bf9c4d3abe1940e357b7e61dd.zip
Auto merge of #134096 - fmease:rollup-0asgoo8, r=fmease
Rollup of 9 pull requests

Successful merges:

 - #133996 (Move most tests for `-l` and `#[link(..)]` into `tests/ui/link-native-libs`)
 - #134012 (Grammar fixes)
 - #134032 (docs: better examples for `std::ops::ControlFlow`)
 - #134040 (bootstrap: print{ln}! -> eprint{ln}! (take 2))
 - #134043 (Add test to check unicode identifier version)
 - #134053 (rustdoc: rename `issue-\d+.rs` tests to have meaningful names (part 10))
 - #134055 (interpret: clean up deduplicating allocation functions)
 - #134073 (dataflow_const_prop: do not eval a ptr address in SwitchInt)
 - #134084 (Fix typo in RFC mention 3598 -> 3593)

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_mir_transform/src')
-rw-r--r--compiler/rustc_mir_transform/src/dataflow_const_prop.rs9
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 },
         }