rustc_builtin_macros: rename bench parameter to avoid collisions with user-defined function names#148279
Merged
Merged
Conversation
Collaborator
This comment has been minimized.
This comment has been minimized.
oli-obk
reviewed
Oct 30, 2025
hkBst
suggested changes
Oct 31, 2025
hkBst
suggested changes
Oct 31, 2025
Contributor
|
r? hkBst |
Collaborator
|
Failed to set assignee to
|
Contributor
|
oh heh @bors delegate=hkBst |
Collaborator
hkBst
suggested changes
Nov 5, 2025
hkBst
suggested changes
Nov 5, 2025
Member
|
Looks fine now, but please squash your commits. |
hkBst
approved these changes
Nov 7, 2025
… user-defined function names
Collaborator
|
This PR was rebased onto a different master 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. |
Contributor
Author
|
@hkBst, just squashed the commits! Thanks again for your review & help :) |
Member
Collaborator
This was referenced Nov 8, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #148275 by preventing name collisions in the
#[bench]macro.Previously, a user-defined function named "b" could not be benchmarked because
the macro-generated lambda identity collided with the same name. We now generate
the lambda ident as
__bench_<function_name>, ensuring it is always distinctfrom the user’s function.
Because the prefix is applied recursively (e.g. benchmarking
__bench_bproduces a lambda ident
__bench___bench_b), there is no possible functionname that can equal its corresponding lambda ident. This guarantees that
the user can safely bench a function of any valid name without risk of
identifier collision.