Skip to content

Ensure that optimize attributes on closures are inherited by the shim.#157802

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
veluca93:optimize-attr-closure
Jun 13, 2026
Merged

Ensure that optimize attributes on closures are inherited by the shim.#157802
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
veluca93:optimize-attr-closure

Conversation

@veluca93

Copy link
Copy Markdown
Contributor

Tracking issue: #54882
Stabilization PR: #157273

@rustbot

rustbot commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

@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 Jun 12, 2026
@rustbot

rustbot commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator

r? @mejrs

rustbot has assigned @mejrs.
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 73 candidates
  • Random selection from 19 candidates

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

r=me with those changes 🙂

View changes since this review

Comment thread compiler/rustc_middle/src/mir/visit.rs Outdated
Comment thread compiler/rustc_middle/src/middle/codegen_fn_attrs.rs Outdated
@wesleywiser wesleywiser 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 Jun 12, 2026
@mejrs

mejrs commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

r=me with those changes 🙂

View changes since this review

I still want to review this as well.

@veluca93 veluca93 force-pushed the optimize-attr-closure branch from 988502a to e18fa55 Compare June 12, 2026 15:01
@rust-log-analyzer

This comment has been minimized.

@veluca93

Copy link
Copy Markdown
Contributor Author

@rustbot ready

(is there a way for me to re-trigger the CI for things that appear to be spurious failures like this one?)

@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 Jun 12, 2026

@mejrs mejrs left a comment

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.

What is the behavior of this?

#![feature(optimize_attribute)]

fn main() {
    f(
        #[optimize(size)] || { },
    );
}

fn f(_: impl Fn()) {}

