]> git.lizzy.rs Git - rust.git/blob - tests/ui/panicking_macros.rs
Merge remote-tracking branch 'upstream/beta' into backport_remerge
[rust.git] / tests / ui / panicking_macros.rs
1 #![warn(clippy::unimplemented, clippy::unreachable, clippy::todo, clippy::panic)]
2 #![allow(clippy::assertions_on_constants, clippy::eq_op)]
3
4 extern crate core;
5
6 fn panic() {
7     let a = 2;
8     panic!();
9     panic!("message");
10     panic!("{} {}", "panic with", "multiple arguments");
11     let b = a + 2;
12 }
13
14 fn todo() {
15     let a = 2;
16     todo!();
17     todo!("message");
18     todo!("{} {}", "panic with", "multiple arguments");
19     let b = a + 2;
20 }
21
22 fn unimplemented() {
23     let a = 2;
24     unimplemented!();
25     unimplemented!("message");
26     unimplemented!("{} {}", "panic with", "multiple arguments");
27     let b = a + 2;
28 }
29
30 fn unreachable() {
31     let a = 2;
32     unreachable!();
33     unreachable!("message");
34     unreachable!("{} {}", "panic with", "multiple arguments");
35     let b = a + 2;
36 }
37
38 fn core_versions() {
39     use core::{panic, todo, unimplemented, unreachable};
40     panic!();
41     todo!();
42     unimplemented!();
43     unreachable!();
44 }
45
46 fn debug_assert() {
47     debug_assert!(true);
48     debug_assert_eq!(true, true);
49     debug_assert_ne!(true, false);
50 }
51
52 fn debug_assert_msg() {
53     debug_assert!(true, "test");
54     debug_assert_eq!(true, true, "test");
55     debug_assert_ne!(true, false, "test");
56 }
57
58 fn main() {
59     panic();
60     todo();
61     unimplemented();
62     unreachable();
63     core_versions();
64 }