]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/tests/ui/unnecessary_safety_comment.rs
Rollup merge of #105050 - WaffleLapkin:uselessrefign, r=jyn514
[rust.git] / src / tools / clippy / tests / ui / unnecessary_safety_comment.rs
1 #![warn(clippy::undocumented_unsafe_blocks, clippy::unnecessary_safety_comment)]
2 #![allow(clippy::let_unit_value, clippy::missing_safety_doc)]
3
4 mod unsafe_items_invalid_comment {
5     // SAFETY:
6     const CONST: u32 = 0;
7     // SAFETY:
8     static STATIC: u32 = 0;
9     // SAFETY:
10     struct Struct;
11     // SAFETY:
12     enum Enum {}
13     // SAFETY:
14     mod module {}
15 }
16
17 mod unnecessary_from_macro {
18     trait T {}
19
20     macro_rules! no_safety_comment {
21         ($t:ty) => {
22             impl T for $t {}
23         };
24     }
25
26     // FIXME: This is not caught
27     // Safety: unnecessary
28     no_safety_comment!(());
29
30     macro_rules! with_safety_comment {
31         ($t:ty) => {
32             // Safety: unnecessary
33             impl T for $t {}
34         };
35     }
36
37     with_safety_comment!(i32);
38 }
39
40 fn unnecessary_on_stmt_and_expr() -> u32 {
41     // SAFETY: unnecessary
42     let num = 42;
43
44     // SAFETY: unnecessary
45     if num > 24 {}
46
47     // SAFETY: unnecessary
48     24
49 }
50
51 fn main() {}