Skip to content

Commit 7195355

Browse files
committed
Add declare_rustdoc_lint! macro
1 parent 37e4cfe commit 7195355

File tree

1 file changed

+22
-14
lines changed

1 file changed

+22
-14
lines changed

src/librustdoc/lint.rs

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -63,78 +63,86 @@ where
6363
(lint_opts, lint_caps)
6464
}
6565

66-
declare_tool_lint! {
66+
macro_rules! declare_rustdoc_lint {
67+
($(#[$attr:meta])* $name: ident, $level: ident, $descr: literal $(,)?) => {
68+
declare_tool_lint! {
69+
$(#[$attr])* pub rustdoc::$name, $level, $descr
70+
}
71+
}
72+
}
73+
74+
declare_rustdoc_lint! {
6775
/// The `broken_intra_doc_links` lint detects failures in resolving
6876
/// intra-doc link targets. This is a `rustdoc` only lint, see the
6977
/// documentation in the [rustdoc book].
7078
///
7179
/// [rustdoc book]: ../../../rustdoc/lints.html#broken_intra_doc_links
72-
pub rustdoc::BROKEN_INTRA_DOC_LINKS,
80+
BROKEN_INTRA_DOC_LINKS,
7381
Warn,
7482
"failures in resolving intra-doc link targets"
7583
}
7684

77-
declare_tool_lint! {
85+
declare_rustdoc_lint! {
7886
/// This is a subset of `broken_intra_doc_links` that warns when linking from
7987
/// a public item to a private one. This is a `rustdoc` only lint, see the
8088
/// documentation in the [rustdoc book].
8189
///
8290
/// [rustdoc book]: ../../../rustdoc/lints.html#private_intra_doc_links
83-
pub rustdoc::PRIVATE_INTRA_DOC_LINKS,
91+
PRIVATE_INTRA_DOC_LINKS,
8492
Warn,
8593
"linking from a public item to a private one"
8694
}
8795

88-
declare_tool_lint! {
96+
declare_rustdoc_lint! {
8997
/// The `invalid_codeblock_attributes` lint detects code block attributes
9098
/// in documentation examples that have potentially mis-typed values. This
9199
/// is a `rustdoc` only lint, see the documentation in the [rustdoc book].
92100
///
93101
/// [rustdoc book]: ../../../rustdoc/lints.html#invalid_codeblock_attributes
94-
pub rustdoc::INVALID_CODEBLOCK_ATTRIBUTES,
102+
INVALID_CODEBLOCK_ATTRIBUTES,
95103
Warn,
96104
"codeblock attribute looks a lot like a known one"
97105
}
98106

99-
declare_tool_lint! {
107+
declare_rustdoc_lint! {
100108
/// The `missing_doc_code_examples` lint detects publicly-exported items
101109
/// without code samples in their documentation. This is a `rustdoc` only
102110
/// lint, see the documentation in the [rustdoc book].
103111
///
104112
/// [rustdoc book]: ../../../rustdoc/lints.html#missing_doc_code_examples
105-
pub rustdoc::MISSING_DOC_CODE_EXAMPLES,
113+
MISSING_DOC_CODE_EXAMPLES,
106114
Allow,
107115
"detects publicly-exported items without code samples in their documentation"
108116
}
109117

110-
declare_tool_lint! {
118+
declare_rustdoc_lint! {
111119
/// The `private_doc_tests` lint detects code samples in docs of private
112120
/// items not documented by `rustdoc`. This is a `rustdoc` only lint, see
113121
/// the documentation in the [rustdoc book].
114122
///
115123
/// [rustdoc book]: ../../../rustdoc/lints.html#private_doc_tests
116-
pub rustdoc::PRIVATE_DOC_TESTS,
124+
PRIVATE_DOC_TESTS,
117125
Allow,
118126
"detects code samples in docs of private items not documented by rustdoc"
119127
}
120128

121-
declare_tool_lint! {
129+
declare_rustdoc_lint! {
122130
/// The `invalid_html_tags` lint detects invalid HTML tags. This is a
123131
/// `rustdoc` only lint, see the documentation in the [rustdoc book].
124132
///
125133
/// [rustdoc book]: ../../../rustdoc/lints.html#invalid_html_tags
126-
pub rustdoc::INVALID_HTML_TAGS,
134+
INVALID_HTML_TAGS,
127135
Allow,
128136
"detects invalid HTML tags in doc comments"
129137
}
130138

131-
declare_tool_lint! {
139+
declare_rustdoc_lint! {
132140
/// The `non_autolinks` lint detects when a URL could be written using
133141
/// only angle brackets. This is a `rustdoc` only lint, see the
134142
/// documentation in the [rustdoc book].
135143
///
136144
/// [rustdoc book]: ../../../rustdoc/lints.html#non_autolinks
137-
pub rustdoc::NON_AUTOLINKS,
145+
NON_AUTOLINKS,
138146
Warn,
139147
"detects URLs that could be written using only angle brackets"
140148
}

0 commit comments

Comments
 (0)