Skip to content

rustdoc: private_doc_tests lint ignores "ignore" #76457

Closed
@ehuss

Description

@ehuss

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:

/// ```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

Labels

A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions