Skip to content

compile-fail doctest sometimes erroneously claims code is compilable when it isn't #43707

Closed
@zackmdavis

Description

@zackmdavis

(example found during hour n of chasing down doctest failures for error codes long forgotten)

$ cat repro.rs 
#[inline()]
pub fn something() {}

fn main() {}
$ rustc repro.rs 
error[E0534]: expected one argument
 --> repro.rs:1:1
  |
1 | #[inline()]
  | ^^^^^^^^^^^

error: aborting due to previous error

$ cat repro.md 
```compile_fail
this should fail to compile, because this text is not valid Rust code
```

```compile_fail
#[inline()]
pub fn something() {}

fn main() {}
```
$ rustdoc --test repro.md 

running 2 tests
test repro.md - (line 1) ... ok
test repro.md - (line 6) ... FAILED

failures:

---- repro.md - (line 6) stdout ----
    	thread 'rustc' panicked at 'test compiled while it wasn't supposed to', /checkout/src/librustdoc/test.rs:263:12
note: Run with `RUST_BACKTRACE=1` for a backtrace.


failures:
    repro.md - (line 6)

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

The doctest output claims that the code in a compile_fail block "compiled while it wasn't supposed to," but we saw just a moment before that that code does not, in fact, compile.

$ rustc --version
rustc 1.21.0-nightly (ed16b0a1d 2017-08-05)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions