]> git.lizzy.rs Git - rust.git/blob - tests/ui/reachable/expr_if.rs
Rollup merge of #106701 - ibraheemdev:sync-sender-spin, r=Amanieu
[rust.git] / tests / ui / reachable / expr_if.rs
1 #![allow(unused_variables)]
2 #![allow(unused_assignments)]
3 #![allow(dead_code)]
4 #![deny(unreachable_code)]
5
6 fn foo() {
7     if {return} { //~ ERROR unreachable block in `if`
8         println!("Hello, world!");
9     }
10 }
11
12 fn bar() {
13     if {true} {
14         return;
15     }
16     println!("I am not dead.");
17 }
18
19 fn 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.");
28     //~^ ERROR unreachable statement
29 }
30
31 fn main() { }