Skip to content

parse inline and rustc_force_inline with same parser - #164648

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
mejrs:inline_parser
Oct 28, 2026
Merged

rust-bors[bot] merged 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

@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

This comment has been minimized.

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

@mejrs

mejrs commented Oct 26, 2026

Copy link
Copy Markdown
Member Author

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.

Or we could just fix the attribute? 🤷

In any case, I don't think folding it into the inline attribute would significantly clean this up.

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 26, 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.

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

In any case, I don't think folding it into the inline attribute would significantly clean this up.

This PR has to do manual target and duplication, which the single attribute would not have to do.

Or we could just fix the attribute? 🤷

Sure, I'm relatively neutral on whether this change is an improvement, and you seem to really like it, so let's do it.
Do we also want to combine all DocAttrs to make the check fully consistent?

@bors r+ rollup

View changes since this review

@rust-bors

rust-bors Bot commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

📌 Commit b749d20 has been approved by JonathanBrouwer

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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 27, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Oct 27, 2026
…uwer

parse inline and rustc_force_inline with same parser

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
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Oct 27, 2026
…uwer

parse inline and rustc_force_inline with same parser

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
rust-bors Bot pushed a commit that referenced this pull request Oct 27, 2026
…uwer

Rollup of 22 pull requests

Successful merges:

 - #159580 (Reject cfg on expressions that cannot be safely removed)
 - #162597 (raise ambiguity error on attribute macro that could be tool attribute)
 - #162808 (Enable `--generate-link-to-definition` rustdoc option on std docs)
 - #163059 (Recover invalid return type until `{`, `}` or `;`)
 - #163672 (Use runCodeGen Abstraction for new LLVM)
 - #164028 (Add a future incompat warning for #[no_link])
 - #164188 (Suggest adding lifetime for `dyn Trait` in return type)
 - #164345 (fix: handle `false` in root contexts)
 - #164494 (drop ands which are a superset of other ands)
 - #164766 (Unstably introduce MVP edition migration lint `unmarked_unchecked_type_aliases` together with bikeshed attribute `#[rustc_unchecked_type_alias]`)
 - #164785 (delegation: emit error when there is no field for `Self` mapping)
 - #164799 (Don't use `IntoIterator` in parallel API)
 - #164871 (Refactor call argument codegen)
 - #164648 (parse inline and rustc_force_inline with same parser)
 - #164811 (fix: Prevent ICE when comparing EII impl against generic declaration)
 - #164900 (make tool_attrs method to retrieve tool attributes.)
 - #164993 (copy_nonoverlapping: dont skip ovelrap check when src is fully uninit)
 - #164996 (miri: add missing alignment check in write_bytes)
 - #165012 (Remove Span::eq_ctxt())
 - #165013 ([tiny] Add missing backticks around lifetime name)
 - #165024 (rustdoc-search: rank re-export lower)
 - #165028 (Update enzyme to fix one bug related to higher-order derivatives)

> [!WARNING]
> This rollup conflicts with pending auto build #165042 and may need to be recreated if the pending build succeeds.
rust-bors Bot pushed a commit that referenced this pull request Oct 27, 2026
…uwer

Rollup of 21 pull requests

Successful merges:

 - #159580 (Reject cfg on expressions that cannot be safely removed)
 - #162597 (raise ambiguity error on attribute macro that could be tool attribute)
 - #162808 (Enable `--generate-link-to-definition` rustdoc option on std docs)
 - #163059 (Recover invalid return type until `{`, `}` or `;`)
 - #163672 (Use runCodeGen Abstraction for new LLVM)
 - #164028 (Add a future incompat warning for #[no_link])
 - #164188 (Suggest adding lifetime for `dyn Trait` in return type)
 - #164345 (fix: handle `false` in root contexts)
 - #164494 (drop ands which are a superset of other ands)
 - #164785 (delegation: emit error when there is no field for `Self` mapping)
 - #164799 (Don't use `IntoIterator` in parallel API)
 - #164871 (Refactor call argument codegen)
 - #164648 (parse inline and rustc_force_inline with same parser)
 - #164811 (fix: Prevent ICE when comparing EII impl against generic declaration)
 - #164900 (make tool_attrs method to retrieve tool attributes.)
 - #164993 (copy_nonoverlapping: dont skip ovelrap check when src is fully uninit)
 - #164996 (miri: add missing alignment check in write_bytes)
 - #165012 (Remove Span::eq_ctxt())
 - #165013 ([tiny] Add missing backticks around lifetime name)
 - #165024 (rustdoc-search: rank re-export lower)
 - #165028 (Update enzyme to fix one bug related to higher-order derivatives)
