Dedup std_instead_of_core by using first segment span for uniqueness #12406
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.
Relates to #12379.
Instead of checking that the paths have an identical span, it checks that the relevant
std
part of the path segment's span is identical. Added a multiline test, because my first implementation was worse and failed that, then I realized that you could grab the span off the first_segmentIdent
.I did find another bug that isn't addressed by this, and that exists on master as well.
The path:
Will get fixed into:
Which doesn't compile since
io::Write
isn't incore
, if any of those paths are present incore
it'll do the replace and cause a miscompilation. Do you think I should file a separate bug for that? Sincerustfmt
default splits those up it isn't that big of a deal.Rustfmt:
changelog: [
std_instead_of_core
]: Fix duplicated output on multiple imports