]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/src/docs/empty_line_after_outer_attr.txt
Rollup merge of #101633 - aDotInTheVoid:rdj-idl, r=jyn514
[rust.git] / src / tools / clippy / src / docs / empty_line_after_outer_attr.txt
1 ### What it does
2 Checks for empty lines after outer attributes
3
4 ### Why is this bad?
5 Most likely the attribute was meant to be an inner attribute using a '!'.
6 If it was meant to be an outer attribute, then the following item
7 should not be separated by empty lines.
8
9 ### Known problems
10 Can cause false positives.
11
12 From the clippy side it's difficult to detect empty lines between an attributes and the
13 following item because empty lines and comments are not part of the AST. The parsing
14 currently works for basic cases but is not perfect.
15
16 ### Example
17 ```
18 #[allow(dead_code)]
19
20 fn not_quite_good_code() { }
21 ```
22
23 Use instead:
24 ```
25 // Good (as inner attribute)
26 #![allow(dead_code)]
27
28 fn this_is_fine() { }
29
30 // or
31
32 // Good (as outer attribute)
33 #[allow(dead_code)]
34 fn this_is_fine_too() { }
35 ```