summary refs log tree commit diff
path: root/compiler/rustc_codegen_ssa/src/mir
diff options
context:
space:
mode:
authorScott McMurray <scottmcm@users.noreply.github.com>2025-07-10 09:17:28 -0700
committerScott McMurray <scottmcm@users.noreply.github.com>2025-07-10 09:17:28 -0700
commitf5fc8727dbbf8c9e93bb0822b2e5bfa77dbd0208 (patch)
tree2842ed4a91fdced7c7697a575f63b0e8ba9c2d3c /compiler/rustc_codegen_ssa/src/mir
parent58d7c2d5a760c1adfa4c3984eeb12787f5ad5b1d (diff)
downloadrust-f5fc8727dbbf8c9e93bb0822b2e5bfa77dbd0208.tar.gz
rust-f5fc8727dbbf8c9e93bb0822b2e5bfa77dbd0208.zip
Add `BuilderMethods::unreachable_nonterminator`
So places that need `unreachable` but in the middle of a basic block can call that instead of figuring out the best way to do it.

Diffstat (limited to 'compiler/rustc_codegen_ssa/src/mir')
-rw-r--r--compiler/rustc_codegen_ssa/src/mir/rvalue.rs8
1 files changed, 2 insertions, 6 deletions
diff --git a/compiler/rustc_codegen_ssa/src/mir/rvalue.rs b/compiler/rustc_codegen_ssa/src/mir/rvalue.rs
index 1e3b76e5f93..bf3b1e73b94 100644
--- a/compiler/rustc_codegen_ssa/src/mir/rvalue.rs
+++ b/compiler/rustc_codegen_ssa/src/mir/rvalue.rs
@@ -207,9 +207,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
         {
             // These cases are all UB to actually hit, so don't emit code for them.
             // (The size mismatches are reachable via `transmute_unchecked`.)
-            // We can't use unreachable because that's a terminator, and we
-            // need something that can be in the middle of a basic block.
-            bx.assume(bx.cx().const_bool(false))
+            bx.unreachable_nonterminator();
         } else {
             // Since in this path we have a place anyway, we can store or copy to it,
             // making sure we use the destination place's alignment even if the
@@ -236,9 +234,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
             || operand.layout.is_uninhabited()
             || cast.is_uninhabited()
         {
-            // We can't use unreachable because that's a terminator, and we
-            // need something that can be in the middle of a basic block.
-            bx.assume(bx.cx().const_bool(false));
+            bx.unreachable_nonterminator();
 
             // We still need to return a value of the appropriate type, but
             // it's already UB so do the easiest thing available.