Skip to content

Use attribute parser for #[inline()] attribute check - #162683

Open
obeis wants to merge 1 commit into
rust-lang:mainfrom
obeis:check-inline
Open

obeis wants to merge 1 commit into
rust-lang:mainfrom
obeis:check-inline

Conversation

@obeis

@obeis obeis commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

@rustbot

rustbot commented Sep 12, 2026

Copy link
Copy Markdown
Collaborator

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

cc @jdonszelmann, @JonathanBrouwer

Some changes occurred in compiler/rustc_attr_parsing

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-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Sep 12, 2026
Comment on lines +66 to +76
match kind {
AttributeKind::NoMangle(..)
| AttributeKind::ExportName { .. }
| AttributeKind::RustcStdInternalSymbol
| AttributeKind::RustcEiiForeignItem
| AttributeKind::EiiImpl(..)
| AttributeKind::RustcOffloadKernel => true,
AttributeKind::Linkage(linkage, _) => *linkage != rustc_attr_ir::Linkage::Internal,
AttributeKind::Lang(item) => item.link_name().is_some(),
_ => false,
}

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

This should be implemented more rigorously, can you refactor this match into a method on AttributeKind and match exhaustively there, similar to encode_cross_crate?

(and then update its and contains_extern_indicator's doc comments to link to each other, because these must be kept in sync)

View changes since the review

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

@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 Sep 12, 2026
@rustbot

rustbot commented Sep 12, 2026

Copy link
Copy Markdown
Collaborator

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

@rustbot

rustbot commented Sep 12, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred in compiler/rustc_attr_ir

cc @jdonszelmann, @JonathanBrouwer

@obeis
obeis requested a review from mejrs September 12, 2026 21:11
LinkName { .. } => false,
LinkOrdinal { .. } => false,
LinkSection { .. } => false,
Linkage(linkage, _) => *linkage != crate::Linkage::Internal,

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

Can you also exhaustively match on Linkage here? The idea is that this should refuse to compile if anyone ever adds a new Linkage variant without updating this.

View changes since the review

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

@mejrs

mejrs commented Sep 12, 2026

Copy link
Copy Markdown
Member

Otherwise it looks good, will wait for @JonathanBrouwer for a final review

@rust-log-analyzer

This comment has been minimized.

@obeis

obeis commented Sep 13, 2026

Copy link
Copy Markdown
Contributor Author

@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 Sep 13, 2026
@rust-log-analyzer

This comment has been minimized.

@rustbot

rustbot commented Sep 17, 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.


/// Whether this attribute is an extern indicator.
///
/// Must stay in sync with [`CodegenFnAttrs::contains_extern_indicator`].

@JonathanBrouwer JonathanBrouwer Sep 18, 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.

Hmmm, I'm not a big fan that we are duplicating this logic here.
The effort done to ensure these stay in sync is good, but it would be better not do to this at all.
Can we re-implement instantiation_mode using this method instead, and then remove CodegenFnAttrs::contains_extern_indicator?

View changes since the review

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.

If we can do that, we can re-consider if we need to match exhaustively here. It might be nice to still do, but it's a lot less valuable then

@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 Sep 18, 2026
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-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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants