]> git.proxmox.com Git - rustc.git/blame - src/test/mir-opt/separate_const_switch.rs
Update unsuspicious file list
[rustc.git] / src / test / mir-opt / separate_const_switch.rs
CommitLineData
94222f64
XL
1#![feature(control_flow_enum)]
2#![feature(try_trait_v2)]
3
4use std::ops::ControlFlow;
5
6// EMIT_MIR separate_const_switch.too_complex.SeparateConstSwitch.diff
94222f64
XL
7fn too_complex(x: Result<i32, usize>) -> Option<i32> {
8 // The pass should break the outer match into
9 // two blocks that only have one parent each.
10 // Parents are one of the two branches of the first
11 // match, so a later pass can propagate constants.
12 match {
13 match x {
14 Ok(v) => ControlFlow::Continue(v),
15 Err(r) => ControlFlow::Break(r),
16 }
17 } {
18 ControlFlow::Continue(v) => Some(v),
19 ControlFlow::Break(r) => None,
20 }
21}
22
23// EMIT_MIR separate_const_switch.identity.SeparateConstSwitch.diff
94222f64
XL
24fn identity(x: Result<i32, i32>) -> Result<i32, i32> {
25 Ok(x?)
26}
27
28fn main() {
29 too_complex(Ok(0));
30 identity(Ok(0));
31}