Make impl_trait_redundant_captures suggestion remove adjacent +#156843
Open
onehr wants to merge 1 commit into
Open
Make impl_trait_redundant_captures suggestion remove adjacent +#156843onehr wants to merge 1 commit into
onehr wants to merge 1 commit into
Conversation
Collaborator
|
r? @tiif rustbot has assigned @tiif. Use Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
The lint suggestion now removes the `+` joiner adjacent to a redundant `use<...>` clause, so applying the suggestion does not leave a dangling `+` that fails to parse. The existing `tests/ui/impl-trait/precise-capturing/redundant.stderr` baseline emits the same diagnostic with the expanded suggestion span and is blessed along with the new `run-rustfix` test. Tested: - ./x test tests/ui/impl-trait/precise-capturing/redundant.rs --force-rerun - ./x test tests/ui/impl-trait/precise-capturing/redundant-machine-applicable.rs --force-rerun - ./x test tidy
aed2feb to
6493163
Compare
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.
Closes #143216
The
impl_trait_redundant_captureslint's machine-applicable suggestion onlyspanned the
use<...>syntax itself, leaving the adjacent+joiner behind.Applying the suggestion produced uncompilable code, e.g.
impl Sized + use<>becomingimpl Sized +(stray trailing+).This extends the removal span to also cover one adjacent
+, preservingvalid syntax in the three bound-list positions covered by the regression test:
impl Sized + use<>becomesimpl Sizedimpl use<> + Sizedbecomesimpl Sizedimpl Sized + use<> + Sendbecomesimpl Sized + SendA
//@ run-rustfixUI test exercises all three positions, so therustfix-applied output is actually compiled — covering the gap the
existing
redundant.rstest left (which only checks lint firing, notsuggestion correctness).
Tested: