]> git.lizzy.rs Git - rust.git/blob - src/test/mir-opt/simplify_try.rs
Rollup merge of #68832 - GuillaumeGomez:clean-up-3-err-codes, r=estebank
[rust.git] / src / test / mir-opt / simplify_try.rs
1 fn try_identity(x: Result<u32, i32>) -> Result<u32, i32> {
2     let y = x?;
3     Ok(y)
4 }
5
6 fn main() {
7     let _ = try_identity(Ok(0));
8 }
9
10 // END RUST SOURCE
11 // START rustc.try_identity.SimplifyArmIdentity.before.mir
12 // fn try_identity(_1: std::result::Result<u32, i32>) -> std::result::Result<u32, i32> {
13 //     debug x => _1;
14 //     let mut _0: std::result::Result<u32, i32>;
15 //     let _2: u32;
16 //     let mut _3: std::result::Result<u32, i32>;
17 //     let mut _4: std::result::Result<u32, i32>;
18 //     let mut _5: isize;
19 //     let _6: i32;
20 //     let mut _7: !;
21 //     let mut _8: i32;
22 //     let mut _9: i32;
23 //     let _10: u32;
24 //     let mut _11: u32;
25 //     scope 1 {
26 //         debug y => _10;
27 //     }
28 //     scope 2 {
29 //         debug err => _6;
30 //         scope 3 {
31 //             scope 7 {
32 //                 debug t => _6;
33 //             }
34 //             scope 8 {
35 //                 debug v => _6;
36 //                 let mut _12: i32;
37 //             }
38 //         }
39 //     }
40 //     scope 4 {
41 //         debug val => _10;
42 //         scope 5 {
43 //         }
44 //     }
45 //     scope 6 {
46 //         debug self => _1;
47 //     }
48 //     bb0: {
49 //         _5 = discriminant(_1);
50 //         switchInt(move _5) -> [0isize: bb1, otherwise: bb2];
51 //     }
52 //     bb1: {
53 //         _10 = ((_1 as Ok).0: u32);
54 //         ((_0 as Ok).0: u32) = move _10;
55 //         discriminant(_0) = 0;
56 //         goto -> bb3;
57 //     }
58 //     bb2: {
59 //         _6 = ((_1 as Err).0: i32);
60 //         ((_0 as Err).0: i32) = move _6;
61 //         discriminant(_0) = 1;
62 //         goto -> bb3;
63 //     }
64 //     bb3: {
65 //         return;
66 //     }
67 // }
68 // END rustc.try_identity.SimplifyArmIdentity.before.mir
69
70 // START rustc.try_identity.SimplifyArmIdentity.after.mir
71 // fn try_identity(_1: std::result::Result<u32, i32>) -> std::result::Result<u32, i32> {
72 //     debug x => _1;
73 //     let mut _0: std::result::Result<u32, i32>;
74 //     let _2: u32;
75 //     let mut _3: std::result::Result<u32, i32>;
76 //     let mut _4: std::result::Result<u32, i32>;
77 //     let mut _5: isize;
78 //     let _6: i32;
79 //     let mut _7: !;
80 //     let mut _8: i32;
81 //     let mut _9: i32;
82 //     let _10: u32;
83 //     let mut _11: u32;
84 //     scope 1 {
85 //         debug y => _10;
86 //     }
87 //     scope 2 {
88 //         debug err => _6;
89 //         scope 3 {
90 //             scope 7 {
91 //                 debug t => _6;
92 //             }
93 //             scope 8 {
94 //                 debug v => _6;
95 //                 let mut _12: i32;
96 //             }
97 //         }
98 //     }
99 //     scope 4 {
100 //         debug val => _10;
101 //         scope 5 {
102 //         }
103 //     }
104 //     scope 6 {
105 //         debug self => _1;
106 //     }
107 //     bb0: {
108 //         _5 = discriminant(_1);
109 //         switchInt(move _5) -> [0isize: bb1, otherwise: bb2];
110 //     }
111 //     bb1: {
112 //         _0 = move _1;
113 //         nop;
114 //         nop;
115 //         goto -> bb3;
116 //     }
117 //     bb2: {
118 //         _0 = move _1;
119 //         nop;
120 //         nop;
121 //         goto -> bb3;
122 //     }
123 //     bb3: {
124 //         return;
125 //     }
126 // }
127 // END rustc.try_identity.SimplifyArmIdentity.after.mir
128
129 // START rustc.try_identity.SimplifyBranchSame.after.mir
130 // fn try_identity(_1: std::result::Result<u32, i32>) -> std::result::Result<u32, i32> {
131 //     debug x => _1;
132 //     let mut _0: std::result::Result<u32, i32>;
133 //     let _2: u32;
134 //     let mut _3: std::result::Result<u32, i32>;
135 //     let mut _4: std::result::Result<u32, i32>;
136 //     let mut _5: isize;
137 //     let _6: i32;
138 //     let mut _7: !;
139 //     let mut _8: i32;
140 //     let mut _9: i32;
141 //     let _10: u32;
142 //     let mut _11: u32;
143 //     scope 1 {
144 //         debug y => _10;
145 //     }
146 //     scope 2 {
147 //         debug err => _6;
148 //         scope 3 {
149 //             scope 7 {
150 //                 debug t => _6;
151 //             }
152 //             scope 8 {
153 //                 debug v => _6;
154 //                 let mut _12: i32;
155 //             }
156 //         }
157 //     }
158 //     scope 4 {
159 //         debug val => _10;
160 //         scope 5 {
161 //         }
162 //     }
163 //     scope 6 {
164 //         debug self => _1;
165 //     }
166 //     bb0: {
167 //         _5 = discriminant(_1);
168 //         goto -> bb1;
169 //     }
170 //     bb1: {
171 //         _0 = move _1;
172 //         nop;
173 //         nop;
174 //         goto -> bb2;
175 //     }
176 //     bb2: {
177 //         return;
178 //     }
179 // }
180 // END rustc.try_identity.SimplifyBranchSame.after.mir
181
182 // START rustc.try_identity.SimplifyLocals.after.mir
183 // fn try_identity(_1: std::result::Result<u32, i32>) -> std::result::Result<u32, i32> {
184 //     debug x => _1;
185 //     let mut _0: std::result::Result<u32, i32>;
186 //     let mut _2: isize;
187 //     let _3: i32;
188 //     let _4: u32;
189 //     scope 1 {
190 //         debug y => _4;
191 //     }
192 //     scope 2 {
193 //         debug err => _3;
194 //         scope 3 {
195 //             scope 7 {
196 //                 debug t => _3;
197 //             }
198 //             scope 8 {
199 //                 debug v => _3;
200 //             }
201 //         }
202 //     }
203 //     scope 4 {
204 //         debug val => _4;
205 //         scope 5 {
206 //         }
207 //     }
208 //     scope 6 {
209 //         debug self => _1;
210 //     }
211 //     bb0: {
212 //         _2 = discriminant(_1);
213 //         _0 = move _1;
214 //         return;
215 //     }
216 // }
217 // END rustc.try_identity.SimplifyLocals.after.mir