Skip to content

Construct tokens for attrs made by mk_attr_word and other variants#159277

Open
mu001999 wants to merge 1 commit into
rust-lang:mainfrom
mu001999-contrib:fix-159261
Open

Construct tokens for attrs made by mk_attr_word and other variants#159277
mu001999 wants to merge 1 commit into
rust-lang:mainfrom
mu001999-contrib:fix-159261

Conversation

@mu001999

@mu001999 mu001999 commented Jul 14, 2026

Copy link
Copy Markdown
Member

Fixes #159261

tokens won't be constructed for generated built-in attrs before, so that after #158854, #[rustc_test_entrypoint_marker] without tokens would be added when expanding #[test]. Then later expansions would cause the ICE when they wanna get the attr's tokens.

This PR makes tokens constructed for such attrs, although this specific ICE only need editing mk_attr_word, but I think it would be good to also edit mk_attr_nested_word and mk_attr_name_value_str.

@rustbot rustbot added 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. labels Jul 14, 2026
@mu001999 mu001999 changed the title Construct tokens for attrs made by mk_attr_word and other variants Construct tokens for attrs made by mk_attr_word and other variants Jul 14, 2026
@jdonszelmann

Copy link
Copy Markdown
Contributor

r? me

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

It's a big fix, but I think it actually addresses multiple longstanding issues. EIIs do the same, where they generate attributes, and I'm sure it was secretly vulnerable to the same ICE. Same for bench and global_allocator prolly too. I guess it's maybe even for the better we found out about this hehe, even though I guess I'm to blame for causing the regression.

Thanks @mu001999 !

r=me if you're ready @mu001999 , maybe undraft it, but I think this is a fine solution :3

View changes since this review

#[test_macros::identity_attr]
fn test() {}
}

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.

I love that you test it with macro_attr, it's a much more concise test like this

@rust-bors

rust-bors Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

📋 Only open, non-draft PRs can be approved.

@mu001999 mu001999 marked this pull request as ready for review July 14, 2026 11:02
@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 Jul 14, 2026
@mu001999

Copy link
Copy Markdown
Member Author

@bors r=jdonszelmann rollup

@rust-bors

rust-bors Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 29668b5 has been approved by jdonszelmann

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

Construct `tokens` for attrs made by `mk_attr_word` and other variants

Fixes rust-lang#159261

`tokens` won't be constructed for generated built-in attrs before, so that after rust-lang#158854, `#[rustc_test_entrypoint_marker]` without `tokens` would be added when expanding `#[test]`. Then later expansions would cause the ICE when they wanna get the attr's `tokens`.

This PR makes `tokens` constructed for such attrs, although this specific ICE only need editing `mk_attr_word`, but I think it would be good to also edit `mk_attr_nested_word` and `mk_attr_name_value_str`.
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jul 14, 2026
…nszelmann

Construct `tokens` for attrs made by `mk_attr_word` and other variants

Fixes rust-lang#159261

`tokens` won't be constructed for generated built-in attrs before, so that after rust-lang#158854, `#[rustc_test_entrypoint_marker]` without `tokens` would be added when expanding `#[test]`. Then later expansions would cause the ICE when they wanna get the attr's `tokens`.

This PR makes `tokens` constructed for such attrs, although this specific ICE only need editing `mk_attr_word`, but I think it would be good to also edit `mk_attr_nested_word` and `mk_attr_name_value_str`.
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jul 14, 2026
…nszelmann

Construct `tokens` for attrs made by `mk_attr_word` and other variants

Fixes rust-lang#159261

`tokens` won't be constructed for generated built-in attrs before, so that after rust-lang#158854, `#[rustc_test_entrypoint_marker]` without `tokens` would be added when expanding `#[test]`. Then later expansions would cause the ICE when they wanna get the attr's `tokens`.

This PR makes `tokens` constructed for such attrs, although this specific ICE only need editing `mk_attr_word`, but I think it would be good to also edit `mk_attr_nested_word` and `mk_attr_name_value_str`.
rust-bors Bot pushed a commit that referenced this pull request Jul 14, 2026
…uwer

Rollup of 22 pull requests

Successful merges:

 - #156047 (Fix trait method resolution on an adjusted never type)
 - #157824 (Comptime inherent impls)
 - #158235 (Store `DefId` instead of `EiiDecl` in `EiiImplResolution::Known`)
 - #158723 (Support EII on Windows MSVC)
 - #158993 (rerun in original typing mode if we meet any opaques in post analysis)
 - #159160 (Make `HasTokens` a sub-trait of `HasAttrs`.)
 - #159183 (Introduce InstanceKind::LlvmIntrinsic)
 - #159251 (Bump rustc-perf submodule)
 - #155013 (Suggest the `[const] Destruct` bound for type parameters in const functions when missing)
 - #159155 (unstable book: Document `diagnostic_on_unknown` feature)
 - #159235 (Add regression test for #95719)
 - #159243 (inline Once wait and wait_force)
 - #159255 (Replace shortened type with `_` instead of `...` as placeholder)
 - #159259 (Add regression test for #144033)
 - #159265 (bootstrap: skip intrinsic-test when rustfmt is unavailable)
 - #159269 (disable range-len-try-from.rs on s390x)
 - #159272 (slice: make swap delegate to swap_unchecked)
 - #159274 (bootstrap: Rename `std_crates_for_run_make` to `std_crates_for_make_run`)
 - #159275 (remove obsolete comment)
 - #159277 (Construct `tokens` for attrs made by `mk_attr_word` and other variants)
 - #159283 (Remove obsolete verbose flag from deref/ref suggestions)
 - #159290 (rustc-dev-guide subtree update)
wjones127 pushed a commit to lance-format/lance that referenced this pull request Jul 14, 2026
Fixes #7786.

Rust `nightly-2026-07-14` introduced rust-lang/rust#159261, which makes
`linux-build` deterministically ICE while expanding a `#[test]` followed
by an attribute macro. Lance hits this in the `lance-encoding` test
binary before any tests execute, and the same failure is present on
`main`.

Pin the job's toolchain installation and `cargo llvm-cov` invocation to
the last known-good `nightly-2026-07-13`. This is a temporary CI
mitigation; restore the floating nightly after a dated release
containing rust-lang/rust#159277 passes the reproduction and the full
job.
rust-bors Bot pushed a commit that referenced this pull request Jul 15, 2026
…uwer

Rollup of 22 pull requests

Successful merges:

 - #156047 (Fix trait method resolution on an adjusted never type)
 - #157824 (Comptime inherent impls)
 - #158235 (Store `DefId` instead of `EiiDecl` in `EiiImplResolution::Known`)
 - #158723 (Support EII on Windows MSVC)
 - #158993 (rerun in original typing mode if we meet any opaques in post analysis)
 - #159160 (Make `HasTokens` a sub-trait of `HasAttrs`.)
 - #159183 (Introduce InstanceKind::LlvmIntrinsic)
 - #159251 (Bump rustc-perf submodule)
 - #155013 (Suggest the `[const] Destruct` bound for type parameters in const functions when missing)
 - #159155 (unstable book: Document `diagnostic_on_unknown` feature)
 - #159235 (Add regression test for #95719)
 - #159243 (inline Once wait and wait_force)
 - #159255 (Replace shortened type with `_` instead of `...` as placeholder)
 - #159259 (Add regression test for #144033)
 - #159265 (bootstrap: skip intrinsic-test when rustfmt is unavailable)
 - #159269 (disable range-len-try-from.rs on s390x)
 - #159272 (slice: make swap delegate to swap_unchecked)
 - #159274 (bootstrap: Rename `std_crates_for_run_make` to `std_crates_for_make_run`)
 - #159275 (remove obsolete comment)
 - #159277 (Construct `tokens` for attrs made by `mk_attr_word` and other variants)
 - #159283 (Remove obsolete verbose flag from deref/ref suggestions)
 - #159290 (rustc-dev-guide subtree update)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

[ICE]: "attribute is missing tokens" on #[test] #[procmacro]

3 participants