Skip to content

Revert "Add rustc_test_entrypoint_marker" - #161931

Merged
rust-bors[bot] merged 4 commits into
rust-lang:mainfrom
JonathanBrouwer:revert-test-entry-point
Aug 31, 2026
Merged

Revert "Add rustc_test_entrypoint_marker"#161931
rust-bors[bot] merged 4 commits into
rust-lang:mainfrom
JonathanBrouwer:revert-test-entry-point

Conversation

@JonathanBrouwer

@JonathanBrouwer JonathanBrouwer commented Aug 28, 2026

Copy link
Copy Markdown
Member

Reverts #158854 because it caused two beta regressions
Revert required some minor solving of conflicts
We can think about re-landing it after

Fixes #161920
Fixes #161917

cc: @Nadrieril @N1ark @aDotInTheVoid @jdonszelmann

@rustbot

rustbot commented Aug 28, 2026

Copy link
Copy Markdown
Collaborator

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

cc @jdonszelmann

Some changes occurred in compiler/rustc_attr_ir

cc @jdonszelmann

Some changes occurred in compiler/rustc_attr_parsing

cc @jdonszelmann

@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 Aug 28, 2026
@rustbot

rustbot commented Aug 28, 2026

Copy link
Copy Markdown
Collaborator

r? @dingxiangfei2009

rustbot has assigned @dingxiangfei2009.
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 75 candidates
  • Random selection from 19 candidates

@N1ark

N1ark commented Aug 28, 2026

Copy link
Copy Markdown
Member

