Add test where slice is a const.
This commit is contained in:
parent
4ad22b91fc
commit
b7a925a7ce
5 changed files with 136 additions and 17 deletions
|
@ -11,15 +11,26 @@
|
||||||
let _6: usize;
|
let _6: usize;
|
||||||
let mut _7: usize;
|
let mut _7: usize;
|
||||||
let mut _8: bool;
|
let mut _8: bool;
|
||||||
let mut _9: &[u32; 3];
|
let mut _10: &[u32];
|
||||||
|
let _11: usize;
|
||||||
|
let mut _12: usize;
|
||||||
|
let mut _13: bool;
|
||||||
|
let mut _14: &[u32; 3];
|
||||||
|
scope 1 {
|
||||||
|
debug local => _1;
|
||||||
|
let _9: u32;
|
||||||
|
scope 2 {
|
||||||
|
debug constant => _9;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bb0: {
|
bb0: {
|
||||||
StorageLive(_1);
|
StorageLive(_1);
|
||||||
StorageLive(_2);
|
StorageLive(_2);
|
||||||
StorageLive(_3);
|
StorageLive(_3);
|
||||||
StorageLive(_4);
|
StorageLive(_4);
|
||||||
_9 = const _;
|
_14 = const _;
|
||||||
_4 = _9;
|
_4 = _14;
|
||||||
_3 = _4;
|
_3 = _4;
|
||||||
_2 = move _3 as &[u32] (PointerCoercion(Unsize));
|
_2 = move _3 as &[u32] (PointerCoercion(Unsize));
|
||||||
StorageDead(_3);
|
StorageDead(_3);
|
||||||
|
@ -39,8 +50,26 @@
|
||||||
StorageDead(_6);
|
StorageDead(_6);
|
||||||
StorageDead(_4);
|
StorageDead(_4);
|
||||||
StorageDead(_2);
|
StorageDead(_2);
|
||||||
StorageDead(_1);
|
StorageLive(_9);
|
||||||
|
StorageLive(_10);
|
||||||
|
_10 = const _;
|
||||||
|
StorageLive(_11);
|
||||||
|
_11 = const 1_usize;
|
||||||
|
_12 = Len((*_10));
|
||||||
|
- _13 = Lt(_11, _12);
|
||||||
|
- assert(move _13, "index out of bounds: the length is {} but the index is {}", move _12, _11) -> [success: bb2, unwind unreachable];
|
||||||
|
+ _13 = Lt(const 1_usize, _12);
|
||||||
|
+ assert(move _13, "index out of bounds: the length is {} but the index is {}", move _12, const 1_usize) -> [success: bb2, unwind unreachable];
|
||||||
|
}
|
||||||
|
|
||||||
|
bb2: {
|
||||||
|
- _9 = (*_10)[_11];
|
||||||
|
+ _9 = (*_10)[1 of 2];
|
||||||
|
StorageDead(_11);
|
||||||
|
StorageDead(_10);
|
||||||
_0 = const ();
|
_0 = const ();
|
||||||
|
StorageDead(_9);
|
||||||
|
StorageDead(_1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,15 +11,26 @@
|
||||||
let _6: usize;
|
let _6: usize;
|
||||||
let mut _7: usize;
|
let mut _7: usize;
|
||||||
let mut _8: bool;
|
let mut _8: bool;
|
||||||
let mut _9: &[u32; 3];
|
let mut _10: &[u32];
|
||||||
|
let _11: usize;
|
||||||
|
let mut _12: usize;
|
||||||
|
let mut _13: bool;
|
||||||
|
let mut _14: &[u32; 3];
|
||||||
|
scope 1 {
|
||||||
|
debug local => _1;
|
||||||
|
let _9: u32;
|
||||||
|
scope 2 {
|
||||||
|
debug constant => _9;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bb0: {
|
bb0: {
|
||||||
StorageLive(_1);
|
StorageLive(_1);
|
||||||
StorageLive(_2);
|
StorageLive(_2);
|
||||||
StorageLive(_3);
|
StorageLive(_3);
|
||||||
StorageLive(_4);
|
StorageLive(_4);
|
||||||
_9 = const _;
|
_14 = const _;
|
||||||
_4 = _9;
|
_4 = _14;
|
||||||
_3 = _4;
|
_3 = _4;
|
||||||
_2 = move _3 as &[u32] (PointerCoercion(Unsize));
|
_2 = move _3 as &[u32] (PointerCoercion(Unsize));
|
||||||
StorageDead(_3);
|
StorageDead(_3);
|
||||||
|
@ -39,8 +50,26 @@
|
||||||
StorageDead(_6);
|
StorageDead(_6);
|
||||||
StorageDead(_4);
|
StorageDead(_4);
|
||||||
StorageDead(_2);
|
StorageDead(_2);
|
||||||
StorageDead(_1);
|
StorageLive(_9);
|
||||||
|
StorageLive(_10);
|
||||||
|
_10 = const _;
|
||||||
|
StorageLive(_11);
|
||||||
|
_11 = const 1_usize;
|
||||||
|
_12 = Len((*_10));
|
||||||
|
- _13 = Lt(_11, _12);
|
||||||
|
- assert(move _13, "index out of bounds: the length is {} but the index is {}", move _12, _11) -> [success: bb2, unwind continue];
|
||||||
|
+ _13 = Lt(const 1_usize, _12);
|
||||||
|
+ assert(move _13, "index out of bounds: the length is {} but the index is {}", move _12, const 1_usize) -> [success: bb2, unwind continue];
|
||||||
|
}
|
||||||
|
|
||||||
|
bb2: {
|
||||||
|
- _9 = (*_10)[_11];
|
||||||
|
+ _9 = (*_10)[1 of 2];
|
||||||
|
StorageDead(_11);
|
||||||
|
StorageDead(_10);
|
||||||
_0 = const ();
|
_0 = const ();
|
||||||
|
StorageDead(_9);
|
||||||
|
StorageDead(_1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,15 +11,26 @@
|
||||||
let _6: usize;
|
let _6: usize;
|
||||||
let mut _7: usize;
|
let mut _7: usize;
|
||||||
let mut _8: bool;
|
let mut _8: bool;
|
||||||
let mut _9: &[u32; 3];
|
let mut _10: &[u32];
|
||||||
|
let _11: usize;
|
||||||
|
let mut _12: usize;
|
||||||
|
let mut _13: bool;
|
||||||
|
let mut _14: &[u32; 3];
|
||||||
|
scope 1 {
|
||||||
|
debug local => _1;
|
||||||
|
let _9: u32;
|
||||||
|
scope 2 {
|
||||||
|
debug constant => _9;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bb0: {
|
bb0: {
|
||||||
StorageLive(_1);
|
StorageLive(_1);
|
||||||
StorageLive(_2);
|
StorageLive(_2);
|
||||||
StorageLive(_3);
|
StorageLive(_3);
|
||||||
StorageLive(_4);
|
StorageLive(_4);
|
||||||
_9 = const _;
|
_14 = const _;
|
||||||
_4 = _9;
|
_4 = _14;
|
||||||
_3 = _4;
|
_3 = _4;
|
||||||
_2 = move _3 as &[u32] (PointerCoercion(Unsize));
|
_2 = move _3 as &[u32] (PointerCoercion(Unsize));
|
||||||
StorageDead(_3);
|
StorageDead(_3);
|
||||||
|
@ -39,8 +50,26 @@
|
||||||
StorageDead(_6);
|
StorageDead(_6);
|
||||||
StorageDead(_4);
|
StorageDead(_4);
|
||||||
StorageDead(_2);
|
StorageDead(_2);
|
||||||
StorageDead(_1);
|
StorageLive(_9);
|
||||||
|
StorageLive(_10);
|
||||||
|
_10 = const _;
|
||||||
|
StorageLive(_11);
|
||||||
|
_11 = const 1_usize;
|
||||||
|
_12 = Len((*_10));
|
||||||
|
- _13 = Lt(_11, _12);
|
||||||
|
- assert(move _13, "index out of bounds: the length is {} but the index is {}", move _12, _11) -> [success: bb2, unwind unreachable];
|
||||||
|
+ _13 = Lt(const 1_usize, _12);
|
||||||
|
+ assert(move _13, "index out of bounds: the length is {} but the index is {}", move _12, const 1_usize) -> [success: bb2, unwind unreachable];
|
||||||
|
}
|
||||||
|
|
||||||
|
bb2: {
|
||||||
|
- _9 = (*_10)[_11];
|
||||||
|
+ _9 = (*_10)[1 of 2];
|
||||||
|
StorageDead(_11);
|
||||||
|
StorageDead(_10);
|
||||||
_0 = const ();
|
_0 = const ();
|
||||||
|
StorageDead(_9);
|
||||||
|
StorageDead(_1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,15 +11,26 @@
|
||||||
let _6: usize;
|
let _6: usize;
|
||||||
let mut _7: usize;
|
let mut _7: usize;
|
||||||
let mut _8: bool;
|
let mut _8: bool;
|
||||||
let mut _9: &[u32; 3];
|
let mut _10: &[u32];
|
||||||
|
let _11: usize;
|
||||||
|
let mut _12: usize;
|
||||||
|
let mut _13: bool;
|
||||||
|
let mut _14: &[u32; 3];
|
||||||
|
scope 1 {
|
||||||
|
debug local => _1;
|
||||||
|
let _9: u32;
|
||||||
|
scope 2 {
|
||||||
|
debug constant => _9;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bb0: {
|
bb0: {
|
||||||
StorageLive(_1);
|
StorageLive(_1);
|
||||||
StorageLive(_2);
|
StorageLive(_2);
|
||||||
StorageLive(_3);
|
StorageLive(_3);
|
||||||
StorageLive(_4);
|
StorageLive(_4);
|
||||||
_9 = const _;
|
_14 = const _;
|
||||||
_4 = _9;
|
_4 = _14;
|
||||||
_3 = _4;
|
_3 = _4;
|
||||||
_2 = move _3 as &[u32] (PointerCoercion(Unsize));
|
_2 = move _3 as &[u32] (PointerCoercion(Unsize));
|
||||||
StorageDead(_3);
|
StorageDead(_3);
|
||||||
|
@ -39,8 +50,26 @@
|
||||||
StorageDead(_6);
|
StorageDead(_6);
|
||||||
StorageDead(_4);
|
StorageDead(_4);
|
||||||
StorageDead(_2);
|
StorageDead(_2);
|
||||||
StorageDead(_1);
|
StorageLive(_9);
|
||||||
|
StorageLive(_10);
|
||||||
|
_10 = const _;
|
||||||
|
StorageLive(_11);
|
||||||
|
_11 = const 1_usize;
|
||||||
|
_12 = Len((*_10));
|
||||||
|
- _13 = Lt(_11, _12);
|
||||||
|
- assert(move _13, "index out of bounds: the length is {} but the index is {}", move _12, _11) -> [success: bb2, unwind continue];
|
||||||
|
+ _13 = Lt(const 1_usize, _12);
|
||||||
|
+ assert(move _13, "index out of bounds: the length is {} but the index is {}", move _12, const 1_usize) -> [success: bb2, unwind continue];
|
||||||
|
}
|
||||||
|
|
||||||
|
bb2: {
|
||||||
|
- _9 = (*_10)[_11];
|
||||||
|
+ _9 = (*_10)[1 of 2];
|
||||||
|
StorageDead(_11);
|
||||||
|
StorageDead(_10);
|
||||||
_0 = const ();
|
_0 = const ();
|
||||||
|
StorageDead(_9);
|
||||||
|
StorageDead(_1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,5 +5,8 @@
|
||||||
|
|
||||||
// EMIT_MIR slice_len.main.DataflowConstProp.diff
|
// EMIT_MIR slice_len.main.DataflowConstProp.diff
|
||||||
fn main() {
|
fn main() {
|
||||||
(&[1u32, 2, 3] as &[u32])[1];
|
let local = (&[1u32, 2, 3] as &[u32])[1];
|
||||||
|
|
||||||
|
const SLICE: &[u32] = &[1, 2, 3];
|
||||||
|
let constant = SLICE[1];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue