Forbid the upper indices of IndexVec indices to allow for niche optimizations
This commit is contained in:
parent
d272e2f6e2
commit
06a041cbd3
5 changed files with 29 additions and 6 deletions
20
src/test/run-pass-fulldeps/newtype_index.rs
Normal file
20
src/test/run-pass-fulldeps/newtype_index.rs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
#![feature(rustc_attrs, step_trait, rustc_private)]
|
||||
|
||||
#[macro_use] extern crate rustc_data_structures;
|
||||
extern crate rustc_serialize;
|
||||
|
||||
use rustc_data_structures::indexed_vec::Idx;
|
||||
|
||||
newtype_index!(struct MyIdx { MAX = 0xFFFF_FFFA });
|
||||
|
||||
use std::mem::size_of;
|
||||
|
||||
fn main() {
|
||||
assert_eq!(size_of::<MyIdx>(), 4);
|
||||
assert_eq!(size_of::<Option<MyIdx>>(), 4);
|
||||
assert_eq!(size_of::<Option<Option<MyIdx>>>(), 4);
|
||||
assert_eq!(size_of::<Option<Option<Option<MyIdx>>>>(), 4);
|
||||
assert_eq!(size_of::<Option<Option<Option<Option<MyIdx>>>>>(), 4);
|
||||
assert_eq!(size_of::<Option<Option<Option<Option<Option<MyIdx>>>>>>(), 4);
|
||||
assert_eq!(size_of::<Option<Option<Option<Option<Option<Option<MyIdx>>>>>>>(), 8);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue