rust/tests/pretty/hir-if-else.rs
Nicholas Nethercote 3d488f8e0c Add pretty printing tests for if/else.
The AST pretty printing is a bit wonky. The HIR pretty printing is
extremely wonky.
2025-04-25 14:33:14 +10:00

60 lines
897 B
Rust

//@ pretty-compare-only
//@ pretty-mode:hir
//@ pp-exact:hir-if-else.pp
fn f(x: u32, y: u32) {
let mut a = 0;
if x > y {
a = 1;
} else {
a = 2;
}
if x < 1 {
a = 1;
} else if x < 2 {
a = 2;
} else if x < 3 {
a = 3;
} else if x < 4 {
a = 4;
} else {
a = 5;
}
if x < y {
a += 1;
a += 1;
a += 1;
a += 1;
a += 1;
a += 1;
} else {
a += 1;
a += 1;
a += 1;
a += 1;
a += 1;
a += 1;
}
if x < 1 {
if x < 2 {
if x < 3 {
a += 1;
} else if x < 4 {
a += 1;
if x < 5 {
a += 1;
}
}
} else if x < 6 {
a += 1;
}
}
}
fn main() {
f(3, 4);
}