about summary refs log tree commit diff
path: root/src/tools/clippy/tests/ui/empty_line_after/doc_comments.2.fixed
blob: 87c636c6ad2c77ccda3471686f80ce0294577dd5 (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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#![warn(clippy::empty_line_after_outer_attr, clippy::empty_line_after_doc_comments)]

//~vvv empty_line_after_doc_comments
//! Meant to be an
//! inner doc comment
//! for the crate

fn first_in_crate() {}

mod m {
    //~vvv empty_line_after_doc_comments
    //! Meant to be an
    //! inner doc comment
    //! for the module

    fn first_in_module() {}
}

mod some_mod {
    //! This doc comment should *NOT* produce a warning

    mod some_inner_mod {
        fn some_noop() {}
    }

    //~v empty_line_after_doc_comments
    /// # Indented
    ///
    /// Blank line
    fn indented() {}
}

//~v empty_line_after_doc_comments
/// This should produce a warning
fn with_doc_and_newline() {}

// This should *NOT* produce a warning
#[crate_type = "lib"]
/// some comment
fn with_no_newline_and_comment() {}

//~v empty_line_after_doc_comments
/// This doc comment should produce a warning
/** This is also a doc comment and is part of the warning
 */
#[allow(non_camel_case_types)]
#[allow(missing_docs)]
#[allow(dead_code)]
fn three_attributes() {}

mod misattributed {
    //~v empty_line_after_doc_comments
    // /// docs for `old_code`
    // fn old_code() {}

    fn new_code() {}

    //~vv empty_line_after_doc_comments
    // /// Docs
    // /// for OldA
    // struct OldA;

    // /// Docs
    // /// for OldB
    // struct OldB;

    /// Docs
    /// for Multiple
    #[allow(dead_code)]
    struct Multiple;
}

mod block_comments {
    //~v empty_line_after_doc_comments
    /*!
     * Meant to be inner doc comment
     */

    fn first_in_module() {}

    //~v empty_line_after_doc_comments
    /*
     * Docs for `old_code`
     */
    /* fn old_code() {} */

    /**
     * Docs for `new_code`
     */
    fn new_code() {}

    //~v empty_line_after_doc_comments
    // /// Docs for `old_code2`
    /* fn old_code2() {} */

    /// Docs for `new_code2`
    fn new_code2() {}
}

// This should *NOT* produce a warning
#[doc = "
Returns the escaped value of the textual representation of

"]
pub fn function() -> bool {
    true
}

// This should *NOT* produce a warning
#[derive(Clone, Copy)]
pub enum FooFighter {
    Bar1,

    Bar2,

    Bar3,

    Bar4,
}

/// Should not lint
// some line comment
/// gaps without an empty line
struct LineComment;

/// This should *NOT* produce a warning because the empty line is inside a block comment
/*

*/
pub struct EmptyInBlockComment;

/// This should *NOT* produce a warning
/* test */
pub struct BlockComment;

/// Ignore the empty line inside a cfg_attr'd out attribute
#[cfg_attr(any(), multiline(
    foo = 1

    bar = 2
))]
fn empty_line_in_cfg_attr() {}

trait Foo {
    fn bar();
}

impl Foo for LineComment {
    // /// comment on assoc item
    //~^ empty_line_after_doc_comments

    fn bar() {}
}

//~v empty_line_after_doc_comments
// /// Docs for this item.
// fn some_item() {}

impl LineComment {} // or any other nameless item kind

fn main() {}