rust-bors Bot pushed a commit that referenced this pull request Oct 28, 2026
…uwer

Rollup of 21 pull requests

Successful merges:

 - #159580 (Reject cfg on expressions that cannot be safely removed)
 - #162597 (raise ambiguity error on attribute macro that could be tool attribute)
 - #162808 (Enable `--generate-link-to-definition` rustdoc option on std docs)
 - #163059 (Recover invalid return type until `{`, `}` or `;`)
 - #163672 (Use runCodeGen Abstraction for new LLVM)
 - #164028 (Add a future incompat warning for #[no_link])
 - #164188 (Suggest adding lifetime for `dyn Trait` in return type)
 - #164345 (fix: handle `false` in root contexts)
 - #164494 (drop ands which are a superset of other ands)
 - #164785 (delegation: emit error when there is no field for `Self` mapping)
 - #164799 (Don't use `IntoIterator` in parallel API)
 - #164871 (Refactor call argument codegen)
 - #164648 (parse inline and rustc_force_inline with same parser)
 - #164811 (fix: Prevent ICE when comparing EII impl against generic declaration)
 - #164900 (make tool_attrs method to retrieve tool attributes.)
 - #164993 (copy_nonoverlapping: dont skip ovelrap check when src is fully uninit)
 - #164996 (miri: add missing alignment check in write_bytes)
 - #165012 (Remove Span::eq_ctxt())
 - #165013 ([tiny] Add missing backticks around lifetime name)
 - #165024 (rustdoc-search: rank re-export lower)
 - #165028 (Update enzyme to fix one bug related to higher-order derivatives)
rust-bors Bot pushed a commit that referenced this pull request Oct 28, 2026
…uwer

Rollup of 21 pull requests

Successful merges:

 - #159580 (Reject cfg on expressions that cannot be safely removed)
 - #162597 (raise ambiguity error on attribute macro that could be tool attribute)
 - #162808 (Enable `--generate-link-to-definition` rustdoc option on std docs)
 - #163059 (Recover invalid return type until `{`, `}` or `;`)
 - #163672 (Use runCodeGen Abstraction for new LLVM)
 - #164028 (Add a future incompat warning for #[no_link])
 - #164188 (Suggest adding lifetime for `dyn Trait` in return type)
 - #164345 (fix: handle `false` in root contexts)
 - #164494 (drop ands which are a superset of other ands)
 - #164785 (delegation: emit error when there is no field for `Self` mapping)
 - #164799 (Don't use `IntoIterator` in parallel API)
 - #164871 (Refactor call argument codegen)
 - #164648 (parse inline and rustc_force_inline with same parser)
 - #164811 (fix: Prevent ICE when comparing EII impl against generic declaration)
 - #164900 (make tool_attrs method to retrieve tool attributes.)
 - #164993 (copy_nonoverlapping: dont skip ovelrap check when src is fully uninit)
 - #164996 (miri: add missing alignment check in write_bytes)
 - #165012 (Remove Span::eq_ctxt())
 - #165013 ([tiny] Add missing backticks around lifetime name)
 - #165024 (rustdoc-search: rank re-export lower)
 - #165028 (Update enzyme to fix one bug related to higher-order derivatives)
rust-bors Bot pushed a commit that referenced this pull request Oct 28, 2026
…uwer

Rollup of 21 pull requests



Successful merges:

 - #159580 (Reject cfg on expressions that cannot be safely removed)
 - #162597 (raise ambiguity error on attribute macro that could be tool attribute)
 - #162808 (Enable `--generate-link-to-definition` rustdoc option on std docs)
 - #163059 (Recover invalid return type until `{`, `}` or `;`)
 - #163672 (Use runCodeGen Abstraction for new LLVM)
 - #164028 (Add a future incompat warning for #[no_link])
 - #164188 (Suggest adding lifetime for `dyn Trait` in return type)
 - #164345 (fix: handle `false` in root contexts)
 - #164494 (drop ands which are a superset of other ands)
 - #164785 (delegation: emit error when there is no field for `Self` mapping)
 - #164799 (Don't use `IntoIterator` in parallel API)
 - #164871 (Refactor call argument codegen)
 - #164648 (parse inline and rustc_force_inline with same parser)
 - #164811 (fix: Prevent ICE when comparing EII impl against generic declaration)
 - #164900 (make tool_attrs method to retrieve tool attributes.)
 - #164993 (copy_nonoverlapping: dont skip ovelrap check when src is fully uninit)
 - #164996 (miri: add missing alignment check in write_bytes)
 - #165012 (Remove Span::eq_ctxt())
 - #165013 ([tiny] Add missing backticks around lifetime name)
 - #165024 (rustdoc-search: rank re-export lower)
 - #165028 (Update enzyme to fix one bug related to higher-order derivatives)
@rust-bors
rust-bors Bot merged commit 1641941 into rust-lang:main Oct 28, 2026
14 checks passed
@rustbot rustbot added this to the 1.101.0 milestone Oct 28, 2026
rust-bors Bot pushed a commit that referenced this pull request Oct 28, 2026
Rollup merge of #164648 - mejrs:inline_parser, r=JonathanBrouwer

parse inline and rustc_force_inline with same parser

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
darkraider01 pushed a commit to darkraider01/miri that referenced this pull request Oct 29, 2026
…uwer

Rollup of 21 pull requests



Successful merges:

 - rust-lang/rust#159580 (Reject cfg on expressions that cannot be safely removed)
 - rust-lang/rust#162597 (raise ambiguity error on attribute macro that could be tool attribute)
 - rust-lang/rust#162808 (Enable `--generate-link-to-definition` rustdoc option on std docs)
 - rust-lang/rust#163059 (Recover invalid return type until `{`, `}` or `;`)
 - rust-lang/rust#163672 (Use runCodeGen Abstraction for new LLVM)
 - rust-lang/rust#164028 (Add a future incompat warning for #[no_link])
 - rust-lang/rust#164188 (Suggest adding lifetime for `dyn Trait` in return type)
 - rust-lang/rust#164345 (fix: handle `false` in root contexts)
 - rust-lang/rust#164494 (drop ands which are a superset of other ands)
 - rust-lang/rust#164785 (delegation: emit error when there is no field for `Self` mapping)
 - rust-lang/rust#164799 (Don't use `IntoIterator` in parallel API)
 - rust-lang/rust#164871 (Refactor call argument codegen)
 - rust-lang/rust#164648 (parse inline and rustc_force_inline with same parser)
 - rust-lang/rust#164811 (fix: Prevent ICE when comparing EII impl against generic declaration)
 - rust-lang/rust#164900 (make tool_attrs method to retrieve tool attributes.)
 - rust-lang/rust#164993 (copy_nonoverlapping: dont skip ovelrap check when src is fully uninit)
 - rust-lang/rust#164996 (miri: add missing alignment check in write_bytes)
 - rust-lang/rust#165012 (Remove Span::eq_ctxt())
 - rust-lang/rust#165013 ([tiny] Add missing backticks around lifetime name)
 - rust-lang/rust#165024 (rustdoc-search: rank re-export lower)
 - rust-lang/rust#165028 (Update enzyme to fix one bug related to higher-order derivatives)
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-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