Skip to content

Add #[rustc_test_entrypoint_marker] back ! - #165879

Open
N1ark wants to merge 1 commit into
rust-lang:mainfrom
N1ark:test-entrypoint-synthetic
Open

N1ark wants to merge 1 commit into
rust-lang:mainfrom
N1ark:test-entrypoint-synthetic

Conversation

@N1ark

@N1ark N1ark commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

View all comments

Re-add the unstable and internal #[rustc_test_entrypoint_marker] (first sighted in #158854)! This is helpful for tools like Charon to translate test entry points, since once test generation is done there is no simple way of finding these: otherwise one needs to look for statics with #[rustc_test_marker], visit their body, and look for a path to a function inside that body (ugly!)

now that synthetic attributes exist doing this is simple and shouldnt cause any regressions :3 (fingers crossed)

r? jdonszelmann

LLM Disclosure: I used an LLM to research how attributes work and how to best re-add this feature :)

@rustbot

rustbot commented Nov 12, 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

Some changes occurred in compiler/rustc_attr_parsing

cc @jdonszelmann, @JonathanBrouwer

Some changes occurred in compiler/rustc_attr_ir

cc @jdonszelmann, @JonathanBrouwer

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

cc @jdonszelmann, @JonathanBrouwer

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

rustbot commented Nov 12, 2026

Copy link
Copy Markdown
Collaborator

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

Comment thread compiler/rustc_ast/src/attr/mod.rs Resolved
@N1ark N1ark changed the title Add RustcTestEntrypointMarker back ! Add #[rustc_test_entrypoint_marker] back ! Nov 12, 2026
@JonathanBrouwer

Copy link
Copy Markdown
Member

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Nov 12, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Nov 12, 2026
Add `#[rustc_test_entrypoint_marker]` back !
@rust-bors

This comment has been minimized.

@rust-bors

rust-bors Bot commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 7bab611 (7bab6110330e1fe41a554f76213f36f54ab92a9b)
Base parent: 29a5d06 (29a5d066d98b58d948d285ba22390a5f849f5938)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (7bab611): comparison URL.

Overall result: ✅ improvements - no action needed

Benchmarking means the PR may be perf-sensitive. Consider adding rollup=never if this change is not fit for rolling up.

@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.2% [-0.2%, -0.2%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.2% [-0.2%, -0.2%] 1

Max RSS (memory usage)

Results (primary -2.7%, secondary -1.0%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-2.7% [-4.8%, -1.5%] 3
Improvements ✅
(secondary)
-1.0% [-1.0%, -1.0%] 1
All ❌✅ (primary) -2.7% [-4.8%, -1.5%] 3

Cycles

Results (primary 3.4%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
3.4% [3.4%, 3.4%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 3.4% [3.4%, 3.4%] 1

Binary size

This perf run didn't have relevant results for this metric.

Bootstrap: 484.783s -> 485.111s (0.07%)
Artifact size: 406.09 MiB -> 406.07 MiB (-0.00%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Nov 12, 2026
@JonathanBrouwer

Copy link
Copy Markdown
Member

Happy to take a look at this tomorrow :)

@mejrs

mejrs commented Nov 12, 2026

Copy link
Copy Markdown
Member

This is helpful for tools like Charon to translate test entry points, since once test generation is done there is no simple way of finding these: otherwise one needs to look for statics with #[rustc_test_marker], visit their body, and look for a path to a function inside that body (ugly!)

This is also what clippy does, and it is indeed rather ugly 🤮

Comment thread compiler/rustc_ast/src/attr/mod.rs Resolved
Comment thread compiler/rustc_span/src/symbol.rs Resolved
Comment on lines +209 to +210
// Drop the test entrypoint marker -- unclear how that would interact.
AttrKind::Synthetic(SyntheticAttr::TestEntrypoint) => {}

@mejrs mejrs Nov 12, 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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

oh lmao -- i guess we need to forbid some attrs on EII

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.

Wow a rustc segfault, that is impressive tbh

Comment on lines +3667 to +3673
/// This synthetic attribute is added by the `#[test]` and `#[bench]` macros to the annotated
/// function, so that tools (e.g. rustc drivers doing analysis) can find test entry points
/// without relying on unstable details such test lowering.
///
/// The attribute is not used by rustc directly and is instead only provided as a utility for
/// out of tree users.
TestEntrypoint,

@mejrs mejrs Nov 12, 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'm not sure if it's right to have bench and test both emit the same trace attribute. It sounds confusing.

View changes since the review

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

the thought process was that you can distinguish both from the arguments (none for #[test], &mut Bencher for #[bench]), and we just want to make these items findable (and two synth attribs felt overkill). happy to remove #[bench], personally i have on use for it, idk about clippy & co

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'm happy to keep it for bench for now, the test and bench infra share a lot of internal stuff so it kinda makes sense

@N1ark
N1ark force-pushed the test-entrypoint-synthetic branch 2 times, most recently from 7ff15d4 to 6ef674a Compare November 13, 2026 09:42
@rustbot

rustbot commented Nov 13, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@rust-log-analyzer

This comment has been minimized.

@JonathanBrouwer JonathanBrouwer left a comment •

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.

r=me after ci is fixed
@rustbot author

View changes since this review

@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 13, 2026
@rustbot rustbot added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Nov 13, 2026
@N1ark
N1ark force-pushed the test-entrypoint-synthetic branch from 6ef674a to 0cfffc4 Compare November 13, 2026 12:53
@JonathanBrouwer

Copy link
Copy Markdown
Member

@bors r+ rollup

@rust-bors

rust-bors Bot commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 0cfffc4 has been tentatively approved by JonathanBrouwer

It will be put into the queue for this repository once PR CI succeeds.

@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. 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-author Status: This is awaiting some action (such as code changes or more information) from the author. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Nov 13, 2026
@rust-bors

rust-bors Bot commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

❌ Commit 0cfffc4 has been unapproved due to PR CI failure. Reapprove it with @bors r+ force if you want to ignore the failure.

View changes since this unapproval

@N1ark
N1ark force-pushed the test-entrypoint-synthetic branch from 0cfffc4 to 395e81a Compare November 13, 2026 14:01
@N1ark

N1ark commented Nov 13, 2026

Copy link
Copy Markdown
Member Author

heh this was in fact not correct

@JonathanBrouwer

Copy link
Copy Markdown
Member

@bors r+ rollup
Thanks!

@rust-bors

rust-bors Bot commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 395e81a has been tentatively approved by JonathanBrouwer

It will be put into the queue for this repository once PR CI succeeds.

@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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Nov 13, 2026
WaffleLapkin added a commit to WaffleLapkin/rust that referenced this pull request Nov 13, 2026
…=JonathanBrouwer

Add `#[rustc_test_entrypoint_marker]` back !

Re-add the unstable and internal `#[rustc_test_entrypoint_marker]` (first sighted in rust-lang#158854)! This is helpful for tools like [Charon](https://github.com/AeneasVerif/charon) to translate test entry points, since once test generation is done there is no simple way of finding these: otherwise one needs to look for statics with `#[rustc_test_marker]`, visit their body, and look for a path to a function inside that body (ugly!)

now that synthetic attributes exist doing this is simple and shouldnt cause any regressions :3 (fingers crossed)

r? jdonszelmann

This branch has not been deployed

No deployments
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-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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants