]> git.lizzy.rs Git - rust.git/commitdiff
Merge pull request #598 from solson/rustup
authorOliver Scherer <github35764891676564198441@oli-obk.de>
Mon, 7 Jan 2019 11:27:13 +0000 (12:27 +0100)
committerGitHub <noreply@github.com>
Mon, 7 Jan 2019 11:27:13 +0000 (12:27 +0100)
implement panic_if_uninhabited intrinsic

src/intrinsic.rs

index 0f7382b61b726668be102dbfa44b1b22c4d063ba..0ef847236418c0b8b1033008c25782772bc14023 100644 (file)
@@ -286,6 +286,14 @@ fn call_intrinsic(
                 this.write_scalar(result_ptr, dest)?;
             }
 
+            "panic_if_uninhabited" => {
+                let ty = substs.type_at(0);
+                let layout = this.layout_of(ty)?;
+                if layout.abi.is_uninhabited() {
+                    return err!(Intrinsic(format!("Trying to instantiate uninhabited type {}", ty)))
+                }
+            }
+
             "powf32" => {
                 let f = this.read_scalar(args[0])?.to_f32()?;
                 let f2 = this.read_scalar(args[1])?.to_f32()?;