Skip to content

libtest: do not early exit from test runners - #162796

Merged
rust-bors[bot] merged 2 commits into
rust-lang:mainfrom
RalfJung:libtest-no-early-exit
Sep 17, 2026
Merged

rust-bors[bot] merged 2 commits into
rust-lang:mainfrom
RalfJung:libtest-no-early-exit

Conversation

@RalfJung

@RalfJung RalfJung commented Sep 15, 2026

Copy link
Copy Markdown
Member

Suggested by @Mark-Simulacrum in #161868. I finally figured out why my earlier attempts did not work.

@rustbot rustbot added A-rustc-dev-guide Area: rustc-dev-guide S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Sep 15, 2026
@RalfJung

Copy link
Copy Markdown
Member Author

@bors try job=dist-x86_64-msvc

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Sep 15, 2026
libtest: do not early exit from test runners


try-job: dist-x86_64-msvc
@rust-log-analyzer

This comment has been minimized.

@rust-bors

rust-bors Bot commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

💔 Test for 40346c4 failed: CI. Failed job:

@RalfJung
RalfJung force-pushed the libtest-no-early-exit branch from 5dd5372 to 7c7e382 Compare September 15, 2026 08:49
It does not look like these items are actually used by rustc.
@RalfJung
RalfJung force-pushed the libtest-no-early-exit branch from 7c7e382 to 5fd598e Compare September 15, 2026 10:43
@RalfJung
RalfJung marked this pull request as ready for review September 15, 2026 10:43
@rustbot

rustbot commented Sep 15, 2026

Copy link
Copy Markdown
Collaborator

clippy is developed in its own repository. If possible, consider making this change to rust-lang/rust-clippy instead.

cc @rust-lang/clippy

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 15, 2026
@rustbot rustbot removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Sep 15, 2026
@rustbot

rustbot commented Sep 15, 2026

Copy link
Copy Markdown
Collaborator

r? @oli-obk

rustbot has assigned @oli-obk.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 76 candidates
  • Random selection from 19 candidates

@RalfJung

Copy link
Copy Markdown
Member Author

@bors try job=dist-x86_64-msvc,testmsvc

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Sep 15, 2026
libtest: do not early exit from test runners


try-job: dist-x86_64-msvc
try-job: test*msvc*
@rust-bors

rust-bors Bot commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 06e803b (06e803b7911a3f2d76a1a9787f21e39692f30738)
Base parent: 5392d2f (5392d2f545c6836dc79f209bcc14ac7179dbc4f2)

@oli-obk

oli-obk commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

@bors r+

@rust-bors

rust-bors Bot commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 5fd598e has been approved by oli-obk

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 16, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Sep 16, 2026
…oli-obk

libtest: do not early exit from test runners

Suggested by @Mark-Simulacrum in rust-lang#161868. I finally figured out why my earlier attempts did not work.
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Sep 16, 2026
…oli-obk

libtest: do not early exit from test runners

Suggested by @Mark-Simulacrum in rust-lang#161868. I finally figured out why my earlier attempts did not work.
rust-bors Bot pushed a commit that referenced this pull request Sep 16, 2026
…uwer

Rollup of 8 pull requests

Successful merges:

 - #162796 (libtest: do not early exit from test runners)
 - #162844 (Add loan reachability traces to polonius MIR dumps)
 - #158186 (Guarantee 8 bytes of alignment of RawWakerVTable)
 - #160108 (Stabilize `windows_process_extensions_main_thread_handle`)
 - #161305 (Use the entire type of a dropped local to compute variance (edge direction) for Polonius alpha)
 - #161838 (tests: accept LLVM 24 optimization in this test)
 - #162825 (core: Add examples for `debug_closure_helpers`)
 - #162856 (Stabilize CommandExt::show_window)
Zalathar added a commit to Zalathar/rust that referenced this pull request Sep 17, 2026
…oli-obk

libtest: do not early exit from test runners

Suggested by @Mark-Simulacrum in rust-lang#161868. I finally figured out why my earlier attempts did not work.
rust-bors Bot pushed a commit that referenced this pull request Sep 17, 2026
Rollup of 12 pull requests

