Skip to content

Commit e8aaa14

Browse files
authored
Rollup merge of #81675 - poliorcetics:respect-shortness, r=jyn514
Make rustdoc respect `--error-format short` in doctests Note that this will not work with `cargo test`, only with `rustdoc --test`, I'll have to modify `cargo` as well. Fix #81662. `@rustbot` label +T-rustdoc +A-doctests
2 parents add80c9 + 716d2cd commit e8aaa14

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

src/librustdoc/doctest.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,12 @@ fn run_test(
296296
}
297297
});
298298
if let ErrorOutputType::HumanReadable(kind) = options.error_format {
299-
let (_, color_config) = kind.unzip();
299+
let (short, color_config) = kind.unzip();
300+
301+
if short {
302+
compiler.arg("--error-format").arg("short");
303+
}
304+
300305
match color_config {
301306
ColorConfig::Never => {
302307
compiler.arg("--color").arg("never");
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// compile-flags:--test --error-format=short
2+
// normalize-stdout-test: "src/test/rustdoc-ui" -> "$$DIR"
3+
// normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME"
4+
// failure-status: 101
5+
6+
/// ```rust
7+
/// foo();
8+
/// ```
9+
//~^^ ERROR cannot find function `foo` in this scope
10+
fn foo() {
11+
println!("Hello, world!");
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
running 1 test
3+
test $DIR/issue-81662-shortness.rs - foo (line 6) ... FAILED
4+
5+
failures:
6+
7+
---- $DIR/issue-81662-shortness.rs - foo (line 6) stdout ----
8+
$DIR/issue-81662-shortness.rs:7:1: error[E0425]: cannot find function `foo` in this scope
9+
error: aborting due to previous error
10+
Couldn't compile the test.
11+
12+
failures:
13+
$DIR/issue-81662-shortness.rs - foo (line 6)
14+
15+
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME
16+

0 commit comments

Comments
 (0)