Skip to content

Add more tests for the optimize attribute#157297

Open
veluca93 wants to merge 1 commit into
rust-lang:mainfrom
veluca93:more-optimize-tests
Open

Add more tests for the optimize attribute#157297
veluca93 wants to merge 1 commit into
rust-lang:mainfrom
veluca93:more-optimize-tests

Conversation

@veluca93
Copy link
Copy Markdown
Contributor

@veluca93 veluca93 commented Jun 2, 2026

Tracking issue: #54882
Stabilization PR: #157273

@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 2, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Jun 2, 2026

r? @dingxiangfei2009

rustbot has assigned @dingxiangfei2009.
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 17 candidates

Copy link
Copy Markdown
Member

@jieyouxu jieyouxu left a comment

Choose a reason for hiding this comment

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

Thanks, a few more coverage nits
@rustbot author

View changes since this review

@@ -55,6 +55,8 @@
//~^ ERROR malformed
#[optimize]
//~^ ERROR malformed
#[optimize(none, speed)]
//~^ ERROR malformed
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.

Suggestion: can you also add a duplicate-value case? I.e.

#[optimize(none, none)]

Comment on lines 24 to 25
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.

Suggestion: can you add coverage for #[optimize] on an impl block fn? I.e.

impl G {
    #[optimize(speed)]
    fn g() {}
}

trait Foo {
#[optimize(speed)] //~ ERROR attribute cannot be used on
fn invalid();
}
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.

Question: wait, but this attr can be used with a trait method w/ a body right? I.e. can you add coverage for

trait Foo {
    #[optimize(speed)]
    fn valid() {}
}

@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 Jun 2, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Jun 2, 2026

Reminder, once the PR becomes ready for a review, use @rustbot ready.

Copy link
Copy Markdown
Member

@jieyouxu jieyouxu Jun 2, 2026

Choose a reason for hiding this comment

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

Remark: I feel like we should probably hoist the optimize attr ones into a separate test, this test is kinda of an abomination of everything

View changes since the review

@jieyouxu jieyouxu self-assigned this Jun 2, 2026
@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented Jun 2, 2026

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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