Skip to content

Lower attributes for functions without bodies - #162761

Merged
rust-bors[bot] merged 3 commits into
rust-lang:mainfrom
JonathanBrouwer:lower-param-attrs
Oct 4, 2026
Merged

rust-bors[bot] merged 3 commits into
rust-lang:mainfrom
JonathanBrouwer:lower-param-attrs

Conversation

@JonathanBrouwer

@JonathanBrouwer JonathanBrouwer commented Sep 14, 2026 •

Copy link
Copy Markdown
Member

View all comments

Fixes #162639

This is a temporary solution to get the bug fixed.
I'm going to see if we can move the function hir::Params from hir::Body to hir::FnSig, this would cleanly fix this bug and would undo most of this PR. That is a large project which might take me some time to complete, so I'd prefer to get the bug fixed first with this workaround.

Maybe r? @jdonszelmann since you have context?
cc @mejrs cause you're probably interested

@rustbot rustbot added 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 14, 2026
@rustbot

rustbot commented Sep 14, 2026

Copy link
Copy Markdown
Collaborator

jdonszelmann is currently at their maximum review capacity.
They may take a while to respond.

@rust-log-analyzer

This comment has been minimized.

Comment thread compiler/rustc_ast_lowering/src/lib.rs Outdated
Comment thread compiler/rustc_ast_lowering/src/lib.rs Outdated
@JonathanBrouwer
JonathanBrouwer force-pushed the lower-param-attrs branch 3 times, most recently from 29274ef to 5bf5ae2 Compare September 14, 2026 12:28
Comment thread compiler/rustc_ast_lowering/src/lib.rs

warning: the `must_use` attribute cannot be used on function params
--> $DIR/param-attrs-builtin-attrs.rs:40:7
--> $DIR/param-attrs-builtin-attrs.rs:29:7

@jdonszelmann jdonszelmann Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

the check for these warnings should go, since it causes double emissions

View changes since the review

@JonathanBrouwer JonathanBrouwer Sep 14, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Let's fix this in a follow-up PR, it will be quite a big diff to remove this error and replace it by target checking consistently

Comment thread tests/ui/rfcs/rfc-2565-param-attrs/param-attrs-builtin-attrs.stderr
@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 14, 2026
@JonathanBrouwer

Copy link
Copy Markdown
Member Author

@rust-lang/lang Is this a PR that you would want to take a look at?
This makes the following code, which was incorrectly allowed, no longer compile.
I believe there is some decision that for attribute fixes a ping was enough? I can't find that tho

fn help(x: fn(#[rustc_splat] usize)) {}

@JonathanBrouwer

Copy link
Copy Markdown
Member 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 14, 2026
@jdonszelmann

Copy link
Copy Markdown
Contributor

r=me then after some acknowledgement from t-lang. I think it falls under the same rule as earlier breaking changes in attrs (i.e. notify t-lang but do the change) but let them acknowledge that. Notably, this attribute is rather new, it's unlikely anyone depends on this.

@JonathanBrouwer JonathanBrouwer added the S-waiting-on-t-lang Status: Awaiting decision from T-lang label Sep 14, 2026
@JonathanBrouwer

Copy link
Copy Markdown
Member Author

Just in case
@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Sep 14, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Sep 14, 2026
Lower attributes for functions without bodies

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

Apart from the comment tweak, this looks like what I'd expect to happen for splat. Thank you for this fix!

View changes since this review

Comment thread compiler/rustc_ast_lowering/src/lib.rs Outdated

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

Did we also want to backport this to beta or stable?

Sorry for the multiple notifications 🙂

View changes since this review

//~| ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes
}

trait Test {

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.

I don't know if it's worth duplicating the trait, type, and extern tests in the splat feature gate test, up to you.

https://github.com/rust-lang/rust/blob/ada41e1ce81819f01577c0ee40ccbd6fc41384e8/tests/ui/feature-gates/feature-gate-splat.rs

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think it's not worth duplicating the test

@rust-bors

rust-bors Bot commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: ed70b09 (ed70b094daccd48a86a95d8b0acdc0dfb125b3d0)
Base parent: ed77b7b (ed77b7b8699e342c2dc842c83cb5fe4025252ee8)

@rust-timer

This comment has been minimized.

@traviscross traviscross added proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. and removed P-lang-drag-1 Lang team prioritization drag level 1. https://rust-lang.zulipchat.com/#narrow/channel/410516-t-lang labels Sep 23, 2026
@scottmcm

Copy link
Copy Markdown
Member

Agreed that this was clearly never supposed to be stable.

@rfcbot reviewed

@teor2345

Copy link
Copy Markdown
Member

Agreed that this was clearly never supposed to be stable.

@rfcbot reviewed

Triage note: after an hour, @scottmcm's box hasn't been ticked by the bot yet, so I ticket it manually.
(This doesn't change whether the FCP is over the threshold.)

@rust-rfcbot rust-rfcbot added finished-final-comment-period The final comment period is finished for this PR / Issue. to-announce Announce this issue on triage meeting labels Oct 3, 2026
@rust-rfcbot

Copy link
Copy Markdown
Collaborator

The final comment period, with a disposition to merge, as per the review above, is now complete.

As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed.

@rustbot

rustbot commented Oct 3, 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

Copy link
Copy Markdown
Member Author

r=me then after some acknowledgement from t-lang.

@bors r=jdonszelmann

@rust-bors

rust-bors Bot commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

📋 This PR cannot be approved because it currently has the following labels: proposed-final-comment-period, S-waiting-on-t-lang.

@JonathanBrouwer JonathanBrouwer removed proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. S-waiting-on-t-lang Status: Awaiting decision from T-lang labels Oct 3, 2026
@JonathanBrouwer

Copy link
Copy Markdown
Member Author

@bors r=jdonszelmann

@rust-bors

rust-bors Bot commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 9c9d810 has been tentatively approved by jdonszelmann

It will be put into the queue for this repository once PR CI succeeds.

@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-review Status: Awaiting review from the assignee but also interested parties. labels Oct 3, 2026
@traviscross traviscross added the waived-reference-pr This language change does not need a Reference PR. label Oct 3, 2026
jhpratt added a commit to jhpratt/rust that referenced this pull request Oct 3, 2026
… r=jdonszelmann

Lower attributes for functions without bodies

Fixes rust-lang#162639

This is a temporary solution to get the bug fixed.
I'm going to see if we can move the function `hir::Param`s from `hir::Body` to `hir::FnSig`, this would cleanly fix this bug and would undo most of this PR. That is a large project which might take me some time to complete, so I'd prefer to get the bug fixed first with this workaround.

Maybe r? @jdonszelmann since you have context?
cc @mejrs cause you're probably interested
rust-bors Bot pushed a commit that referenced this pull request Oct 4, 2026
Rollup of 18 pull requests

Successful merges:

 - #158102 (When compiling without a specified `--edition`, emit a message)
 - #162027 (std: add `fs::rename_noreplace`)
 - #162761 (Lower attributes for functions without bodies)
 - #163161 (implement FCW for `rustc_allowed_through_unstable_modules` items)
 - #163613 (Tweak the rendering of "not general enough" errors on the old trait solver)
 - #162062 (core: fix the docs of PanicInfo::location)
 - #163140 (document safety requirements for atomic intrinsics)
 - #163342 (Don't imply incorrect things about `Global` in the docs of `System`)
 - #163445 (Add safety comments for alloc::str)
 - #163503 (Mark Rc strong/weak count methods must_use)
 - #163548 (fs::set_permissions_nofollow: Android support, test cleanup)
 - #163585 ([triagebot] Create `debugger_visualizer` assign group)
 - #163597 (Add `SplitPathsRef` implementation for motor to make std build)
 - #163602 (Move media & home dirs tests to fs tests.)
 - #163667 (Finalize changes on expect messages for library/core/src/fmt/mod.rs)
 - #163682 ([rustdoc] Correctly link to (imported) enum variants with "jump to def")
 - #163683 (Fix GCC codegen backend comment in bootstrap)
 - #163703 (Move more `rustdoc-html tests` in the right location)

Failed merges:

 - #161491 (Rip out old solver coherence)
rust-bors Bot pushed a commit that referenced this pull request Oct 4, 2026
Rollup of 18 pull requests

Successful merges:

 - #158102 (When compiling without a specified `--edition`, emit a message)
 - #162761 (Lower attributes for functions without bodies)
 - #163161 (implement FCW for `rustc_allowed_through_unstable_modules` items)
 - #163613 (Tweak the rendering of "not general enough" errors on the old trait solver)
 - #162062 (core: fix the docs of PanicInfo::location)
 - #163140 (document safety requirements for atomic intrinsics)
 - #163342 (Don't imply incorrect things about `Global` in the docs of `System`)
 - #163445 (Add safety comments for alloc::str)
 - #163503 (Mark Rc strong/weak count methods must_use)
 - #163548 (fs::set_permissions_nofollow: Android support, test cleanup)
 - #163585 ([triagebot] Create `debugger_visualizer` assign group)
 - #163597 (Add `SplitPathsRef` implementation for motor to make std build)
 - #163602 (Move media & home dirs tests to fs tests.)
 - #163667 (Finalize changes on expect messages for library/core/src/fmt/mod.rs)
 - #163682 ([rustdoc] Correctly link to (imported) enum variants with "jump to def")
 - #163683 (Fix GCC codegen backend comment in bootstrap)
 - #163703 (Move more `rustdoc-html tests` in the right location)
 - #163725 (some crashes fixed with next-solver)

Failed merges:

 - #161491 (Rip out old solver coherence)
@rust-bors
rust-bors Bot merged commit dc179d7 into rust-lang:main Oct 4, 2026
14 checks passed
@rustbot rustbot added this to the 1.101.0 milestone Oct 4, 2026
rust-bors Bot pushed a commit that referenced this pull request Oct 4, 2026
Rollup merge of #162761 - JonathanBrouwer:lower-param-attrs, r=jdonszelmann

Lower attributes for functions without bodies

Fixes #162639

This is a temporary solution to get the bug fixed.
I'm going to see if we can move the function `hir::Param`s from `hir::Body` to `hir::FnSig`, this would cleanly fix this bug and would undo most of this PR. That is a large project which might take me some time to complete, so I'd prefer to get the bug fixed first with this workaround.

Maybe r? @jdonszelmann since you have context?
cc @mejrs cause you're probably interested
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. finished-final-comment-period The final comment period is finished for this PR / Issue. I-lang-radar Items that are on lang's radar and will need eventual work or consideration. 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. T-lang Relevant to the language team to-announce Announce this issue on triage meeting waived-reference-pr This language change does not need a Reference PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rustc_splat is not feature gated in functions without bodies