about summary refs log tree commit diff
path: root/src/tools/clippy/tests/ui/doc_suspicious_footnotes.rs
blob: 9a8d0dcf47548ad35819dc09f6710533c8377be0 (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
162
#![warn(clippy::doc_suspicious_footnotes)]
#![allow(clippy::needless_raw_string_hashes)]
//! This is not a footnote[^1].
//~^ doc_suspicious_footnotes
//!
//! This is not a footnote[^either], but it doesn't warn.
//!
//! This is not a footnote\[^1], but it also doesn't warn.
//!
//! This is not a footnote[^1\], but it also doesn't warn.
//!
//! This is not a `footnote[^1]`, but it also doesn't warn.
//!
//! This is a footnote[^2].
//!
//! [^2]: hello world

/// This is not a footnote[^1].
//~^ doc_suspicious_footnotes
///
/// This is not a footnote[^either], but it doesn't warn.
///
/// This is not a footnote\[^1], but it also doesn't warn.
///
/// This is not a footnote[^1\], but it also doesn't warn.
///
/// This is not a `footnote[^1]`, but it also doesn't warn.
///
/// This is a footnote[^2].
///
/// [^2]: hello world
pub fn footnotes() {
    // test code goes here
}

pub struct Foo;
#[rustfmt::skip]
impl Foo {
    #[doc = r#"This is not a footnote[^1]."#]
    //~^ doc_suspicious_footnotes
    #[doc = r#""#]
    #[doc = r#"This is not a footnote[^either], but it doesn't warn."#]
    #[doc = r#""#]
    #[doc = r#"This is not a footnote\[^1], but it also doesn't warn."#]
    #[doc = r#""#]
    #[doc = r#"This is not a footnote[^1\], but it also doesn't warn."#]
    #[doc = r#""#]
    #[doc = r#"This is not a `footnote[^1]`, but it also doesn't warn."#]
    #[doc = r#""#]
    #[doc = r#"This is a footnote[^2]."#]
    #[doc = r#""#]
    #[doc = r#"[^2]: hello world"#]
    pub fn footnotes() {
        // test code goes here
    }
    #[doc = "This is not a footnote[^1].

    This is not a footnote[^either], but it doesn't warn.

    This is not a footnote\\[^1], but it also doesn't warn.

    This is not a footnote[^1\\], but it also doesn't warn.

    This is not a `footnote[^1]`, but it also doesn't warn.

    This is a footnote[^2].

    [^2]: hello world
    "]
    //~^^^^^^^^^^^^^^ doc_suspicious_footnotes
    pub fn footnotes2() {
        // test code goes here
    }
    #[cfg_attr(
        not(FALSE),
        doc = "This is not a footnote[^1].\n\nThis is not a footnote[^either], but it doesn't warn."
    //~^ doc_suspicious_footnotes
    )]
    pub fn footnotes3() {
        // test code goes here
    }
    #[doc = "My footnote [^foot\note]"]
    pub fn footnote4() {
        // test code goes here
    }
    #[doc = "Hihi"]pub fn footnote5() {
        // test code goes here
    }
}

#[doc = r"This is not a footnote[^1]."]
//~^ doc_suspicious_footnotes
#[doc = r""]
#[doc = r"This is not a footnote[^either], but it doesn't warn."]
#[doc = r""]
#[doc = r"This is not a footnote\[^1], but it also doesn't warn."]
#[doc = r""]
#[doc = r"This is not a footnote[^1\], but it also doesn't warn."]
#[doc = r""]
#[doc = r"This is not a `footnote[^1]`, but it also doesn't warn."]
#[doc = r""]
#[doc = r"This is a footnote[^2]."]
#[doc = r""]
#[doc = r"[^2]: hello world"]
pub fn footnotes_attrs() {
    // test code goes here
}

pub mod multiline {
    /*!
     * This is not a footnote[^1]. //~ doc_suspicious_footnotes
     *
     * This is not a footnote\[^1], but it doesn't warn.
     *
     * This is a footnote[^2].
     *
     * These give weird results, but correct ones, so it works.
     *
     * [^2]: hello world
     */
    /**
     * This is not a footnote[^1]. //~ doc_suspicious_footnotes
     *
     * This is not a footnote\[^1], but it doesn't warn.
     *
     * This is a footnote[^2].
     *
     * These give weird results, but correct ones, so it works.
     *
     * [^2]: hello world
     */
    pub fn foo() {}
}

/// This is not a footnote [^1]
//~^ doc_suspicious_footnotes
///
/// This one is [^2]
///
/// [^2]: contents
#[doc = "This is not a footnote [^3]"]
//~^ doc_suspicious_footnotes
#[doc = ""]
#[doc = "This one is [^4]"]
#[doc = ""]
#[doc = "[^4]: contents"]
pub struct MultiFragmentFootnote;

#[doc(inline)]
/// This is not a footnote [^5]
//~^ doc_suspicious_footnotes
///
/// This one is [^6]
///
/// [^6]: contents
#[doc = "This is not a footnote [^7]"]
//~^ doc_suspicious_footnotes
#[doc = ""]
#[doc = "This one is [^8]"]
#[doc = ""]
#[doc = "[^8]: contents"]
pub use MultiFragmentFootnote as OtherInlinedFootnote;