Skip to content

Rustdoc does not obey --error-format for doctests error messages #81662

@Nemo157

Description

@Nemo157

I tried this code:

/// ```rust /// foo(); /// ``` fn foo() { println!("Hello, world!"); }

I expected to see this happen: Running cargo test --doc --message-format=short uses short messages for all errors

Instead, this happened: The build failure for the doc test emits full error messages:

> cargo test --doc --message-format=short  Compiling foo v0.1.0 (/tmp/tmp.RZdiSTk0tC/foo) src/lib.rs:4:4: warning: function is never used: `foo` warning: 1 warning emitted  Finished test [unoptimized + debuginfo] target(s) in 0.11s  Doc-tests foo running 1 test test src/lib.rs - foo (line 1) ... FAILED failures: ---- src/lib.rs - foo (line 1) stdout ---- error[E0423]: expected function, found crate `foo`  --> src/lib.rs:2:1  | 4 | foo();  | ^^^ not a function error: aborting due to previous error For more information about this error, try `rustc --explain E0423`. Couldn't compile the test. failures:  src/lib.rs - foo (line 1) test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.04s error: test failed, to rerun pass '--doc'

Meta

rustc --version --verbose:

rustc 1.50.0-nightly (0f6f2d681 2020-12-06) binary: rustc commit-hash: 0f6f2d681b39c5f95459cd09cb936b6ceb27cd82 commit-date: 2020-12-06 host: x86_64-unknown-linux-gnu release: 1.50.0-nightly 

Metadata

Metadata

Assignees

Labels

A-doctestsArea: Documentation tests, run by rustdocC-bugCategory: This is a bug.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