]>
git.proxmox.com Git - rustc.git/blob - src/tools/clippy/tests/ui/missing_assert_message.rs
2 #![warn(clippy::missing_assert_message)]
12 // Should trigger warning
13 fn asserts_without_message() {
15 assert_eq
!(foo(), foo());
16 assert_ne
!(foo(), foo());
18 debug_assert_eq
!(foo(), foo());
19 debug_assert_ne
!(foo(), foo());
22 // Should trigger warning
23 fn asserts_without_message_but_with_macro_calls() {
25 assert
!(bar
!(true, false));
26 assert_eq
!(bar
!(true), foo());
27 assert_ne
!(bar
!(true, true), bar
!(true));
30 // Should trigger warning
31 fn asserts_with_trailing_commas() {
33 assert_eq
!(foo(), foo(),);
34 assert_ne
!(foo(), foo(),);
35 debug_assert
!(foo(),);
36 debug_assert_eq
!(foo(), foo(),);
37 debug_assert_ne
!(foo(), foo(),);
40 // Should not trigger warning
41 fn asserts_with_message_and_with_macro_calls() {
42 assert
!(bar
!(true), "msg");
43 assert
!(bar
!(true, false), "msg");
44 assert_eq
!(bar
!(true), foo(), "msg");
45 assert_ne
!(bar
!(true, true), bar
!(true), "msg");
48 // Should not trigger warning
49 fn asserts_with_message() {
50 assert
!(foo(), "msg");
51 assert_eq
!(foo(), foo(), "msg");
52 assert_ne
!(foo(), foo(), "msg");
53 debug_assert
!(foo(), "msg");
54 debug_assert_eq
!(foo(), foo(), "msg");
55 debug_assert_ne
!(foo(), foo(), "msg");
58 // Should not trigger warning
60 fn asserts_without_message_but_inside_a_test_function() {
62 assert_eq
!(foo(), foo());
63 assert_ne
!(foo(), foo());
65 debug_assert_eq
!(foo(), foo());
66 debug_assert_ne
!(foo(), foo());
69 // Should not trigger warning
72 fn asserts_without_message_but_inside_a_test_module() {
74 assert_eq
!(foo(), foo());
75 assert_ne
!(foo(), foo());
77 debug_assert_eq
!(foo(), foo());
78 debug_assert_ne
!(foo(), foo());