summary refs log tree commit diff
path: root/src/test/mir-opt/const_prop/slice_len.rs
blob: 5babeb195a826f0fbf7e2b5ebfb36a4a58d77d60 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
fn main() {
    (&[1u32, 2, 3] as &[u32])[1];
}

// END RUST SOURCE
// START rustc.main.ConstProp.before.mir
//  bb0: {
//      ...
//      _4 = &(promoted[0]: [u32; 3]);
//      _3 = _4;
//      _2 = move _3 as &[u32] (Pointer(Unsize));
//      ...
//      _6 = const 1usize;
//      _7 = Len((*_2));
//      _8 = Lt(_6, _7);
//      assert(move _8, "index out of bounds: the len is move _7 but the index is _6") -> bb1;
//  }
//  bb1: {
//      _1 = (*_2)[_6];
//      ...
//      return;
//  }
// END rustc.main.ConstProp.before.mir
// START rustc.main.ConstProp.after.mir
//  bb0: {
//      ...
//      _4 = const Scalar(AllocId(0).0x0) : &[u32; 3];
//      _3 = const Scalar(AllocId(0).0x0) : &[u32; 3];
//      _2 = move _3 as &[u32] (Pointer(Unsize));
//      ...
//      _6 = const 1usize;
//      _7 = const 3usize;
//      _8 = const true;
//      assert(const true, "index out of bounds: the len is move _7 but the index is _6") -> bb1;
//  }
//  bb1: {
//      _1 = (*_2)[_6];
//      ...
//      return;
//  }
// END rustc.main.ConstProp.after.mir