Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
zackmdavis opened this issue Aug 7, 2017 · 2 comments

Comments

@zackmdavis
Copy link
Member

(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)
zackmdavis added a commit to zackmdavis/rust that referenced this issue Aug 7, 2017
After repatriating error explanations to the global registry, some lurking
doctest failures surfaced and needed to be chased down. Sadly, a few doctests
needed to be ignored due to a not-yet-understood regression in the doctest
`compile_fail` functionality (filed rust-lang#43707).
@kennytm
Copy link
Member

kennytm commented Aug 7, 2017

The problem is that the content of an inline attribute is checked during trans, the step which compile_fail will skip.

Duplicate of #40792.

@Mark-Simulacrum
Copy link
Member

Closing in favor of #40792.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants