-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.Category: This is a bug.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.Relevant to the rustdoc team, which will review and decide on the PR/issue.
Description
I tried this code:
#![warn(private_doc_tests)]
mod foo {
/// private doc test
///
/// ```ignore
/// assert!(false);
/// ```
fn bar() {}
}
I expected to see this happen: No warning for the given code block.
Instead, this happened: Warning appears for the given code block.
warning: documentation test in private item
--> src/lib.rs:4:5
|
4 | / /// private doc test
5 | | ///
6 | | /// ```
7 | | /// assert!(false);
8 | | /// ```
| |___________^
|
note: the lint level is defined here
--> src/lib.rs:1:9
|
1 | #![warn(private_doc_tests)]
| ^^^^^^^^^^^^^^^^^
As it is, I don't see a way to include a rust-highlighted code block with this lint. It is not uncommon to have sample code that is not intended to be tested, or even pseudo-code that you want highlighted, like this:
rust/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs
Lines 490 to 499 in 9fe551a
/// ```ignore (only-for-syntax-highlight) | |
/// struct Struct<'a, ..., 'z, A, B: DeclaredTrait, C, ..., Z> where C: WhereTrait { | |
/// a: A, | |
/// b: B::Item, | |
/// b1: <B as DeclaredTrait>::Item, | |
/// c1: <C as WhereTrait>::Item, | |
/// c2: Option<<C as WhereTrait>::Item>, | |
/// ... | |
/// } | |
/// ``` |
It would be nice to have some way to make the lint not fire, but still get rust syntax highlighting. ignore
seems like the first choice I would make, though I guess there could be other options.
Meta
rustdoc 1.48.0-nightly (c59199efc 2020-09-04)
Metadata
Metadata
Assignees
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.Category: This is a bug.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.Relevant to the rustdoc team, which will review and decide on the PR/issue.