summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/tests/ui/unnecessary_safety_comment.rs
blob: 7fefea7051d698ce92aab8e5c9dc6b48242e2564 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#![warn(clippy::undocumented_unsafe_blocks, clippy::unnecessary_safety_comment)]
#![allow(clippy::let_unit_value, clippy::missing_safety_doc)]

mod unsafe_items_invalid_comment {
    // SAFETY:
    const CONST: u32 = 0;
    // SAFETY:
    static STATIC: u32 = 0;
    // SAFETY:
    struct Struct;
    // SAFETY:
    enum Enum {}
    // SAFETY:
    mod module {}
}

mod unnecessary_from_macro {
    trait T {}

    macro_rules! no_safety_comment {
        ($t:ty) => {
            impl T for $t {}
        };
    }

    // FIXME: This is not caught
    // Safety: unnecessary
    no_safety_comment!(());

    macro_rules! with_safety_comment {
        ($t:ty) => {
            // Safety: unnecessary
            impl T for $t {}
        };
    }

    with_safety_comment!(i32);
}

fn unnecessary_on_stmt_and_expr() -> u32 {
    // SAFETY: unnecessary
    let num = 42;

    // SAFETY: unnecessary
    if num > 24 {}

    // SAFETY: unnecessary
    24
}

fn main() {}