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: Comments (prose) are being parsed as tests #81648

Closed
rjframe opened this issue Feb 1, 2021 · 2 comments
Closed

Rustdoc: Comments (prose) are being parsed as tests #81648

rjframe opened this issue Feb 1, 2021 · 2 comments
Labels
C-bug Category: This is a bug.

Comments

@rjframe
Copy link

rjframe commented Feb 1, 2021

Given multi-line doc-comments (/** */), indented one or more levels, the second paragraph is parsed as code.

With the following code:

    /** Summary

        a b
    */
    fn f() {}

I get the following output from cargo test (standard output only):

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out


running 1 test
test src/lib.rs - f (line 4) ... FAILED

failures:

---- src/lib.rs - f (line 4) stdout ----
error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `b`
 --> src/lib.rs:5:3
  |
3 | a b
  |   ^ expected one of 8 possible tokens

error: aborting due to previous error

Couldn't compile the test.

failures:
    src/lib.rs - f (line 4)

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out

This only occurs with indented, multi-line doc-comments that have at least two paragraphs separated by a blank line.

This occurs on both stable and nightly.

@rjframe rjframe added the C-bug Category: This is a bug. label Feb 1, 2021
@jfrimmel
Copy link
Contributor

jfrimmel commented Feb 1, 2021

This is the intended behavior. In markdown (the syntax used in doc comments) an indentation of 4 spaces marks a code block, similar to the three-backtick-block. If you don't provide a source language (you cannot for indented blocks), rustdoc interprets it as Rust source code and hence compiles and tests it.

@ehuss
Copy link
Contributor

ehuss commented Feb 1, 2021

Closing as a duplicate of #64162 and #59867.

@ehuss ehuss closed this as completed Feb 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug.
Projects
None yet
Development

No branches or pull requests

3 participants