Auto merge of #54032 - oli-obk:layout_scalar_ranges, r=eddyb

Add forever unstable attribute to allow specifying arbitrary scalar ranges

r? @eddyb for the first commit and @nikomatsakis for the second one
This commit is contained in:
bors 2018-09-14 09:47:21 +00:00
commit dfabe4b885
23 changed files with 279 additions and 161 deletions

View file

@ -64,11 +64,11 @@ fn main() {
// bb0: {
// Validate(Acquire, [_1: &ReFree(DefId(0/1:11 ~ validate_1[317d]::main[0]::{{closure}}[0]), BrEnv) [closure@NodeId(50)], _2: &ReFree(DefId(0/1:11 ~ validate_1[317d]::main[0]::{{closure}}[0]), BrAnon(0)) mut i32]);
// StorageLive(_3);
// Validate(Suspend(ReScope(Remainder(BlockRemainder { block: ItemLocalId(25), first_statement_index: 0 }))), [(*_2): i32]);
// Validate(Suspend(ReScope(Remainder { block: ItemLocalId(25), first_statement_index: 0 })), [(*_2): i32]);
// _3 = &ReErased (*_2);
// Validate(Acquire, [(*_3): i32/ReScope(Remainder(BlockRemainder { block: ItemLocalId(25), first_statement_index: 0 })) (imm)]);
// Validate(Acquire, [(*_3): i32/ReScope(Remainder { block: ItemLocalId(25), first_statement_index: 0 }) (imm)]);
// _0 = (*_3);
// EndRegion(ReScope(Remainder(BlockRemainder { block: ItemLocalId(25), first_statement_index: 0 })));
// EndRegion(ReScope(Remainder { block: ItemLocalId(25), first_statement_index: 0 }));
// StorageDead(_3);
// return;
// }

View file

@ -48,12 +48,12 @@ fn main() {
// StorageLive(_1);
// _1 = Test { x: const 0i32 };
// StorageLive(_2);
// Validate(Suspend(ReScope(Remainder(BlockRemainder { block: ItemLocalId(20), first_statement_index: 3 }))), [_1: Test]);
// Validate(Suspend(ReScope(Remainder { block: ItemLocalId(20), first_statement_index: 3 })), [_1: Test]);
// _2 = &ReErased _1;
// Validate(Acquire, [(*_2): Test/ReScope(Remainder(BlockRemainder { block: ItemLocalId(20), first_statement_index: 3 })) (imm)]);
// Validate(Acquire, [(*_2): Test/ReScope(Remainder { block: ItemLocalId(20), first_statement_index: 3 }) (imm)]);
// StorageLive(_4);
// StorageLive(_5);
// Validate(Suspend(ReScope(Node(ItemLocalId(18)))), [((*_2).0: i32): i32/ReScope(Remainder(BlockRemainder { block: ItemLocalId(20), first_statement_index: 3 })) (imm)]);
// Validate(Suspend(ReScope(Node(ItemLocalId(18)))), [((*_2).0: i32): i32/ReScope(Remainder { block: ItemLocalId(20), first_statement_index: 3 }) (imm)]);
// _5 = &ReErased ((*_2).0: i32);
// Validate(Acquire, [(*_5): i32/ReScope(Node(ItemLocalId(18))) (imm)]);
// Validate(Suspend(ReScope(Node(ItemLocalId(18)))), [(*_5): i32/ReScope(Node(ItemLocalId(18))) (imm)]);
@ -68,7 +68,7 @@ fn main() {
// StorageDead(_4);
// StorageDead(_5);
// _0 = ();
// EndRegion(ReScope(Remainder(BlockRemainder { block: ItemLocalId(20), first_statement_index: 3 })));
// EndRegion(ReScope(Remainder { block: ItemLocalId(20), first_statement_index: 3 }));
// StorageDead(_2);
// StorageDead(_1);
// return;

View file

@ -0,0 +1,20 @@
#![feature(min_const_fn, rustc_attrs, rustc_private, step_trait)]
#[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);
}

View file

@ -0,0 +1,5 @@
// compile-pass
static ASSERT: () = [()][!(std::mem::size_of::<u32>() == 4) as usize];
fn main() {}