Skip to content

Commit 26a7c9d

Browse files
committed
Add a mir-opt test that demonstrates user type annotations
1 parent bca5f37 commit 26a7c9d

9 files changed

+467
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
// MIR for `let_else` after built
2+
3+
| User Type Annotations
4+
| 0: user_ty: Canonical { value: Ty((u32, u64, &'static char)), max_universe: U0, variables: [] }, span: $DIR/user_type_annotations.rs:35:20: 35:45, inferred_ty: (u32, u64, &char)
5+
| 1: user_ty: Canonical { value: Ty((u32, u64, &'static char)), max_universe: U0, variables: [] }, span: $DIR/user_type_annotations.rs:35:20: 35:45, inferred_ty: (u32, u64, &char)
6+
| 2: user_ty: Canonical { value: Ty((u32, u64, &'static char)), max_universe: U0, variables: [] }, span: $DIR/user_type_annotations.rs:35:20: 35:45, inferred_ty: (u32, u64, &char)
7+
|
8+
fn let_else() -> () {
9+
let mut _0: ();
10+
let mut _1: !;
11+
let _2: u32 as UserTypeProjection { base: UserType(0), projs: [Field(0, ())] };
12+
let _3: u64 as UserTypeProjection { base: UserType(0), projs: [Field(1, ())] };
13+
let _4: &char as UserTypeProjection { base: UserType(0), projs: [Field(2, ())] };
14+
let mut _5: (u32, u64, &char);
15+
let mut _6: &char;
16+
let _7: &char;
17+
let _8: char;
18+
scope 1 {
19+
debug x => _2;
20+
debug y => _3;
21+
debug z => _4;
22+
}
23+
24+
bb0: {
25+
StorageLive(_2);
26+
StorageLive(_3);
27+
StorageLive(_4);
28+
StorageLive(_5);
29+
StorageLive(_6);
30+
StorageLive(_7);
31+
StorageLive(_8);
32+
_8 = const 'u';
33+
_7 = &_8;
34+
_6 = &(*_7);
35+
_5 = (const 7_u32, const 12_u64, move _6);
36+
StorageDead(_6);
37+
PlaceMention(_5);
38+
falseEdge -> [real: bb4, imaginary: bb3];
39+
}
40+
41+
bb1: {
42+
_1 = core::panicking::panic(const "internal error: entered unreachable code") -> bb6;
43+
}
44+
45+
bb2: {
46+
unreachable;
47+
}
48+
49+
bb3: {
50+
goto -> bb5;
51+
}
52+
53+
bb4: {
54+
AscribeUserType(_5, +, UserTypeProjection { base: UserType(2), projs: [] });
55+
_2 = copy (_5.0: u32);
56+
_3 = copy (_5.1: u64);
57+
_4 = copy (_5.2: &char);
58+
StorageDead(_7);
59+
StorageDead(_5);
60+
_0 = const ();
61+
StorageDead(_8);
62+
StorageDead(_4);
63+
StorageDead(_3);
64+
StorageDead(_2);
65+
return;
66+
}
67+
68+
bb5: {
69+
StorageDead(_7);
70+
StorageDead(_5);
71+
StorageDead(_8);
72+
StorageDead(_4);
73+
StorageDead(_3);
74+
StorageDead(_2);
75+
goto -> bb1;
76+
}
77+
78+
bb6 (cleanup): {
79+
resume;
80+
}
81+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
// MIR for `let_else_bindless` after built
2+
3+
| User Type Annotations
4+
| 0: user_ty: Canonical { value: Ty((u32, u64, &'static char)), max_universe: U0, variables: [] }, span: $DIR/user_type_annotations.rs:40:20: 40:45, inferred_ty: (u32, u64, &char)
5+
| 1: user_ty: Canonical { value: Ty((u32, u64, &'static char)), max_universe: U0, variables: [] }, span: $DIR/user_type_annotations.rs:40:20: 40:45, inferred_ty: (u32, u64, &char)
6+
| 2: user_ty: Canonical { value: Ty((u32, u64, &'static char)), max_universe: U0, variables: [] }, span: $DIR/user_type_annotations.rs:40:20: 40:45, inferred_ty: (u32, u64, &char)
7+
|
8+
fn let_else_bindless() -> () {
9+
let mut _0: ();
10+
let mut _1: !;
11+
let mut _2: (u32, u64, &char);
12+
let mut _3: &char;
13+
let _4: &char;
14+
let _5: char;
15+
scope 1 {
16+
}
17+
18+
bb0: {
19+
StorageLive(_2);
20+
StorageLive(_3);
21+
StorageLive(_4);
22+
StorageLive(_5);
23+
_5 = const 'u';
24+
_4 = &_5;
25+
_3 = &(*_4);
26+
_2 = (const 7_u32, const 12_u64, move _3);
27+
StorageDead(_3);
28+
PlaceMention(_2);
29+
falseEdge -> [real: bb4, imaginary: bb3];
30+
}
31+
32+
bb1: {
33+
_1 = core::panicking::panic(const "internal error: entered unreachable code") -> bb6;
34+
}
35+
36+
bb2: {
37+
unreachable;
38+
}
39+
40+
bb3: {
41+
goto -> bb5;
42+
}
43+
44+
bb4: {
45+
AscribeUserType(_2, +, UserTypeProjection { base: UserType(2), projs: [] });
46+
StorageDead(_4);
47+
StorageDead(_2);
48+
_0 = const ();
49+
StorageDead(_5);
50+
return;
51+
}
52+
53+
bb5: {
54+
StorageDead(_4);
55+
StorageDead(_2);
56+
StorageDead(_5);
57+
goto -> bb1;
58+
}
59+
60+
bb6 (cleanup): {
61+
resume;
62+
}
63+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// MIR for `let_init` after built
2+
3+
| User Type Annotations
4+
| 0: user_ty: Canonical { value: Ty((u32, u64, &'static char)), max_universe: U0, variables: [] }, span: $DIR/user_type_annotations.rs:25:20: 25:45, inferred_ty: (u32, u64, &char)
5+
| 1: user_ty: Canonical { value: Ty((u32, u64, &'static char)), max_universe: U0, variables: [] }, span: $DIR/user_type_annotations.rs:25:20: 25:45, inferred_ty: (u32, u64, &char)
6+
|
7+
fn let_init() -> () {
8+
let mut _0: ();
9+
let _1: u32 as UserTypeProjection { base: UserType(0), projs: [Field(0, ())] };
10+
let _2: u64 as UserTypeProjection { base: UserType(0), projs: [Field(1, ())] };
11+
let _3: &char as UserTypeProjection { base: UserType(0), projs: [Field(2, ())] };
12+
let mut _4: (u32, u64, &char);
13+
let mut _5: &char;
14+
let _6: &char;
15+
let _7: char;
16+
scope 1 {
17+
debug x => _1;
18+
debug y => _2;
19+
debug z => _3;
20+
}
21+
22+
bb0: {
23+
StorageLive(_4);
24+
StorageLive(_5);
25+
StorageLive(_6);
26+
StorageLive(_7);
27+
_7 = const 'u';
28+
_6 = &_7;
29+
_5 = &(*_6);
30+
_4 = (const 7_u32, const 12_u64, move _5);
31+
StorageDead(_5);
32+
PlaceMention(_4);
33+
AscribeUserType(_4, +, UserTypeProjection { base: UserType(1), projs: [] });
34+
StorageLive(_1);
35+
_1 = copy (_4.0: u32);
36+
StorageLive(_2);
37+
_2 = copy (_4.1: u64);
38+
StorageLive(_3);
39+
_3 = copy (_4.2: &char);
40+
StorageDead(_6);
41+
StorageDead(_4);
42+
_0 = const ();
43+
StorageDead(_3);
44+
StorageDead(_2);
45+
StorageDead(_1);
46+
StorageDead(_7);
47+
return;
48+
}
49+
50+
bb1: {
51+
FakeRead(ForMatchedPlace(None), _4);
52+
unreachable;
53+
}
54+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// MIR for `let_init_bindless` after built
2+
3+
| User Type Annotations
4+
| 0: user_ty: Canonical { value: Ty((u32, u64, &'static char)), max_universe: U0, variables: [] }, span: $DIR/user_type_annotations.rs:30:20: 30:45, inferred_ty: (u32, u64, &char)
5+
| 1: user_ty: Canonical { value: Ty((u32, u64, &'static char)), max_universe: U0, variables: [] }, span: $DIR/user_type_annotations.rs:30:20: 30:45, inferred_ty: (u32, u64, &char)
6+
|
7+
fn let_init_bindless() -> () {
8+
let mut _0: ();
9+
let mut _1: (u32, u64, &char);
10+
let mut _2: &char;
11+
let _3: &char;
12+
let _4: char;
13+
scope 1 {
14+
}
15+
16+
bb0: {
17+
StorageLive(_1);
18+
StorageLive(_2);
19+
StorageLive(_3);
20+
StorageLive(_4);
21+
_4 = const 'u';
22+
_3 = &_4;
23+
_2 = &(*_3);
24+
_1 = (const 7_u32, const 12_u64, move _2);
25+
StorageDead(_2);
26+
PlaceMention(_1);
27+
AscribeUserType(_1, +, UserTypeProjection { base: UserType(1), projs: [] });
28+
StorageDead(_3);
29+
StorageDead(_1);
30+
_0 = const ();
31+
StorageDead(_4);
32+
return;
33+
}
34+
35+
bb1: {
36+
FakeRead(ForMatchedPlace(None), _1);
37+
unreachable;
38+
}
39+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// MIR for `let_uninit` after built
2+
3+
| User Type Annotations
4+
| 0: user_ty: Canonical { value: Ty((u32, u64, &'static char)), max_universe: U0, variables: [] }, span: $DIR/user_type_annotations.rs:15:20: 15:45, inferred_ty: (u32, u64, &char)
5+
| 1: user_ty: Canonical { value: Ty((u32, u64, &'static char)), max_universe: U0, variables: [] }, span: $DIR/user_type_annotations.rs:15:20: 15:45, inferred_ty: (u32, u64, &char)
6+
|
7+
fn let_uninit() -> () {
8+
let mut _0: ();
9+
let _1: u32 as UserTypeProjection { base: UserType(0), projs: [Field(0, ())] };
10+
let _2: u64 as UserTypeProjection { base: UserType(0), projs: [Field(1, ())] };
11+
let _3: &char as UserTypeProjection { base: UserType(0), projs: [Field(2, ())] };
12+
scope 1 {
13+
debug x => _1;
14+
debug y => _2;
15+
debug z => _3;
16+
}
17+
18+
bb0: {
19+
StorageLive(_1);
20+
StorageLive(_2);
21+
StorageLive(_3);
22+
_0 = const ();
23+
StorageDead(_3);
24+
StorageDead(_2);
25+
StorageDead(_1);
26+
return;
27+
}
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// MIR for `let_uninit_bindless` after built
2+
3+
| User Type Annotations
4+
| 0: user_ty: Canonical { value: Ty((u32, u64, &'static char)), max_universe: U0, variables: [] }, span: $DIR/user_type_annotations.rs:20:20: 20:45, inferred_ty: (u32, u64, &char)
5+
| 1: user_ty: Canonical { value: Ty((u32, u64, &'static char)), max_universe: U0, variables: [] }, span: $DIR/user_type_annotations.rs:20:20: 20:45, inferred_ty: (u32, u64, &char)
6+
|
7+
fn let_uninit_bindless() -> () {
8+
let mut _0: ();
9+
scope 1 {
10+
}
11+
12+
bb0: {
13+
_0 = const ();
14+
return;
15+
}
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// MIR for `match_assoc_const` after built
2+
3+
| User Type Annotations
4+
| 0: user_ty: Canonical { value: TypeOf(DefId(0:11 ~ user_type_annotations[ee8e]::MyTrait::FOO), UserArgs { args: [MyStruct, 'static], user_self_ty: None }), max_universe: U0, variables: [] }, span: $DIR/user_type_annotations.rs:54:9: 54:44, inferred_ty: u32
5+
| 1: user_ty: Canonical { value: TypeOf(DefId(0:11 ~ user_type_annotations[ee8e]::MyTrait::FOO), UserArgs { args: [MyStruct, 'static], user_self_ty: None }), max_universe: U0, variables: [] }, span: $DIR/user_type_annotations.rs:54:9: 54:44, inferred_ty: u32
6+
|
7+
fn match_assoc_const() -> () {
8+
let mut _0: ();
9+
let mut _1: u32;
10+
11+
bb0: {
12+
StorageLive(_1);
13+
_1 = const 8_u32;
14+
PlaceMention(_1);
15+
switchInt(copy _1) -> [99: bb2, otherwise: bb1];
16+
}
17+
18+
bb1: {
19+
_0 = const ();
20+
goto -> bb6;
21+
}
22+
23+
bb2: {
24+
falseEdge -> [real: bb5, imaginary: bb1];
25+
}
26+
27+
bb3: {
28+
goto -> bb1;
29+
}
30+
31+
bb4: {
32+
FakeRead(ForMatchedPlace(None), _1);
33+
unreachable;
34+
}
35+
36+
bb5: {
37+
AscribeUserType(_1, -, UserTypeProjection { base: UserType(1), projs: [] });
38+
_0 = const ();
39+
goto -> bb6;
40+
}
41+
42+
bb6: {
43+
StorageDead(_1);
44+
return;
45+
}
46+
}

0 commit comments

Comments
 (0)