Skip to content

Commit 8655ad5

Browse files
committed
codegen: mark invalid SetDiscriminant unreachable
1 parent aeaaf8f commit 8655ad5

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/librustc_codegen_ssa/mir/place.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,7 @@ impl<'a, 'tcx, V: CodegenObject> PlaceRef<'tcx, V> {
333333
variant_index: VariantIdx
334334
) {
335335
if self.layout.for_variant(bx.cx(), variant_index).abi.is_uninhabited() {
336+
bx.unreachable();
336337
return;
337338
}
338339
match self.layout.variants {
@@ -488,9 +489,9 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
488489
},
489490
Err(_) => {
490491
// This is unreachable as long as runtime
491-
// and compile-time agree on values
492+
// and compile-time agree perfectly.
492493
// With floats that won't always be true,
493-
// so we generate an abort.
494+
// so we generate a (safe) abort.
494495
bx.abort();
495496
let llval = bx.cx().const_undef(
496497
bx.cx().type_ptr_to(bx.cx().backend_type(layout))

0 commit comments

Comments
 (0)