rustdoc -D warnings doesn't fail for all warnings · Issue #79792 · rust-lang/rust (original) (raw)
I tried this code:
/// See [foo:Foo
].
/// ```rust
fn main() {}
I expected to see this happen:
The env variable -Dwarnings
is supposed to make rustdoc treat warnings as errors. For export RUSTDOCFLAGS=""
the run below outputs only warnings, no errors. For RUSTDOCFLAGS="-Dwarnings"
I would have expected both warnings to now be errors.
$ export RUSTDOCFLAGS="-Dwarnings"
$ cargo doc
Documenting rustdoc-bug v0.1.0 (/tmp/bug/rustdoc-bug)
error: unresolved link to `foo:Foo`
--> src/main.rs:1:10
|
1 | /// See [`foo:Foo`].
| ^^^^^^^^^ no item named `foo:Foo` in scope
|
= note: `-D broken-intra-doc-links` implied by `-D warnings`
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
error: Rust code block is empty
--> src/main.rs:2:5
|
2 | /// ```rust
| ^^^^^^^
error: aborting due to previous error; 1 warning emitted```
Instead, this happened:
Only one of the warnings is switched to an error.
$ export RUSTDOCFLAGS="-Dwarnings"
$ cargo doc
Documenting rustdoc-bug v0.1.0 (/tmp/bug/rustdoc-bug)
error: unresolved link to `foo:Foo`
--> src/main.rs:1:10
|
1 | /// See [`foo:Foo`].
| ^^^^^^^^^ no item named `foo:Foo` in scope
|
= note: `-D broken-intra-doc-links` implied by `-D warnings`
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
warning: Rust code block is empty
--> src/main.rs:2:5
|
2 | /// ```rust
| ^^^^^^^
error: aborting due to previous error; 1 warning emitted```
This is also problematic because for warnings the exit code is still 0
, so a CI setup might not detect the failure:
$ cat src/main.rs
/// ```rust
fn main() {}
$ RUSTDOCFLAGS="-Dwarnings" cargo doc
warning: Rust code block is empty
--> src/main.rs:1:5
|
1 | /// ```rust
| ^^^^^^^
warning: 1 warning emitted
Finished dev [unoptimized + debuginfo] target(s) in 0.00s
$ echo $?
0
Meta
rustc --version --verbose
:
rustc 1.50.0-nightly (1c389ffef 2020-11-24)