Successful merges:

 - #161596 (coretests: Add more pattern tests.)
 - #162796 (libtest: do not early exit from test runners)
 - #162844 (Add loan reachability traces to polonius MIR dumps)
 - #158186 (Guarantee 8 bytes of alignment of RawWakerVTable)
 - #160108 (Stabilize `windows_process_extensions_main_thread_handle`)
 - #160212 (traits: Fix rigid alias liveness matching)
 - #160544 (Stabilize `feature(trim_prefix_suffix)` (`{str, [T], Path}::trim_prefix` and `{str, [T]}::trim_suffix`))
 - #161305 (Use the entire type of a dropped local to compute variance (edge direction) for Polonius alpha)
 - #161838 (tests: accept LLVM 24 optimization in this test)
 - #162805 (Add `must_use` lint to `ExitCode`)
 - #162825 (core: Add examples for `debug_closure_helpers`)
 - #162856 (Stabilize CommandExt::show_window)
Zalathar added a commit to Zalathar/rust that referenced this pull request Sep 17, 2026
…oli-obk

libtest: do not early exit from test runners

Suggested by @Mark-Simulacrum in rust-lang#161868. I finally figured out why my earlier attempts did not work.
Zalathar added a commit to Zalathar/rust that referenced this pull request Sep 17, 2026
…oli-obk

libtest: do not early exit from test runners

Suggested by @Mark-Simulacrum in rust-lang#161868. I finally figured out why my earlier attempts did not work.
rust-bors Bot pushed a commit that referenced this pull request Sep 17, 2026
Rollup of 16 pull requests

Successful merges:

 - #161596 (coretests: Add more pattern tests.)
 - #162796 (libtest: do not early exit from test runners)
 - #162844 (Add loan reachability traces to polonius MIR dumps)
 - #162876 (Move operations out of `rustc_middle::query::job`)
 - #160108 (Stabilize `windows_process_extensions_main_thread_handle`)
 - #160212 (traits: Fix rigid alias liveness matching)
 - #160544 (Stabilize `feature(trim_prefix_suffix)` (`{str, [T], Path}::trim_prefix` and `{str, [T]}::trim_suffix`))
 - #161246 (Normalize non-rigid aliases in ty_known_to_outlive)
 - #161305 (Use the entire type of a dropped local to compute variance (edge direction) for Polonius alpha)
 - #161838 (tests: accept LLVM 24 optimization in this test)
 - #162805 (Add `must_use` lint to `ExitCode`)
 - #162825 (core: Add examples for `debug_closure_helpers`)
 - #162841 (enable asm tests for xtensa targets)
 - #162842 (reintroduce check RibKind::ConstParamTy did in direct consts)
 - #162845 (mgca: fix issue with mismatched array valtree/valtree tys)
 - #162856 (Stabilize CommandExt::show_window)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Sep 17, 2026
…oli-obk

libtest: do not early exit from test runners

Suggested by @Mark-Simulacrum in rust-lang#161868. I finally figured out why my earlier attempts did not work.
rust-bors Bot pushed a commit that referenced this pull request Sep 17, 2026
…uwer

Rollup of 24 pull requests

Successful merges:

 - #161596 (coretests: Add more pattern tests.)
 - #162177 (Properly implement the gpu-kernel ABI for amdgpu)
 - #162411 (Make Receiver `#[rustc_dyn_incompatible_trait]`)
 - #162760 (yeet alias new_from_def_id)
 - #162796 (libtest: do not early exit from test runners)
 - #162844 (Add loan reachability traces to polonius MIR dumps)
 - #162876 (Move operations out of `rustc_middle::query::job`)
 - #160108 (Stabilize `windows_process_extensions_main_thread_handle`)
 - #160212 (traits: Fix rigid alias liveness matching)
 - #160544 (Stabilize `feature(trim_prefix_suffix)` (`{str, [T], Path}::trim_prefix` and `{str, [T]}::trim_suffix`))
 - #161305 (Use the entire type of a dropped local to compute variance (edge direction) for Polonius alpha)
 - #161838 (tests: accept LLVM 24 optimization in this test)
 - #162312 (core: Rewrite docs for try_as_dyn)
 - #162785 (Avoid creating overlapping assignments in MatchBranchSimplification)
 - #162805 (Add `must_use` lint to `ExitCode`)
 - #162825 (core: Add examples for `debug_closure_helpers`)
 - #162841 (enable asm tests for xtensa targets)
 - #162842 (reintroduce check RibKind::ConstParamTy did in direct consts)
 - #162845 (mgca: fix issue with mismatched array valtree/valtree tys)
 - #162856 (Stabilize CommandExt::show_window)
 - #162865 (Complex conjugate, negation and default)
 - #162874 (Add support for `annotate_snippets::snippet::AnnotationKind::Visible`)
 - #162881 (Simplify the macro for forwarding Decoder methods )
 - #162888 (Fix a typo on the Armv7-R platform docs page)
rust-bors Bot pushed a commit that referenced this pull request Sep 17, 2026
…uwer

Rollup of 23 pull requests

Successful merges:

 - #161596 (coretests: Add more pattern tests.)
 - #162411 (Make Receiver `#[rustc_dyn_incompatible_trait]`)
 - #162760 (yeet alias new_from_def_id)
 - #162796 (libtest: do not early exit from test runners)
 - #162844 (Add loan reachability traces to polonius MIR dumps)
 - #162876 (Move operations out of `rustc_middle::query::job`)
 - #160108 (Stabilize `windows_process_extensions_main_thread_handle`)
 - #160212 (traits: Fix rigid alias liveness matching)
 - #160544 (Stabilize `feature(trim_prefix_suffix)` (`{str, [T], Path}::trim_prefix` and `{str, [T]}::trim_suffix`))
 - #161305 (Use the entire type of a dropped local to compute variance (edge direction) for Polonius alpha)
 - #161838 (tests: accept LLVM 24 optimization in this test)
 - #162312 (core: Rewrite docs for try_as_dyn)
 - #162785 (Avoid creating overlapping assignments in MatchBranchSimplification)
 - #162805 (Add `must_use` lint to `ExitCode`)
 - #162825 (core: Add examples for `debug_closure_helpers`)
 - #162841 (enable asm tests for xtensa targets)
 - #162842 (reintroduce check RibKind::ConstParamTy did in direct consts)
 - #162845 (mgca: fix issue with mismatched array valtree/valtree tys)
 - #162856 (Stabilize CommandExt::show_window)
 - #162865 (Complex conjugate, negation and default)
 - #162874 (Add support for `annotate_snippets::snippet::AnnotationKind::Visible`)
 - #162881 (Simplify the macro for forwarding Decoder methods )
 - #162888 (Fix a typo on the Armv7-R platform docs page)
@rust-bors
rust-bors Bot merged commit 757cb99 into rust-lang:main Sep 17, 2026
14 checks passed
@rustbot rustbot added this to the 1.100.0 milestone Sep 17, 2026
rust-bors Bot pushed a commit that referenced this pull request Sep 17, 2026
Rollup merge of #162796 - RalfJung:libtest-no-early-exit, r=oli-obk

libtest: do not early exit from test runners

Suggested by @Mark-Simulacrum in #161868. I finally figured out why my earlier attempts did not work.
@ranger-ross

Copy link
Copy Markdown
Member

I think this change has caused Cargo's build-std CI check to start failing on all PRs. (example)

error[E0463]: can't find crate for `test`

It's not clear to me if its an issue with rustc or if Cargo's tests should be updated

@RalfJung

Copy link
Copy Markdown
Member Author

Hm, that is strange.
Are these tests using the #[test_runner] attribute? Reading the diff now it seems like previously we never imported the test crate if that attribute was set, now we do.

@ranger-ross

Copy link
Copy Markdown
Member

Looking at the failing test, it specifically for custom test harnesses.

#![no_std]
#![cfg_attr(test, no_main)]
#![feature(custom_test_frameworks)]
#![test_runner(crate::test_runner)]

pub fn test_runner(_tests: &[&dyn Fn()]) {}

#[panic_handler]
fn panic(_info: &core::panic::PanicInfo) -> ! {
    loop {}
}

@RalfJung

RalfJung commented Sep 18, 2026

Copy link
Copy Markdown
Member Author

Ah, makes sense then.

I suspect adding a #[test] would make it fail even without this PR as that requires extern crate test;...
Also the signature for test_runner seems wrong, we are passing a slice of &TestDescAndFn, not &dyn Fn.

EDIT: Ah, you're supposed to use #[test_case], not #[test], with a custom runner. Then you can pick ~any type signature. #162971 adds a pretty-printing test based on the unstable book so we can at least see that there was an unnecessary extern crate test;.

JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Sep 19, 2026
…ieyouxu

libtest harness: avoid 'extern crate test' with custom runner

This might fix the regression reported in rust-lang#162796 (comment).
rust-bors Bot pushed a commit that referenced this pull request Sep 19, 2026
Rollup merge of #162971 - RalfJung:libtest-extern-crate, r=jieyouxu

libtest harness: avoid 'extern crate test' with custom runner

This might fix the regression reported in #162796 (comment).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-rustc-dev-guide Area: rustc-dev-guide S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants