Skip to content

fn main in a comment in rustdoc breaks tests #21299

Closed
@aidanhs

Description

@aidanhs
$ cat confuse.md
```rust
// pub fn mai
```
$ rustdoc --test confuse.md

running 1 test
test _0 ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured

$ sed -i 's/mai/main/' confuse.md
$ rustdoc --test confuse.md

running 1 test
test _0 ... FAILED

failures:

---- _0 stdout ----
        error: main function not found
error: aborting due to previous error
thread '_0' panicked at 'Box<Any>', /home/aidanhs/Desktop/rust/rust/src/libsyntax/diagnostic.rs:144



failures:
    _0

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

thread '<unnamed>' panicked at 'Some tests failed', /home/aidanhs/Desktop/rust/rust/src/libtest/lib.rs:265
thread '<main>' panicked at 'called `Result::unwrap()` on an `Err` value: ()', /home/aidanhs/Desktop/rust/rust/src/libcore/result.rs:746

Per http://doc.rust-lang.org/rustdoc.html, "Given a code block, if it does not contain fn main, it is wrapped in fn main() { your_code }"

Can it not be "does not contain 'fn main (' outside of a comment"?

Metadata

Metadata

Labels

C-bugCategory: This is a bug.T-dev-toolsRelevant to the dev-tools subteam, which will review and decide on the PR/issue.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

No branches or pull requests

Issue actions