this is really unfortunate :( i wonder if we can fix this later; #161920 seems to just be an issue in the test_retry macro that needs fixing anyways, but idk what to do about #161917

@JonathanBrouwer

Copy link
Copy Markdown
Member Author

Yeah #161917 is the annoying one of the two.
For beta the safe thing to do is just to revert.
For on nightly we might be able to re-land this as a synthetic attribute? I'd love to find a way to still have this without breakage

@mejrs

mejrs commented Aug 28, 2026

Copy link
Copy Markdown
Member

Consider also cases like

#![feature(macro_metavar_expr_concat)]
#![feature(macro_attr)]

macro_rules! ohno {
    attr() { $(#[$a:meta])* fn $name:ident () $body: block } => {
        $(#[$a])*
        fn ${ concat(not_, $name) }() $body
    }
}

#[ohno]
#[test]
fn works() {}

#[test]
#[ohno]
fn no_works() {}
error[E0658]: use of an internal attribute
  --> src/lib.rs:15:1
   |
15 | #[test]
   | ^^^^^^^
   |
   = help: add `#![feature(rustc_attrs)]` to the crate attributes to enable
   = note: the `rustc_test_entrypoint_marker` attribute is an internal implementation detail that will never be stable

error[E0425]: cannot find function `no_works` in this scope
  --> src/lib.rs:17:1
   |
17 | fn no_works() {}
   | ^^^^^^^^^^^^^^^^
   | |
   | you might have meant to refer to this constant
   | not found in this scope

So it was already possible to combine misbehaving attribute macros and #[test] to create malformed output.

Another way to fix this and these issues is to make the test macro reorder itself, i.e. for

#[test] // not last
#[ohno]
fn blah() {}

we expand into

#[ohno]
#[test] // last!
fn blah() {}

@mejrs mejrs 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.

The following also does not work (despite not being weird) , can you add it as a test case?

#![feature(macro_attr)]

macro_rules! ohno {
    attr() { $(#[$a:meta])* fn $name:ident () $body: block } => {
        $(#[$a])*
        fn $name () $body
    }
}

#[test]
#[ohno]
fn my_test() {}

produces:

error[E0658]: use of an internal attribute
  --> src/lib.rs:10:1
   |
10 | #[test]
   | ^^^^^^^
   |
   = help: add `#![feature(rustc_attrs)]` to the crate attributes to enable
   = note: the `rustc_test_entrypoint_marker` attribute is an internal implementation detail that will never be stable

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

View changes since this review

@rustbot rustbot 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-review Status: Awaiting review from the assignee but also interested parties. labels Aug 28, 2026
@JonathanBrouwer

JonathanBrouwer commented Aug 30, 2026

Copy link
Copy Markdown
Member Author

Good idea! Added
@rustbot ready

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

@mejrs mejrs 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

r=me with test fixed

View changes since this review

@@ -0,0 +1,17 @@
//@ check-pass

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.

Suggested change
//@ check-pass
//@ check-pass
//@ compile-flags: --test

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 whooops that's terrible, thanks for catching that!

@rustbot rustbot assigned mejrs and unassigned dingxiangfei2009 Aug 30, 2026
@JonathanBrouwer
JonathanBrouwer force-pushed the revert-test-entry-point branch from 7418683 to 9b70ab0 Compare August 30, 2026 17:19
@JonathanBrouwer

JonathanBrouwer commented Aug 30, 2026

Copy link
Copy Markdown
Member Author

Confirmed that the test now fails before the revert.
@bors r=mejrs rollup

@rust-bors

rust-bors Bot commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 9b70ab0 has been approved by mejrs

It is now in the queue for this repository.

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

Revert "Add rustc_test_entrypoint_marker"

Reverts rust-lang#158854 because it caused two beta regressions
Revert required some minor solving of conflicts
We can think about re-landing it after

Fixes rust-lang#161920
Fixes rust-lang#161917

cc: @Nadrieril @N1ark @aDotInTheVoid @jdonszelmann
rust-bors Bot pushed a commit that referenced this pull request Aug 30, 2026
…uwer

Rollup of 8 pull requests

Successful merges:

 - #137720 (support `#[target_feature(enable = ...)]` on `#[naked]` functions)
 - #160923 (Handle multiple action records in EH personality function)
 - #161788 (Check to ensure we're running against the correct LLVM version)
 - #161644 (bootstrap: Flatten and rename `compute_src_directory_via_git`)
 - #161702 (Use `drop_guard` in some places in {core,alloc,std})
 - #161931 (Revert "Add rustc_test_entrypoint_marker")
 - #162015 (touch up "get attribute" docs.)
 - #162019 (remove a couple of redundant clones, thanks clippy)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Aug 30, 2026
…point, r=mejrs

Revert "Add rustc_test_entrypoint_marker"

Reverts rust-lang#158854 because it caused two beta regressions
Revert required some minor solving of conflicts
We can think about re-landing it after

Fixes rust-lang#161920
Fixes rust-lang#161917

cc: @Nadrieril @N1ark @aDotInTheVoid @jdonszelmann
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Aug 30, 2026
…point, r=mejrs

Revert "Add rustc_test_entrypoint_marker"

Reverts rust-lang#158854 because it caused two beta regressions
Revert required some minor solving of conflicts
We can think about re-landing it after

Fixes rust-lang#161920
Fixes rust-lang#161917

cc: @Nadrieril @N1ark @aDotInTheVoid @jdonszelmann
rust-bors Bot pushed a commit that referenced this pull request Aug 30, 2026
…uwer

Rollup of 11 pull requests

Successful merges:

 - #160923 (Handle multiple action records in EH personality function)
 - #161788 (Check to ensure we're running against the correct LLVM version)
 - #158303 (Always escape grapheme extenders in `str::escape_debug`)
 - #161644 (bootstrap: Flatten and rename `compute_src_directory_via_git`)
 - #161702 (Use `drop_guard` in some places in {core,alloc,std})
 - #161713 (Add config for gram editor to .gitignore)
 - #161792 (Fix and improve diagnostics for lint `rust_2021_prefixes_incompatible_syntax`)
 - #161931 (Revert "Add rustc_test_entrypoint_marker")
 - #162015 (touch up "get attribute" docs.)
 - #162019 (remove a couple of redundant clones, thanks clippy)
 - #162023 (Remove redundant braces from `NonZero` doctests)
rust-bors Bot pushed a commit that referenced this pull request Aug 30, 2026
…uwer

Rollup of 11 pull requests

Successful merges:

 - #160923 (Handle multiple action records in EH personality function)
 - #161788 (Check to ensure we're running against the correct LLVM version)
 - #158303 (Always escape grapheme extenders in `str::escape_debug`)
 - #161644 (bootstrap: Flatten and rename `compute_src_directory_via_git`)
 - #161702 (Use `drop_guard` in some places in {core,alloc,std})
 - #161713 (Add config for gram editor to .gitignore)
 - #161792 (Fix and improve diagnostics for lint `rust_2021_prefixes_incompatible_syntax`)
 - #161931 (Revert "Add rustc_test_entrypoint_marker")
 - #162015 (touch up "get attribute" docs.)
 - #162019 (remove a couple of redundant clones, thanks clippy)
 - #162023 (Remove redundant braces from `NonZero` doctests)
@rust-bors
rust-bors Bot merged commit e36bc49 into rust-lang:main Aug 31, 2026
13 checks passed
@rustbot rustbot added this to the 1.100.0 milestone Aug 31, 2026
rust-bors Bot pushed a commit that referenced this pull request Aug 31, 2026
Rollup merge of #161931 - JonathanBrouwer:revert-test-entry-point, r=mejrs

Revert "Add rustc_test_entrypoint_marker"

Reverts #158854 because it caused two beta regressions
Revert required some minor solving of conflicts
We can think about re-landing it after

Fixes #161920
Fixes #161917

cc: @Nadrieril @N1ark @aDotInTheVoid @jdonszelmann
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-attributes Area: Attributes (`#[…]`, `#![…]`) beta-nominated Nominated for backporting to the compiler in the beta channel. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

1.99 beta crater regression: expected item after attributes 1.99 beta crater regression: use of an internal attribute

5 participants