Note that the attribute is applied to a function argument, not the expression (hence it does not require #![feature(stmt_expr_attributes)]).

View changes since this review

@mejrs

mejrs commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

(I just noticed there's a stabilization PR in flight, I have raised it there as well)

@veluca93

Copy link
Copy Markdown
Contributor Author

What is the behavior of this?

#![feature(optimize_attribute)]

fn main() {
    f(
        #[optimize(size)] || { },
    );
}

fn f(_: impl Fn()) {}

Note that the attribute is applied to a function argument, not the expression (hence it does not require #![feature(stmt_expr_attributes)]).

View changes since this review

In practice that's going to depend on inlining (i.e. if the closure gets MIR-inlined into f, the attribute has no effect, but if not, then the closure's body should be optimized for size).

@mejrs

mejrs commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

I see. Attributes in that position are somewhat ambiguous so a test would be nice, if it is feasible.

(is there a way for me to re-trigger the CI for things that appear to be spurious failures like this one?)

You can force push nothing.

@veluca93 veluca93 force-pushed the optimize-attr-closure branch from e18fa55 to 0959e4d Compare June 12, 2026 21:08
@veluca93

Copy link
Copy Markdown
Contributor Author

I see. Attributes in that position are somewhat ambiguous so a test would be nice, if it is feasible.

I think I did so.

(is there a way for me to re-trigger the CI for things that appear to be spurious failures like this one?)

You can force push nothing.

Good to know!

@mejrs

mejrs commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

@bors r=mejrs,wesleywiser rollup

@rust-bors

rust-bors Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 0959e4d has been approved by mejrs,wesleywiser

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-review Status: Awaiting review from the assignee but also interested parties. labels Jun 12, 2026
samueltardieu added a commit to samueltardieu/rust that referenced this pull request Jun 12, 2026
…mejrs,wesleywiser

Ensure that optimize attributes on closures are inherited by the shim.

Tracking issue: rust-lang#54882
Stabilization PR: rust-lang#157273
jhpratt added a commit to jhpratt/rust that referenced this pull request Jun 13, 2026
…mejrs,wesleywiser

Ensure that optimize attributes on closures are inherited by the shim.

Tracking issue: rust-lang#54882
Stabilization PR: rust-lang#157273
rust-bors Bot pushed a commit that referenced this pull request Jun 13, 2026
Rollup of 7 pull requests

Successful merges:

 - #157653 (remove AliasTerm::def_id())
 - #157773 (Remove AnonConstKind::GCA and reject generic anon consts)
 - #157740 (rustdoc: correct doctest span for trailing semicolon after item)
 - #157782 (Added `PhantomPinned` diagnostic item and prevented dead field warning on `PhantomPinned`)
 - #157802 (Ensure that optimize attributes on closures are inherited by the shim.)
 - #157812 (rustc_public: implement `ty::Alias` conversion)
 - #157833 (Update wasm-component-ld to 0.5.25)
jhpratt added a commit to jhpratt/rust that referenced this pull request Jun 13, 2026
…mejrs,wesleywiser

Ensure that optimize attributes on closures are inherited by the shim.

Tracking issue: rust-lang#54882
Stabilization PR: rust-lang#157273
rust-bors Bot pushed a commit that referenced this pull request Jun 13, 2026
Rollup of 9 pull requests

Successful merges:

 - #157653 (remove AliasTerm::def_id())
 - #157773 (Remove AnonConstKind::GCA and reject generic anon consts)
 - #157846 (Avoid ICE in unconstrained generic parameter suggestion for enums)
 - #157514 ([tiny] Use multipart suggestion for finding ident when literal was expected in attr)
 - #157740 (rustdoc: correct doctest span for trailing semicolon after item)
 - #157782 (Added `PhantomPinned` diagnostic item and prevented dead field warning on `PhantomPinned`)
 - #157802 (Ensure that optimize attributes on closures are inherited by the shim.)
 - #157812 (rustc_public: implement `ty::Alias` conversion)
 - #157833 (Update wasm-component-ld to 0.5.25)
rust-bors Bot pushed a commit that referenced this pull request Jun 13, 2026
Rollup of 10 pull requests

Successful merges:

 - #157714 (Improve polymorphization of raw pointer formatting)
 - #157653 (remove AliasTerm::def_id())
 - #157773 (Remove AnonConstKind::GCA and reject generic anon consts)
 - #157846 (Avoid ICE in unconstrained generic parameter suggestion for enums)
 - #157594 (note which target a missing target_feature belongs to)
 - #157740 (rustdoc: correct doctest span for trailing semicolon after item)
 - #157782 (Added `PhantomPinned` diagnostic item and prevented dead field warning on `PhantomPinned`)
 - #157802 (Ensure that optimize attributes on closures are inherited by the shim.)
 - #157812 (rustc_public: implement `ty::Alias` conversion)
 - #157833 (Update wasm-component-ld to 0.5.25)
rust-bors Bot pushed a commit that referenced this pull request Jun 13, 2026
Rollup of 10 pull requests

Successful merges:

 - #157714 (Improve polymorphization of raw pointer formatting)
 - #157653 (remove AliasTerm::def_id())
 - #157773 (Remove AnonConstKind::GCA and reject generic anon consts)
 - #157846 (Avoid ICE in unconstrained generic parameter suggestion for enums)
 - #157594 (note which target a missing target_feature belongs to)
 - #157740 (rustdoc: correct doctest span for trailing semicolon after item)
 - #157782 (Added `PhantomPinned` diagnostic item and prevented dead field warning on `PhantomPinned`)
 - #157802 (Ensure that optimize attributes on closures are inherited by the shim.)
 - #157812 (rustc_public: implement `ty::Alias` conversion)
 - #157833 (Update wasm-component-ld to 0.5.25)
@rust-bors rust-bors Bot merged commit c5ed1a7 into rust-lang:main Jun 13, 2026
12 checks passed
@rustbot rustbot added this to the 1.98.0 milestone Jun 13, 2026
rust-timer added a commit that referenced this pull request Jun 13, 2026
Rollup merge of #157802 - veluca93:optimize-attr-closure, r=mejrs,wesleywiser

Ensure that optimize attributes on closures are inherited by the shim.

Tracking issue: #54882
Stabilization PR: #157273
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

5 participants