Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit ff4fe5d

Browse files
authored
Merge pull request rust-lang#3044 from orium/fix-too-many-modsep
Fix bug in import where two consecutive module separators were possible.
2 parents 4568c1a + 98a0ef2 commit ff4fe5d

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/imports.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,11 +324,15 @@ impl UseTree {
324324
&& a.prefix.to_string().len() > 2
325325
&& a.prefix.to_string().starts_with("::");
326326

327+
let mut modsep = leading_modsep;
328+
327329
for p in &a.prefix.segments {
328-
if let Some(use_segment) = UseSegment::from_path_segment(context, p, leading_modsep) {
330+
if let Some(use_segment) = UseSegment::from_path_segment(context, p, modsep) {
329331
result.path.push(use_segment);
332+
modsep = false;
330333
}
331334
}
335+
332336
match a.kind {
333337
UseTreeKind::Glob => {
334338
result.path.push(UseSegment::Glob);

tests/target/issue-3043.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// rustfmt-edition: 2018
2+
3+
use ::std::vec::Vec;
4+
5+
fn main() {}

0 commit comments

Comments
 (0)