rustc: optimize out uninhabited types and variants.
This commit is contained in:
parent
f62e43da28
commit
ced5e04e8b
11 changed files with 197 additions and 92 deletions
18
src/test/ui/print_type_sizes/uninhabited.rs
Normal file
18
src/test/ui/print_type_sizes/uninhabited.rs
Normal 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);
|
||||
}
|
||||
5
src/test/ui/print_type_sizes/uninhabited.stdout
Normal file
5
src/test/ui/print_type_sizes/uninhabited.stdout
Normal 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue