Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,7 @@ impl UseTree {
if let UseSegmentKind::List(list) = last.kind {
let mut list = list.into_iter().map(UseTree::normalize).collect::<Vec<_>>();
list.sort();
list.dedup();
last = UseSegment {
kind: UseSegmentKind::List(list),
style_edition: last.style_edition,
Expand Down Expand Up @@ -827,6 +828,7 @@ fn merge_rest(
UseTree::from_path(b[len..].to_vec(), DUMMY_SP),
];
list.sort();
list.dedup();
let mut new_path = b[..len].to_vec();
let kind = UseSegmentKind::List(list);
let style_edition = a[0].style_edition;
Expand Down Expand Up @@ -891,6 +893,7 @@ fn merge_use_trees_inner(trees: &mut Vec<UseTree>, use_tree: UseTree, merge_by:
}
trees.push(use_tree);
trees.sort();
trees.dedup();
}

impl Hash for UseTree {
Expand Down
4 changes: 4 additions & 0 deletions tests/source/issue-6243.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// rustfmt-imports_granularity: Module

use risingwave_batch::executor::{BoxedExecutor, JoinType};
use risingwave_batch::executor::{BoxedExecutor, JoinType};
3 changes: 3 additions & 0 deletions tests/target/issue-6243.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// rustfmt-imports_granularity: Module

use risingwave_batch::executor::{BoxedExecutor, JoinType};
6 changes: 1 addition & 5 deletions tests/target/multiple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@ extern crate foo;
extern crate foo;

use std::cell::*;
use std::{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. Should we have this test at all? This original code won't compile, and now the use tree is much smaller. We should tweak this to import a lot of items

cc @calebcartwright if you have an idea as to what this test was doing before

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still think this should be fixed: let's change this to a test that imports a lot of different items.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rustfmt does still have to work on code that doesn't compile, provided it can still be parsed.

I'm not sure what the thinking was for making that distinction back in the day, but it made sense to me in the context of an inner dev-loop and format on save in editors

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, makes sense. We shouldn't have any stability around that but we should test it I guess.

self, any, ascii, borrow, borrow, borrow, borrow, borrow, borrow, borrow, borrow, borrow,
borrow, borrow, boxed, boxed, boxed, boxed, boxed, boxed, boxed, boxed, boxed, boxed, char,
char, char, char, char, char, char, char, char, char,
};
use std::{self, any, ascii, borrow, boxed, char};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait, this is changing behavior without this flag.

However, this code is broken, so perhaps that's fine?


mod doc;
mod other;
Expand Down
Loading