Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rustdoc: private_doc_tests lint ignores "ignore" #76457

Closed
ehuss opened this issue Sep 7, 2020 · 1 comment · Fixed by #76642
Closed

rustdoc: private_doc_tests lint ignores "ignore" #76457

ehuss opened this issue Sep 7, 2020 · 1 comment · Fixed by #76642
Assignees
Labels
A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@ehuss
Copy link
Contributor

ehuss commented Sep 7, 2020

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)

@ehuss ehuss added the C-bug Category: This is a bug. label Sep 7, 2020
@jyn514 jyn514 added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. labels Sep 8, 2020
@GuillaumeGomez
Copy link
Member

This shouldn't be considered as a codeblock. Fixing it.

@GuillaumeGomez GuillaumeGomez self-assigned this Sep 12, 2020
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Sep 16, 2020
@bors bors closed this as completed in ece688b Sep 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants