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

Use attribute parser for #[inline()] attribute check#162683
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.

}
scope 18 (inlined <Enumerate<std::slice::Iter<'_, T>> as Iterator>::next) {
let mut _22: std::option::Option<std::convert::Infallible>;
let mut _22: std::option::Option<!>;

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

Why does this PR update these tests? 🤔

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.

Updated by x test --bless, not sure why?

@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

@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

Copy link
Copy Markdown
Collaborator

The job test-x86_64-gnu-llvm-21 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
error[E0004]: non-exhaustive patterns: `&data_structures::AttributeKind::AlwaysGca` not covered
   --> compiler/rustc_attr_ir/src/encode_cross_crate.rs:224:15
    |
224 |         match self {
    |               ^^^^ pattern `&data_structures::AttributeKind::AlwaysGca` not covered
    |
note: `data_structures::AttributeKind` defined here
   --> compiler/rustc_attr_ir/src/data_structures.rs:780:10
    |
780 | pub enum AttributeKind {
    |          ^^^^^^^^^^^^^
...
789 |     AlwaysGca,
    |     --------- not covered
    = note: the matched value is of type `&data_structures::AttributeKind`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
    |
415 ~             WindowsSubsystem(..) => false,
416 ~             &data_structures::AttributeKind::AlwaysGca => todo!(),
    |

For more information about this error, try `rustc --explain E0004`.
[RUSTC-TIMING] rustc_attr_ir test:false 0.785
error: could not compile `rustc_attr_ir` (lib) due to 1 previous error

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