]> git.lizzy.rs Git - rust.git/blob - tests/ui/panicking_macros.rs
Auto merge of #8359 - flip1995:rustup, r=flip1995
[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 assert() {
47     assert!(true);
48     assert_eq!(true, true);
49     assert_ne!(true, false);
50 }
51
52 fn assert_msg() {
53     assert!(true, "this should not panic");
54     assert_eq!(true, true, "this should not panic");
55     assert_ne!(true, false, "this should not panic");
56 }
57
58 fn debug_assert() {
59     debug_assert!(true);
60     debug_assert_eq!(true, true);
61     debug_assert_ne!(true, false);
62 }
63
64 fn debug_assert_msg() {
65     debug_assert!(true, "test");
66     debug_assert_eq!(true, true, "test");
67     debug_assert_ne!(true, false, "test");
68 }
69
70 fn main() {
71     panic();
72     todo();
73     unimplemented();
74     unreachable();
75     core_versions();
76     assert();
77     assert_msg();
78     debug_assert();
79     debug_assert_msg();
80 }