borrowck: Don't mention unused vars in closure outlive errors#154674
Merged
rust-bors[bot] merged 3 commits intorust-lang:mainfrom Apr 5, 2026
Merged
borrowck: Don't mention unused vars in closure outlive errors#154674rust-bors[bot] merged 3 commits intorust-lang:mainfrom
rust-bors[bot] merged 3 commits intorust-lang:mainfrom
Conversation
The `user_arg_index` nomenclature can be applied more broadly, but then the diff becomes annoyingly big, so I chose not to do that.
So that the impact of the commit that fixes the test can be seen clearly.
When there is a lifetime error, the code does its best to find variables that correspond to the lifetimes involved. This commit stops mentioning arguments that are unused in closures, since they are not relevant. See the diff of the blessed test to get a good clue of what that means.
Collaborator
|
rustbot has assigned @jdonszelmann. Use Why was this reviewer chosen?The reviewer was selected based on:
|
jdonszelmann
reviewed
Apr 2, 2026
| let mut used = false; | ||
| VisitPlacesWith(|place: Place<'_>, context: PlaceContext| { | ||
| if !matches!(context, PlaceContext::NonUse(_)) && place.local == target { | ||
| used = true; |
Contributor
There was a problem hiding this comment.
is there a way to break out here? We don't need to continue the visit
Member
Author
There was a problem hiding this comment.
I tried to find a way, but I don't think there is a way (without doing stuff like manually implementing a visitor specifically for this purpose, but IMHO that would be overkill). Luckily this code is only run in the face of compiler errors, so normal compilation speed is not affected.
jdonszelmann
reviewed
Apr 2, 2026
jdonszelmann
requested changes
Apr 2, 2026
Member
Author
|
@rustbot ready |
Contributor
|
@bors r+ rollup |
Contributor
rust-timer
added a commit
that referenced
this pull request
Apr 5, 2026
Rollup merge of #154674 - Enselic:unused-outlive, r=jdonszelmann borrowck: Don't mention unused vars in closure outlive errors When there is a closure arg lifetime error, the code does its best to find variables that correspond to the lifetimes involved. This commit stops mentioning arguments that are unused in closures, since they are not relevant. This removes the "red herring" of #113121. The `user_arg_index` nomenclature can be applied more broadly, but then the diff becomes annoyingly big, so I chose not to do that. Review each commit individually for a nicer experience.
JonathanBrouwer
added a commit
to JonathanBrouwer/rust
that referenced
this pull request
Apr 20, 2026
…mann borrowck: Apply `user_arg_index` nomenclature more broadly No change in behavior. Only renames and a couple of added comments. As requested here: rust-lang#154674 (comment) r? jdonszelmann
rust-timer
added a commit
that referenced
this pull request
Apr 20, 2026
Rollup merge of #154895 - Enselic:user-arg-index, r=jdonszelmann borrowck: Apply `user_arg_index` nomenclature more broadly No change in behavior. Only renames and a couple of added comments. As requested here: #154674 (comment) r? jdonszelmann
github-actions Bot
pushed a commit
to rust-lang/rustc-dev-guide
that referenced
this pull request
Apr 21, 2026
borrowck: Apply `user_arg_index` nomenclature more broadly No change in behavior. Only renames and a couple of added comments. As requested here: rust-lang/rust#154674 (comment) r? jdonszelmann
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.
When there is a closure arg lifetime error, the code does its best to find variables that correspond to the lifetimes involved. This commit stops mentioning arguments that are unused in closures, since they are not relevant. This removes the "red herring" of #113121.
The
user_arg_indexnomenclature can be applied more broadly, but then the diff becomes annoyingly big, so I chose not to do that.Review each commit individually for a nicer experience.