about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorEduard-Mihai Burtescu <edy.burt@gmail.com>2017-09-26 21:34:10 +0300
committerEduard-Mihai Burtescu <edy.burt@gmail.com>2017-11-19 02:14:33 +0200
commitced5e04e8bfa80ae297cba6c95ec0948dceb6933 (patch)
treeacb7b944d4fcdbb06ae6ecd786c7505616edc1ea /src/test
parentf62e43da2891a65a484a917d84642544ed093ba2 (diff)
downloadrust-ced5e04e8bfa80ae297cba6c95ec0948dceb6933.tar.gz
rust-ced5e04e8bfa80ae297cba6c95ec0948dceb6933.zip
rustc: optimize out uninhabited types and variants.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/ui/print_type_sizes/uninhabited.rs18
-rw-r--r--src/test/ui/print_type_sizes/uninhabited.stdout5
2 files changed, 23 insertions, 0 deletions
diff --git a/src/test/ui/print_type_sizes/uninhabited.rs b/src/test/ui/print_type_sizes/uninhabited.rs
new file mode 100644
index 00000000000..69cc4c93360
--- /dev/null
+++ b/src/test/ui/print_type_sizes/uninhabited.rs
@@ -0,0 +1,18 @@
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// compile-flags: -Z print-type-sizes
+
+#![feature(never_type)]
+
+pub fn main() {
+    let _x: Option<!> = None;
+    let _y: Result<u32, !> = Ok(42);
+}
diff --git a/src/test/ui/print_type_sizes/uninhabited.stdout b/src/test/ui/print_type_sizes/uninhabited.stdout
new file mode 100644
index 00000000000..2a8706f7ac5
--- /dev/null
+++ b/src/test/ui/print_type_sizes/uninhabited.stdout
@@ -0,0 +1,5 @@
+print-type-size type: `std::result::Result<u32, !>`: 4 bytes, alignment: 4 bytes
+print-type-size     variant `Ok`: 4 bytes
+print-type-size         field `.0`: 4 bytes
+print-type-size type: `std::option::Option<!>`: 0 bytes, alignment: 1 bytes
+print-type-size     variant `None`: 0 bytes