Skip to content

Empty doc tests should be linted #60319

Closed
@phrohdoh

Description

@phrohdoh

Run tests for https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=8ac29ea8121d53906e7a77cd01ccbe70 and you'll get the following diagnostic:

warning: invalid start of a new code block
 --> /playground/src/lib.rs:1:1
  |
1 | //! Hello
  | ^^^^^^^^^

But to be as helpful as possible the diagnostic should, if possible, point to the start of the invalid code block.

Activity

added
A-diagnosticsArea: Messages for errors, warnings, and lints
A-doctestsArea: Documentation tests, run by rustdoc
T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.
on Apr 26, 2019
euclio

euclio commented on Apr 27, 2019

@euclio
Contributor

This error was removed in #60140 because I didn't think it could actually be produced. Looks like it was possible to trigger by writing an empty doc test. The error message is misleading, though. It's a valid code block, just empty.

On master, this code produces a passing doc test now. IMO, that is the correct behavior. There should probably be a test for it.

phrohdoh

phrohdoh commented on Apr 27, 2019

@phrohdoh
Author

There should probably be a test for it.

I agree completely.

Would this mean re-introducing this message but improving the message (replacing invalid with empty or something similar)?

I believe that is the best course of action as warning on an empty code block is completely valid and desired IMO.

added
E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.
on Apr 27, 2019
euclio

euclio commented on Apr 27, 2019

@euclio
Contributor

The original code only caught this incidentally. I think this check would make more sense as a rustdoc lint instead of a hard warning. Could be added to check-code-block-syntax or a new pass entirely.

euclio

euclio commented on May 6, 2019

@euclio
Contributor

@phrohdoh could you edit this issue to reflect the current status? It should be something like "Empty doc tests should be linted".

changed the title [-]Invalid code block warning for doc test points to start of doc instead of the code block[/-] [+]Empty doc tests should be linted[/+] on May 6, 2019
tommilligan

tommilligan commented on Aug 19, 2019

@tommilligan
Contributor

@euclio @phrohdoh I'd like to take this issue - should have a PR this week for review.

added a commit that references this issue on Aug 31, 2019

Auto merge of #63703 - tommilligan:warn-empty-doctest, r=ollie27

59cc53e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-doctestsArea: Documentation tests, run by rustdocE-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.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

      Participants

      @euclio@jonas-schievink@varkor@phrohdoh@tommilligan

      Issue actions

        Empty doc tests should be linted · Issue #60319 · rust-lang/rust