Skip to content

Commit 04f993f

Browse files
committed
Add DOC_INCLUDE lint
1 parent 460d4ac commit 04f993f

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

compiler/rustc_lint_defs/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,7 @@ macro_rules! declare_lint {
446446
macro_rules! declare_tool_lint {
447447
(
448448
$(#[$attr:meta])* $vis:vis $tool:ident ::$NAME:ident, $Level: ident, $desc: expr
449+
$(, @future_incompatible = FutureIncompatibleInfo { $($field:ident : $val:expr),* $(,)* }; )?
449450
) => (
450451
$crate::declare_tool_lint!{$(#[$attr])* $vis $tool::$NAME, $Level, $desc, false}
451452
);

src/doc/rustdoc/src/lints.md

+12
Original file line numberDiff line numberDiff line change
@@ -331,3 +331,15 @@ warning: this URL is not a hyperlink
331331
3 | /// [http://example.net]
332332
| ^^^^^^^^^^^^^^^^^^ help: use an automatic link instead: `<http://example.net>`
333333
```
334+
335+
## external_doc
336+
337+
This lint is **nightly-only** and **warns by default**. It detects when
338+
`#![feature(external_doc)]` is used. This feature is scheduled for removal and will give a hard
339+
error in a future release.
340+
341+
```rust
342+
#![feature(external_doc)]
343+
#[doc(include = "README.md")]
344+
pub fn foo() {}
345+
```

src/librustdoc/lint.rs

+20-1
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,12 @@ where
6464
}
6565

6666
macro_rules! declare_rustdoc_lint {
67-
($(#[$attr:meta])* $name: ident, $level: ident, $descr: literal $(,)?) => {
67+
($(#[$attr:meta])* $name: ident, $level: ident, $descr: literal
68+
$(, @future_incompatible = FutureIncompatibleInfo { $($field:ident : $val:expr),* $(,)* }; )?
69+
$(,)?) => {
6870
declare_tool_lint! {
6971
$(#[$attr])* pub rustdoc::$name, $level, $descr
72+
$(, @future_incompatible = FutureIncompatibleInfo { $($field : $val),* };)?
7073
}
7174
}
7275
}
@@ -158,6 +161,22 @@ declare_rustdoc_lint! {
158161
"detects URLs that could be written using only angle brackets"
159162
}
160163

164+
declare_rustdoc_lint! {
165+
/// The `doc_include` lint detects when `#[doc(include = ...)]` is used.
166+
/// This feature is scheduled for removal and will give a hard error in a future release.
167+
///
168+
/// This is a `rustdoc` only lint, see the documentation in the [rustdoc book].
169+
///
170+
/// [rustdoc book]: ../../../rustdoc/lints.html#non_autolinks
171+
DOC_INCLUDE,
172+
Warn,
173+
"detects using `#[doc(include = ...)]`",
174+
@future_incompatible = FutureIncompatibleInfo {
175+
reference: "issue #44732 <https://github.com/rust-lang/rust/issues/44732>",
176+
edition: None,
177+
};
178+
}
179+
161180
crate static RUSTDOC_LINTS: Lazy<Vec<&'static Lint>> = Lazy::new(|| {
162181
vec![
163182
BROKEN_INTRA_DOC_LINKS,

0 commit comments

Comments
 (0)