Skip to content

disallow most attrs on eiis#157312

Open
jdonszelmann wants to merge 2 commits into
rust-lang:mainfrom
jdonszelmann:reject-attrs-eii
Open

disallow most attrs on eiis#157312
jdonszelmann wants to merge 2 commits into
rust-lang:mainfrom
jdonszelmann:reject-attrs-eii

Conversation

@jdonszelmann
Copy link
Copy Markdown
Contributor

@jdonszelmann jdonszelmann commented Jun 2, 2026

Most attributes do not make sense on EIIs. Whether they're copied to the macro, default, or foreign item is also highly dependent per attribute.

I was thinking of ways to configure this, though I don't think we need that kind of complexity rn. For now I just reject them all, except for ones that obviously make sense or are necessary for current usage in std.

user attr macros are blanket-rejected with this too, which seems good, it seems cursed to present expanded eiis to them.

r? @JonathanBrouwer

@rustbot rustbot added 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 Jun 2, 2026
Comment thread compiler/rustc_builtin_macros/src/errors.rs
@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 Jun 2, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Jun 2, 2026

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@jdonszelmann jdonszelmann force-pushed the reject-attrs-eii branch 2 times, most recently from 94898ec to a492d4f Compare June 2, 2026 14:32
@jdonszelmann
Copy link
Copy Markdown
Contributor Author

@rustbot review

better?

@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 Jun 2, 2026
@jdonszelmann
Copy link
Copy Markdown
Contributor Author

I don't think an exhaustive test is too useful, this just tests some of the behavior. An exhaustive test just means we duplicate the logic here and in the macro. I do recommend people to add tests if they depend on specific attrs being enabled I guess

Copy link
Copy Markdown
Contributor

@JonathanBrouwer JonathanBrouwer left a comment

Choose a reason for hiding this comment

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

@bors r+ rollup
Makes sense, thanks!

View changes since this review

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented Jun 2, 2026

📌 Commit a492d4f has been approved by JonathanBrouwer

It is now in the queue for this repository.

🌲 The tree is currently closed for pull requests below priority 5. This pull request will be tested once the tree is reopened.

@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 Jun 2, 2026
@boozook
Copy link
Copy Markdown

boozook commented Jun 2, 2026

Just one question: what if I need to define link-section or symbol-name for eii-definition, as well same for default eii-impl?
I mean could be awesome to be able strictly define these attrs for eii-definition, and all implementations to inherit attrs of their definitions.

Use-case: entry-points, allocators, panic, any global or layout-depending things in embedded and custom targets.

JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jun 2, 2026
…onathanBrouwer

disallow most attrs on eiis

Most attributes do not make sense on EIIs. Whether they're copied to the macro, default, or foreign item is also highly dependent per attribute.

I was thinking of ways to configure this, though I don't think we need that kind of complexity rn. For now I just reject them all, except for ones that obviously make sense or are necessary for current usage in std.

user attr macros are blanket-rejected with this too, which seems good, it seems cursed to present expanded eiis to them.

r? @JonathanBrouwer
rust-bors Bot pushed a commit that referenced this pull request Jun 2, 2026
…uwer

Rollup of 6 pull requests

Successful merges:

 - #155418 (transmute: fix check for whether newtypes have equal size)
 - #156603 (Clarify E0381 diagnostics for branch conditions)
 - #156643 (Document run-make external dependencies)
 - #157009 (Avoid `unreachable_code` on required return values)
 - #157308 (make typing mode exhaustive again...)
 - #157312 (disallow most attrs on eiis)
rust-bors Bot pushed a commit that referenced this pull request Jun 2, 2026
…uwer

Rollup of 6 pull requests

Successful merges:

 - #155418 (transmute: fix check for whether newtypes have equal size)
 - #156603 (Clarify E0381 diagnostics for branch conditions)
 - #156643 (Document run-make external dependencies)
 - #157009 (Avoid `unreachable_code` on required return values)
 - #157308 (make typing mode exhaustive again...)
 - #157312 (disallow most attrs on eiis)
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.

4 participants