You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
rustdoc will attempt to compile a doc test for the following code, resulting in a failed doctest compilation:
I encountered this while writing verbatim docs for options using the clap derive API.
Steps to reproduce:
Add this to src/lib.rs
/// Show more output////// * -q - show only required output/// * - show changes/// * -v - show intermediate steps/// * -vv - show filter logs/// * -vvv - show pattern preprocessing logs/// * -vvvv - show internal logspubfnmain(){}
Run cargo t --doc
Expected result: no doctest is compiled for fn main, as it has not code blocks Actual result: a doctest failure
Finished test [unoptimized + debuginfo] target(s) in 0.00s
Doc-tests playground
running 1 test
test src/lib.rs - main (line 4) ... FAILED
failures:
---- src/lib.rs - main (line 4) stdout ----
error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `changes`
--> src/lib.rs:5:8
|
3 | - show changes
| ^^^^^^^ expected one of 8 possible tokens
error: aborting due to previous error
Couldn't compile the test.
failures:
src/lib.rs - main (line 4)
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.02s
error: test failed, to rerun pass '--doc'
The text was updated successfully, but these errors were encountered:
Unfortunately this is a known issue. The line * - show changes is an indendent code block according to commonmark rules. All code blocks are treated as rust code blocks, and all rust code blocks get tested. I don't think in this case you'll be able to indent the text to line up visually. You could perhaps use nbsp whitespace or something like that, but that might not render well in an editor.
I'm going to close as a duplicate of several other issues:
rustdoc
will attempt to compile a doc test for the following code, resulting in a failed doctest compilation:I encountered this while writing verbatim docs for options using the
clap
derive API.Steps to reproduce:
src/lib.rs
cargo t --doc
Expected result: no doctest is compiled for
fn main
, as it has not code blocksActual result: a doctest failure
Meta
rustc --version --verbose
:This also happens on stable,
rustc +stable --version --verbose
:Backtrace
The text was updated successfully, but these errors were encountered: