Skip to content

Add #[rustc_test_entrypoint_marker]#158854

Open
jdonszelmann wants to merge 3 commits into
rust-lang:mainfrom
jdonszelmann:test-entrypoint
Open

Add #[rustc_test_entrypoint_marker]#158854
jdonszelmann wants to merge 3 commits into
rust-lang:mainfrom
jdonszelmann:test-entrypoint

Conversation

@jdonszelmann

@jdonszelmann jdonszelmann commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

r? @JonathanBrouwer

cc: @Nadrieril @N1ark @aDotInTheVoid

Some context: a bunch of tooling around rustc likes to find entry points. This is easy for main, it's a lang item. But tests aren't as easy. There is already a similar marker for the data structure associated with tests, but if you want to do for example dynamic analysis, you want just the defid of the function you can call to start the tests. This is that marker. There's a test using a rustc driver that the attr indeed shows up and marks the test functions.

@Nadrieril and @N1ark asked for this kind of behavior. I talked to @aDotInTheVoid about whether we should do things like this where we cannot really guarantee the stability or even use it inside rustc. The thing is, we don't provide staboility guarantees, it's just a useful little thing to have for as long as its there and it doesn't bother anyone either. It's up to tool authors to deal with breakage we may introduce.

@rustbot

rustbot commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred in compiler/rustc_hir/src/attrs

cc @JonathanBrouwer

Some changes occurred in compiler/rustc_attr_parsing

cc @JonathanBrouwer

Some changes occurred in compiler/rustc_passes/src/check_attr.rs

cc @JonathanBrouwer

@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 6, 2026
@rustbot

rustbot commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

JonathanBrouwer is currently at their maximum review capacity.
They may take a while to respond.

@rust-log-analyzer

This comment has been minimized.

@JonathanBrouwer

Copy link
Copy Markdown
Contributor

(this might take me a few days to get to, should have time to take a look on friday)

@JonathanBrouwer JonathanBrouwer left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rust-bors

rust-bors Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 0133252 has been approved by JonathanBrouwer

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 Jul 10, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jul 10, 2026
…nathanBrouwer

Add `#[rustc_test_entrypoint_marker]`

r? @JonathanBrouwer

cc: @Nadrieril @N1ark @aDotInTheVoid

Some context: a bunch of tooling around rustc likes to find entry points. This is easy for `main`, it's a lang item. But tests aren't as easy. There is already a similar marker for the data structure associated with tests, but if you want to do for example dynamic analysis, you want just the defid of the function you can call to start the tests. This is that marker. There's a test using a rustc driver that the attr indeed shows up and marks the test functions.

@Nadrieril and @N1ark asked for this kind of behavior. I talked to @aDotInTheVoid about whether we should do things like this where we cannot really guarantee the stability or even use it inside rustc. The thing is, we don't provide staboility guarantees, it's just a useful little thing to have for as long as its there and it doesn't bother anyone either. It's up to tool authors to deal with breakage we may introduce.
rust-bors Bot pushed a commit that referenced this pull request Jul 10, 2026
…uwer

Rollup of 7 pull requests

Successful merges:

 - #157690 (codegen_ssa: pack small const aggregates into immediate stores)
 - #159005 (Use `as_lang_item` instead of repeatedly matching)
 - #156735 (Move NativeLib::filename to the rmeta-link archive member)
 - #158732 (Apply MCP 1003 and move diagnostics.rs into its own module)
 - #158854 (Add `#[rustc_test_entrypoint_marker]`)
 - #158965 (Add codegen test for Result is_ok unwrap)
 - #159050 (assert only opaques with sub unified hidden infer are non-rigid)
@JonathanBrouwer

Copy link
Copy Markdown
Contributor

💔 I suspect this PR failed tests as part of a rollup
@bors r-

After fixing the problem, consider running a try job for the failed job before re-approving.

Link to failure: #159068 (comment)

@rust-bors rust-bors Bot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jul 10, 2026
@rust-bors

rust-bors Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

This pull request was unapproved.

This PR was contained in a rollup (#159068), which was unapproved.

View changes since this unapproval

path.to_string(),
];
rustc_driver::catch_fatal_errors(|| -> interface::Result<()> {
rustc_driver::run_compiler(&args, &mut TestAttr { expected_tests });

@Nadrieril Nadrieril Jul 10, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we can run this twice. There's a test that ensures that running interface::run_compiler twice works, but that's a different entrypoint

View changes since the review

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's the only thing I can see, otherwise the test looks like the other rustc_driver tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-attributes Area: Attributes (`#[…]`, `#![…]`) S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler 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