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

compiletest shows very confusing error when a "build-fail" test fails the check part #130894

Closed
RalfJung opened this issue Sep 26, 2024 · 0 comments · Fixed by #131642
Closed
Labels
A-compiletest Area: The compiletest test runner C-bug Category: This is a bug. D-confusing Diagnostics: Confusing error or lint that should be reworked. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

Comments

@RalfJung
Copy link
Member

I'm working in a test with //@ build-fail, and I am getting the following error from compiletest:

error: test compilation failed although it shouldn't!
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/home/r/src/rust/rustc.2/build/x86_64-unknown-linux-gnu/stage1/bin/rustc" "/home/r/src/rust/rustc.2/tests/ui/asm/x86_64/type-check-4.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/home/r/.cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/home/r/src/rust/rustc.2/vendor" "--sysroot" "/home/r/src/rust/rustc.2/build/x86_64-unknown-linux-gnu/stage1" "--target=x86_64-unknown-linux-gnu" "--check-cfg" "cfg(FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/home/r/src/rust/rustc.2/build/x86_64-unknown-linux-gnu/test/ui/asm/x86_64/type-check-4" "-A" "unused" "-A" "internal_features" "-Crpath" "-Cdebuginfo=0" "-Lnative=/home/r/src/rust/rustc.2/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/home/r/src/rust/rustc.2/build/x86_64-unknown-linux-gnu/test/ui/asm/x86_64/type-check-4/auxiliary"
stdout: none
--- stderr -------------------------------
error[E0015]: cannot call non-const fn `non_const_fn` in constants
  --> /home/r/src/rust/rustc.2/tests/ui/asm/x86_64/type-check-4.rs:12:25
   |
LL | global_asm!("{}", const non_const_fn(0));
   |                         ^^^^^^^^^^^^^^^
   |
   = note: calls in constants are limited to constant functions, tuple structs and tuple variants

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0015`.
------------------------------------------

This error clearly makes no sense -- test compilation should indeed fail, it's a build-fail test after all!

But I assume what happens is what because it says "build-fail", it expects that a "check" build (--emit=metadata) should succeed, and that's the cause of the error. But then it should say so very clearly.

@RalfJung RalfJung added the A-compiletest Area: The compiletest test runner label Sep 26, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Sep 26, 2024
@saethlin saethlin added T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Sep 27, 2024
@jieyouxu jieyouxu added C-bug Category: This is a bug. D-confusing Diagnostics: Confusing error or lint that should be reworked. labels Oct 11, 2024
@bors bors closed this as completed in 0fa7101 Oct 13, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Oct 13, 2024
Rollup merge of rust-lang#131642 - jieyouxu:build-fail-check-fail, r=Kobzol

Special case error message for a `build-fail` test that failed check build

A `build-fail` test requires that a check build (roughly `--emit=metadata`, no codegen) succeeds but fails later. Previously, if its check build failed, the user will see the error message

```
error: test compilation failed although it shouldn't!
```

which is confusing. Because the test is `build-fail`, we want the test compilation to fail! This error message doesn't account for the difference between a check build and a complete build, so let's special case the error message for a `build-fail` test whose check build failed to instead say

```
error: `build-fail` test is required to pass check build, but check build failed
```

Fixes rust-lang#130894.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-compiletest Area: The compiletest test runner C-bug Category: This is a bug. D-confusing Diagnostics: Confusing error or lint that should be reworked. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
Development

Successfully merging a pull request may close this issue.

4 participants