rustc: optimize out uninhabited types and variants.

This commit is contained in:
Eduard-Mihai Burtescu 2017-09-26 21:34:10 +03:00
parent f62e43da28
commit ced5e04e8b
11 changed files with 197 additions and 92 deletions

View file

@ -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);
}

View file

@ -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