Skip to content

Commit d510ba3

Browse files
add mir-opt test
1 parent 48c1c1d commit d510ba3

File tree

2 files changed

+84
-0
lines changed

2 files changed

+84
-0
lines changed

Diff for: src/test/mir-opt/issue-101867.rs

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#![feature(let_else)]
2+
3+
// EMIT_MIR issue_101867.main.mir_map.0.mir
4+
fn main() {
5+
let x: Option<u8> = Some(1);
6+
let Some(y) = x else {
7+
panic!();
8+
};
9+
}

Diff for: src/test/mir-opt/issue_101867.main.mir_map.0.mir

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
// MIR for `main` 0 mir_map
2+
3+
| User Type Annotations
4+
| 0: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(std::option::Option<u8>) }, span: $DIR/issue-101867.rs:5:12: 5:22, inferred_ty: std::option::Option<u8>
5+
| 1: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(std::option::Option<u8>) }, span: $DIR/issue-101867.rs:5:12: 5:22, inferred_ty: std::option::Option<u8>
6+
|
7+
fn main() -> () {
8+
let mut _0: (); // return place in scope 0 at $DIR/issue-101867.rs:+0:11: +0:11
9+
let _1: std::option::Option<u8> as UserTypeProjection { base: UserType(0), projs: [] }; // in scope 0 at $DIR/issue-101867.rs:+1:9: +1:10
10+
let mut _2: !; // in scope 0 at $DIR/issue-101867.rs:+2:26: +4:6
11+
let _3: (); // in scope 0 at $SRC_DIR/std/src/panic.rs:LL:COL
12+
let mut _4: !; // in scope 0 at $SRC_DIR/std/src/panic.rs:LL:COL
13+
let mut _6: isize; // in scope 0 at $DIR/issue-101867.rs:+2:9: +2:16
14+
scope 1 {
15+
debug x => _1; // in scope 1 at $DIR/issue-101867.rs:+1:9: +1:10
16+
let _5: u8; // in scope 1 at $DIR/issue-101867.rs:+2:14: +2:15
17+
scope 2 {
18+
debug y => _5; // in scope 2 at $DIR/issue-101867.rs:+2:14: +2:15
19+
}
20+
}
21+
22+
bb0: {
23+
StorageLive(_1); // scope 0 at $DIR/issue-101867.rs:+1:9: +1:10
24+
_1 = Option::<u8>::Some(const 1_u8); // scope 0 at $DIR/issue-101867.rs:+1:25: +1:32
25+
FakeRead(ForLet(None), _1); // scope 0 at $DIR/issue-101867.rs:+1:9: +1:10
26+
AscribeUserType(_1, o, UserTypeProjection { base: UserType(1), projs: [] }); // scope 0 at $DIR/issue-101867.rs:+1:12: +1:22
27+
StorageLive(_5); // scope 1 at $DIR/issue-101867.rs:+2:14: +2:15
28+
FakeRead(ForMatchedPlace(None), _1); // scope 1 at $DIR/issue-101867.rs:+2:19: +2:20
29+
_6 = discriminant(_1); // scope 1 at $DIR/issue-101867.rs:+2:19: +2:20
30+
switchInt(move _6) -> [1_isize: bb4, otherwise: bb3]; // scope 1 at $DIR/issue-101867.rs:+2:9: +2:16
31+
}
32+
33+
bb1: {
34+
StorageLive(_3); // scope 1 at $SRC_DIR/std/src/panic.rs:LL:COL
35+
StorageLive(_4); // scope 1 at $SRC_DIR/std/src/panic.rs:LL:COL
36+
_4 = begin_panic::<&str>(const "explicit panic") -> bb7; // scope 1 at $SRC_DIR/std/src/panic.rs:LL:COL
37+
// mir::Constant
38+
// + span: $SRC_DIR/std/src/panic.rs:LL:COL
39+
// + literal: Const { ty: fn(&str) -> ! {begin_panic::<&str>}, val: Value(<ZST>) }
40+
// mir::Constant
41+
// + span: $SRC_DIR/std/src/panic.rs:LL:COL
42+
// + literal: Const { ty: &str, val: Value(Slice(..)) }
43+
}
44+
45+
bb2: {
46+
StorageDead(_4); // scope 1 at $SRC_DIR/std/src/panic.rs:LL:COL
47+
StorageDead(_3); // scope 1 at $DIR/issue-101867.rs:+3:16: +3:17
48+
unreachable; // scope 1 at $DIR/issue-101867.rs:+2:26: +4:6
49+
}
50+
51+
bb3: {
52+
goto -> bb6; // scope 1 at $DIR/issue-101867.rs:+2:19: +2:20
53+
}
54+
55+
bb4: {
56+
falseEdge -> [real: bb5, imaginary: bb3]; // scope 1 at $DIR/issue-101867.rs:+2:9: +2:16
57+
}
58+
59+
bb5: {
60+
_5 = ((_1 as Some).0: u8); // scope 1 at $DIR/issue-101867.rs:+2:14: +2:15
61+
_0 = const (); // scope 0 at $DIR/issue-101867.rs:+0:11: +5:2
62+
StorageDead(_5); // scope 1 at $DIR/issue-101867.rs:+5:1: +5:2
63+
StorageDead(_1); // scope 0 at $DIR/issue-101867.rs:+5:1: +5:2
64+
return; // scope 0 at $DIR/issue-101867.rs:+5:2: +5:2
65+
}
66+
67+
bb6: {
68+
StorageDead(_5); // scope 1 at $DIR/issue-101867.rs:+5:1: +5:2
69+
goto -> bb1; // scope 0 at $DIR/issue-101867.rs:+0:11: +5:2
70+
}
71+
72+
bb7 (cleanup): {
73+
resume; // scope 0 at $DIR/issue-101867.rs:+0:1: +5:2
74+
}
75+
}

0 commit comments

Comments
 (0)