]> git.lizzy.rs Git - rust.git/blob - tests/ui/diverging_sub_expression.rs
Auto merge of #4314 - chansuke:add-negation-to-is_empty, r=flip1995
[rust.git] / tests / ui / diverging_sub_expression.rs
1 #![feature(never_type)]
2 #![warn(clippy::diverging_sub_expression)]
3 #![allow(clippy::match_same_arms, clippy::logic_bug)]
4
5 #[allow(clippy::empty_loop)]
6 fn diverge() -> ! {
7     loop {}
8 }
9
10 struct A;
11
12 impl A {
13     fn foo(&self) -> ! {
14         diverge()
15     }
16 }
17
18 #[allow(unused_variables, clippy::unnecessary_operation, clippy::short_circuit_statement)]
19 fn main() {
20     let b = true;
21     b || diverge();
22     b || A.foo();
23 }
24
25 #[allow(dead_code, unused_variables)]
26 fn foobar() {
27     loop {
28         let x = match 5 {
29             4 => return,
30             5 => continue,
31             6 => true || return,
32             7 => true || continue,
33             8 => break,
34             9 => diverge(),
35             3 => true || diverge(),
36             10 => match 42 {
37                 99 => return,
38                 _ => true || panic!("boo"),
39             },
40             _ => true || break,
41         };
42     }
43 }