Closed
Description
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
euclio commentedon Apr 27, 2019
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 commentedon Apr 27, 2019
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.
euclio commentedon Apr 27, 2019
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 commentedon May 6, 2019
@phrohdoh could you edit this issue to reflect the current status? It should be something like "Empty doc tests should be linted".
[-]Invalid code block warning for doc test points to start of doc instead of the code block[/-][+]Empty doc tests should be linted[/+]tommilligan commentedon Aug 19, 2019
@euclio @phrohdoh I'd like to take this issue - should have a PR this week for review.
Auto merge of #63703 - tommilligan:warn-empty-doctest, r=ollie27