-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
Don't suggest replacing closure parameter with type name #151035
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
rust-bors
merged 1 commit into
rust-lang:main
from
heathdutton:issue-150693-closure-arg-suggestion
Jan 13, 2026
Merged
Don't suggest replacing closure parameter with type name #151035
rust-bors
merged 1 commit into
rust-lang:main
from
heathdutton:issue-150693-closure-arg-suggestion
Jan 13, 2026
+3
−11
Conversation
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
Collaborator
This comment has been minimized.
This comment has been minimized.
When a closure has an inferred parameter type like `|ch|` and the expected type differs in borrowing (e.g., `char` vs `&char`), the suggestion code would incorrectly suggest `|char|` instead of the valid `|ch: char|`. This happened because the code couldn't walk explicit `&` references in the HIR when the type is inferred, and fell back to replacing the entire parameter span with the expected type name. Fix by only emitting the suggestion when we can properly identify the `&` syntax to remove.
74abd3d to
afe76df
Compare
jieyouxu
approved these changes
Jan 13, 2026
Member
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Member
|
@bors r+ rollup |
Contributor
rust-bors bot
pushed a commit
that referenced
this pull request
Jan 13, 2026
…uwer Rollup of 14 pull requests Successful merges: - #150151 (Destabilise `target-spec-json`) - #150826 (Add `f16` inline ASM support for s390x) - #150883 (Improve span for "unresolved intra doc link" on `deprecated` attribute) - #150934 (Move some checks from `check_doc_attrs` directly into `rustc_attr_parsing`) - #150943 (Port `#[must_not_suspend]` to attribute parser) - #150990 (std: sys: net: uefi: Make TcpStream Send) - #150995 (core: ptr: split_at_mut: fix typo in safety doc) - #150998 (Relax test expectation for @__llvm_profile_runtime_user) - #151002 (Remove a workaround for a bug (take 2)) - #151005 (Fix typo in `MaybeUninit` docs) - #151011 (Update books) - #151029 (rustc-dev-guide subtree update) - #151032 (fix: added missing backtick in triagebot.toml) - #151035 (Don't suggest replacing closure parameter with type name) r? @ghost
rust-timer
added a commit
that referenced
this pull request
Jan 13, 2026
Rollup merge of #151035 - issue-150693-closure-arg-suggestion, r=jieyouxu Don't suggest replacing closure parameter with type name When a closure has an inferred parameter type like `|ch|` and the expected type differs in borrowing (e.g., `char` vs `&char`), the suggestion would incorrectly propose `|char|` instead of something valid like `|ch: char|`. This happened because the code couldn't walk explicit `&` references in the HIR when the type is inferred, and fell back to replacing the entire parameter span with the expected type name. Fix by only emitting the suggestion when we can properly identify the `&` syntax to remove. Fixes #150693
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.
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.
When a closure has an inferred parameter type like
|ch|and the expected type differs in borrowing (e.g.,charvs&char), the suggestion would incorrectly propose|char|instead of something valid like|ch: char|.This happened because the code couldn't walk explicit
&references in the HIR when the type is inferred, and fell back to replacing the entire parameter span with the expected type name.Fix by only emitting the suggestion when we can properly identify the
&syntax to remove.Fixes #150693