Skip to content
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

Dedup std_instead_of_core by using first segment span for uniqueness #12406

Merged

Conversation

MarcusGrass
Copy link
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
Copy link
Collaborator

rustbot commented Mar 3, 2024

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
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
Copy link
Collaborator

bors commented Mar 3, 2024

📌 Commit 3735bf9 has been approved by Alexendoo

It is now in the queue for this repository.

@bors
Copy link
Collaborator

bors commented Mar 3, 2024

⌛ Testing commit 3735bf9 with merge 3064211...

@bors
Copy link
Collaborator

bors commented Mar 3, 2024

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

@bors bors merged commit 3064211 into rust-lang:master Mar 3, 2024
5 checks passed
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.

None yet

4 participants