]> git.proxmox.com Git - rustc.git/blame - src/test/ui/reachable/expr_if.rs
New upstream version 1.56.0~beta.4+dfsg1
[rustc.git] / src / test / ui / reachable / expr_if.rs
CommitLineData
cc61c64b
XL
1#![allow(unused_variables)]
2#![allow(unused_assignments)]
32a655c1 3#![allow(dead_code)]
cc61c64b 4#![deny(unreachable_code)]
cc61c64b
XL
5
6fn foo() {
94222f64 7 if {return} { //~ ERROR unreachable block in `if`
cc61c64b
XL
8 println!("Hello, world!");
9 }
10}
11
12fn bar() {
13 if {true} {
14 return;
15 }
16 println!("I am not dead.");
17}
18
19fn baz() {
20 if {true} {
21 return;
22 } else {
23 return;
24 }
25 // As the next action to be taken after the if arms, we should
26 // report the `println!` as unreachable:
27 println!("But I am.");
8faf50e0 28 //~^ ERROR unreachable statement
cc61c64b 29}
a7813a04 30
32a655c1 31fn main() { }