fork/rust

git clone https://git.julia.blue/fork/rust

borsAuto merge of #103046 - JanBeh:PR_clarify_cmp_terminology, r=workingjubilee3bcad65fbf6

master
1.6 KiB68 linesraw
1//@revisions: edition2018 edition2021
2//@[edition2018] edition:2018
3//@[edition2021] edition:2021
4
5#![warn(clippy::manual_assert)]
6#![allow(dead_code, unused_doc_comments)]
7#![allow(clippy::nonminimal_bool, clippy::uninlined_format_args, clippy::useless_vec)]
8
9macro_rules! one {
10    () => {
11        1
12    };
13}
14
15fn main() {
16    let a = vec![1, 2, 3];
17    let c = Some(2);
18    if !a.is_empty()
19        && a.len() == 3
20        && c.is_some()
21        && !a.is_empty()
22        && a.len() == 3
23        && !a.is_empty()
24        && a.len() == 3
25        && !a.is_empty()
26        && a.len() == 3
27    {
28        panic!("qaqaq{:?}", a);
29    }
30    assert!(a.is_empty(), "qaqaq{:?}", a);
31    assert!(a.is_empty(), "qwqwq");
32    if a.len() == 3 {
33        println!("qwq");
34        println!("qwq");
35        println!("qwq");
36    }
37    if let Some(b) = c {
38        panic!("orz {}", b);
39    }
40    if a.len() == 3 {
41        panic!("qaqaq");
42    } else {
43        println!("qwq");
44    }
45    let b = vec![1, 2, 3];
46    assert!(!b.is_empty(), "panic1");
47    assert!(!(b.is_empty() && a.is_empty()), "panic2");
48    assert!(!(a.is_empty() && !b.is_empty()), "panic3");
49    assert!(!(b.is_empty() || a.is_empty()), "panic4");
50    assert!(!(a.is_empty() || !b.is_empty()), "panic5");
51    assert!(!a.is_empty(), "with expansion {}", one!());
52    if a.is_empty() {
53        let _ = 0;
54    } else if a.len() == 1 {
55        panic!("panic6");
56    }
57}
58
59fn issue7730(a: u8) {
60    // Suggestion should preserve comment
61    // comment
62/* this is a
63        multiline
64        comment */
65/// Doc comment
66// comment after `panic!`
67assert!(!(a > 2), "panic with comment");
68}