Skip to content

parse inline and rustc_force_inline with same parser - #164648

Open
mejrs wants to merge 1 commit into
rust-lang:mainfrom
mejrs:inline_parser
Open

mejrs wants to merge 1 commit into
rust-lang:mainfrom
mejrs:inline_parser

Conversation

@mejrs

@mejrs mejrs commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

It's an error to have #[inline]#[rustc_force_inline]fn blah(){}, but they both lower to the same InlineAttr, so this would error and then have an attribute list of multiple inline attrs, which breaks the invariant that a list of attributes has no duplicate variants

It's an error to have `#[inline]#[rustc_force_inline]fn blah(){}`, but they both lower to the same `InlineAttr`, so this would error and then have an attribute list of multiple inline attrs
@rustbot

rustbot commented Oct 20, 2026

Copy link
Copy Markdown
Collaborator

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 Oct 20, 2026
@rustbot

rustbot commented Oct 20, 2026

Copy link
Copy Markdown
Collaborator

r? @jackh726

rustbot has assigned @jackh726.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 77 candidates
  • Random selection from 19 candidates

@JonathanBrouwer

Copy link
Copy Markdown
Member

r? me

@rustbot rustbot assigned JonathanBrouwer and unassigned jackh726 Oct 25, 2026
@rust-bors

rust-bors Bot commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

☔ The latest upstream changes (presumably #164894) made this pull request unmergeable. Please resolve the merge conflicts by rebasing.

@JonathanBrouwer JonathanBrouwer left a comment •

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.

which breaks the invariant that a list of attributes has no duplicate variants

I'm leaning towards that that's fine, since one of the attributes is rustc internal and the broken invariant is not really observable. Imo this change makes the code less readable. What is the concrete advantage of this change?

Another approach would be replacing rustc_inline_force with #[inline(rustc_force)] or similar, then we can have only one attribute.

View changes since this review

@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 Oct 26, 2026
@mejrs

mejrs commented Oct 26, 2026

Copy link
Copy Markdown
Member Author

I wanted to add a (debug) assertion to check for no duplicates (except doc comments) in #164260, but hit it for a rustc_force_inline test instead.

Another approach would be replacing rustc_inline_force with #[inline(rustc_force)] or similar, then we can have only one attribute.

The downside of having #[inline(rustc_force)] (or #[inline(force)]) is that this sort of looks like it's on a path towards stabilization, which IIRC it is very much not.

@JonathanBrouwer

Copy link
Copy Markdown
Member

I wanted to add a (debug) assertion to check for no duplicates (except doc comments) in #164260, but hit it for a rustc_force_inline test instead.

Another way would be to also add a similar exception for inline, or to make it a delayed bug such that it is allowed when there are errors.

The downside of having #[inline(rustc_force)] (or #[inline(force)]) is that this sort of looks like it's on a path towards stabilization, which IIRC it is very much not.

Yeah I proposed rustc_force specifically so it would be clear that it's internal. Feel free to suggest another name that makes this even clearer.

This branch has not been deployed

No deployments
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.

4 participants