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`.
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