]> git.lizzy.rs Git - rust.git/commitdiff
codegen: mark invalid SetDiscriminant unreachable
authorRalf Jung <post@ralfj.de>
Thu, 5 Dec 2019 13:20:53 +0000 (14:20 +0100)
committerRalf Jung <post@ralfj.de>
Thu, 5 Dec 2019 13:20:53 +0000 (14:20 +0100)
src/librustc_codegen_ssa/mir/place.rs

index e2507394ce68170a8d610f4360a7c1eb1fe9d093..4b8819d11f4f874c2b745c73ba85d5b02de61d8e 100644 (file)
@@ -333,6 +333,7 @@ pub fn codegen_set_discr<Bx: BuilderMethods<'a, 'tcx, Value = V>>(
         variant_index: VariantIdx
     ) {
         if self.layout.for_variant(bx.cx(), variant_index).abi.is_uninhabited() {
+            bx.unreachable();
             return;
         }
         match self.layout.variants {
@@ -488,9 +489,9 @@ pub fn codegen_place(
                     },
                     Err(_) => {
                         // This is unreachable as long as runtime
-                        // and compile-time agree on values
+                        // and compile-time agree perfectly.
                         // With floats that won't always be true,
-                        // so we generate an abort.
+                        // so we generate a (safe) abort.
                         bx.abort();
                         let llval = bx.cx().const_undef(
                             bx.cx().type_ptr_to(bx.cx().backend_type(layout))