Skip to content

Hint that memchr returns an in-bounds index - #159784

Open
SomeFlyingThing wants to merge 5 commits into
rust-lang:mainfrom
SomeFlyingThing:agent/hint-memchr-result-bounds
Open

Hint that memchr returns an in-bounds index#159784
SomeFlyingThing wants to merge 5 commits into
rust-lang:mainfrom
SomeFlyingThing:agent/hint-memchr-result-bounds

Conversation

@SomeFlyingThing

@SomeFlyingThing SomeFlyingThing commented Jul 23, 2026

Copy link
Copy Markdown

memchr_aligned always returns an index within the input slice, but that fact was not visible to callers after inlining. Record the invariant with assert_unchecked so LLVM can simplify callers such as str::find(char)

In x86_64 codegen, find(char) shrank from 463 to 377 bytes.

@rustbot rustbot added 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. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jul 23, 2026
@SomeFlyingThing
SomeFlyingThing marked this pull request as ready for review July 23, 2026 17:42
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 23, 2026
@rustbot rustbot removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Jul 23, 2026
@rustbot

rustbot commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the pull request, and welcome! The Rust Project is excited to review your changes, and you should hear from @petrochenkov (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 (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue
Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 74 candidates
  • Random selection from 19 candidates

@petrochenkov

Copy link
Copy Markdown
Contributor

r? libs

@rustbot rustbot assigned Darksonn and unassigned petrochenkov Jul 24, 2026
Comment thread library/core/src/slice/memchr.rs
@Darksonn

Copy link
Copy Markdown
Member

@rustbot author

@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 24, 2026
@rustbot

rustbot commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator

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

@rustbot rustbot added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Jul 24, 2026
@rust-log-analyzer

This comment has been minimized.

@SomeFlyingThing

Copy link
Copy Markdown
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 Jul 27, 2026

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

@rust-bors

rust-bors Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 49c1f02 has been approved by Darksonn

It is now in the queue for this repository.

🌲 The tree is currently closed for pull requests below priority 100. This pull request will be tested once the tree is reopened.

Reason for tree closure: spurious failures

@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 Jul 28, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jul 28, 2026
…result-bounds, r=Darksonn

Hint that memchr returns an in-bounds index

`memchr_aligned` always returns an index within the input slice, but that fact was not visible to callers after inlining. Record the invariant with `assert_unchecked` so LLVM can simplify callers such as `str::find(char)`

 In x86_64 codegen, `find(char)` shrank from 463 to 377 bytes.
rust-bors Bot pushed a commit that referenced this pull request Jul 28, 2026
…uwer

Rollup of 5 pull requests

Successful merges:

 - #159784 (Hint that memchr returns an in-bounds index)
 - #160027 (Add regression test for #132767)
 - #160030 (Update `browser-ui-test` version to `0.25.0`)
 - #160046 (Improve consistency of attribute error messages (part 2))
 - #160056 (Fix associated function suggestion for generic ADTs)
@JonathanBrouwer

Copy link
Copy Markdown
Contributor

💔 I suspect this PR failed tests as part of a rollup
@bors r-

After fixing the problem, consider running a try job for the failed job before re-approving.

Link to failure: #160070 (comment)

@rust-bors rust-bors Bot 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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jul 28, 2026
@rust-bors

rust-bors Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

This pull request was unapproved.

This PR was contained in a rollup (#160070), which was unapproved.

View changes since this unapproval

@SomeFlyingThing

Copy link
Copy Markdown
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 Jul 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants