Skip to content

Dedup std_instead_of_core by using first segment span for uniqueness#12406

Merged
bors merged 3 commits into
rust-lang:masterfrom
MarcusGrass:fix-duplicate-std-instead-of-core
Mar 3, 2024
Merged

Dedup std_instead_of_core by using first segment span for uniqueness#12406
bors merged 3 commits into
rust-lang:masterfrom
MarcusGrass:fix-duplicate-std-instead-of-core

Conversation

@MarcusGrass

Copy link
Copy Markdown
Contributor

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_segment Ident.

I did find another bug that isn't addressed by this, and that exists on master as well.

The path:

use std::{io::Write, fmt::Display};

Will get fixed into:

use core::{io::Write, fmt::Display};

Which doesn't compile since io::Write isn't in core, if any of those paths are present in core it'll do the replace and cause a miscompilation. Do you think I should file a separate bug for that? Since rustfmt default splits those up it isn't that big of a deal.

Rustfmt:

// Pre
use std::{io::Write, fmt::Display};
// Post
use std::fmt::Display;
use std::io::Write;

changelog: [std_instead_of_core]: Fix duplicated output on multiple imports

@rustbot

rustbot commented Mar 3, 2024

Copy link
Copy Markdown
Collaborator

r? @Alexendoo

rustbot has assigned @Alexendoo.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Mar 3, 2024
@Alexendoo

Copy link
Copy Markdown
Member

Thanks! @bors r+

Yeah it'd be good to have an issue for that, some do configure rustfmt to use that style of imports

@bors

bors commented Mar 3, 2024

Copy link
Copy Markdown
Contributor

📌 Commit 3735bf9 has been approved by Alexendoo

It is now in the queue for this repository.

@bors

bors commented Mar 3, 2024

Copy link
Copy Markdown
Contributor

⌛ Testing commit 3735bf9 with merge 3064211...

@bors

bors commented Mar 3, 2024

Copy link
Copy Markdown
Contributor

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: Alexendoo
Pushing 3064211 to master...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants