Merged RustcForceInline & Inline Attribute Parsers#158814
Conversation
|
Some changes occurred in compiler/rustc_attr_parsing cc @jdonszelmann, @JonathanBrouwer Some changes occurred in compiler/rustc_passes/src/check_attr.rs |
|
Thanks for the pull request, and welcome! The Rust Project is excited to review your changes, and you should hear from @folkertdev (or someone else) some time within the next two weeks. Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (
Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
bd990d8 to
15b16bb
Compare
15b16bb to
b2e4430
Compare
|
(would like to take a look at this, this might take me a few days to get to, should have time to take a look on friday) |
| | ^^^^^^^^^^^^^^^^---^^ | ||
| | | | ||
| | didn't expect any arguments here | ||
| | valid arguments are `always` or `never` |
There was a problem hiding this comment.
This change is not correct, always does not take any arguments.
This error would suggest always(always) would be valid.
Please drop that commit
There was a problem hiding this comment.
You made changes to tests that are not related to this PR, could you at the very least split these changes into individual commits, and preferably into separate PRs? It makes the diff hard to review
|
Reminder, once the PR becomes ready for a review, use |
6df20c4 to
0f6e739
Compare
This comment has been minimized.
This comment has been minimized.
0f6e739 to
9e86aa9
Compare
|
Thanks for your feedback, I've applied the new changes and removed irrelevant ones. #[inline(always = 5)]
fn foo() {}This now emits unexpected_args as you said: error[E0565]: malformed `inline` attribute input
--> /tmp/main.rs:14:1
|
14 | #[inline(always = 5)]
| ^^^^^^^^^----------^^
| |
| didn't expect any arguments hereCurrently with #[inline(always = 1)]
#[inline(always = "a")]
fn foo() {}
#[inline(always = 1)]
fn bar() {}
#[inline(always = "b")]
fn baz() {}
#[inline(always(always))]
fn buz() {}
fn main() {}(Only generates warning but compiles successfully) All of those malformed cases are covered now, with my changes. Also reviewed spans of diagnostics several times, but if there is still something that must be changed, let me know. |
b991fc5 to
61fa4a1
Compare
|
I'm still waiting for a review. |
This comment has been minimized.
This comment has been minimized.
|
Yep sorry, have been quite busy with moving recently, will get to it soon |
|
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. |
This comment has been minimized.
This comment has been minimized.
8efcf9a to
295cf46
Compare
295cf46 to
2eac322
Compare
|
Docker registry got timeout error, maybe it'd be fixed if we run the workflow again. |
|
@rustbot assign @JonathanBrouwer |
|
|
3f27f56 to
81b256f
Compare
This comment has been minimized.
This comment has been minimized.
81b256f to
436e365
Compare
This comment has been minimized.
This comment has been minimized.
…with AttributeParser
436e365 to
767b76d
Compare
|
This PR is ready to be merged now. @JonathanBrouwer |
View all comments
Merged RustcForceInline & Inline Attribute Parsers
I've been reading #153101, #131229 and I came across with this comment in
compiler/rustc_attr_parsing/src/attributes/inline.rs:Having separate
SingleAttributeParserimplementations for#[rustc_force_inline]and#[inline(...)]meant the compiler wasn't able to recognize cases where both of them were used together on the same item, for example:This case was previously considered allowed, which is not correct.
My changes replace the distinct attribute parsers with a single unified
AttributeParserimplementation forInlineParser, handling both attributes together in a single pass. By consolidating the logic, the parser now tracks the state of both attributes side-by-side using anAcceptMappingand introduces a new session diagnostic,InlineForceInlineConflict, which is explicitly triggered in thefinalizestep if a user attempts to combine them.An added benefit of catching this conflict early during the parsing phase is that it prevents downstream validation passes (like
check_attr) from triggering redundant errors on malformed or incorrectly placed attributes, which naturally cleans up and streamlines our compiler stderr output as reflected in the updated UI test baselines.This is my very first PR on rustc, and I am incredibly grateful to @hkalbasi, who heavily guided me through the codebase and helped make this change possible!
Sincerely looking for your feedback and thoughts on this, let me know if there is something need to be changed.