From 345b161a6a3e7bf7ca180d5f29deecf877973b8b Mon Sep 17 00:00:00 2001 From: Josh Robson Chase Date: Sat, 18 May 2019 16:01:01 -0400 Subject: [PATCH 1/3] Add failing case to merge_imports test --- tests/source/merge_imports.rs | 3 +++ tests/target/merge_imports.rs | 3 +++ 2 files changed, 6 insertions(+) diff --git a/tests/source/merge_imports.rs b/tests/source/merge_imports.rs index 7a2c5ca8e24..1473f46f786 100644 --- a/tests/source/merge_imports.rs +++ b/tests/source/merge_imports.rs @@ -22,3 +22,6 @@ use a::{b::{c::*}}; use a::{b::{c::{}}}; use a::{b::{c::d}}; use a::{b::{c::{xxx, yyy, zzz}}}; + +use a::b; +use a::b::c; diff --git a/tests/target/merge_imports.rs b/tests/target/merge_imports.rs index 63e5baacaba..92570896a10 100644 --- a/tests/target/merge_imports.rs +++ b/tests/target/merge_imports.rs @@ -14,3 +14,6 @@ use foo::{a, b, c}; pub use foo::{bar, foobar}; use a::b::c::{d, xxx, yyy, zzz, *}; + +use a::b; +use a::b::c; From f7e3d7c85b34ca418ff34bd8d84bdca84c3887e5 Mon Sep 17 00:00:00 2001 From: Josh Robson Chase Date: Sat, 18 May 2019 16:31:43 -0400 Subject: [PATCH 2/3] Adjust more tests --- src/imports.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/imports.rs b/src/imports.rs index 1d9eba7b1ef..2128d69ba80 100644 --- a/src/imports.rs +++ b/src/imports.rs @@ -989,9 +989,9 @@ mod test { } test_merge!(["a::b::{c, d}", "a::b::{e, f}"], ["a::b::{c, d, e, f}"]); - test_merge!(["a::b::c", "a::b"], ["a::b::{self, c}"]); + test_merge!(["a::b::c", "a::b"], ["a::{b, b::c}"]); test_merge!(["a::b", "a::b"], ["a::b"]); - test_merge!(["a", "a::b", "a::b::c"], ["a::{self, b::{self, c}}"]); + test_merge!(["a", "a::b", "a::b::c"], ["a", "a::b", "a::b::c"]); test_merge!( ["a::{b::{self, c}, d::e}", "a::d::f"], ["a::{b::{self, c}, d::{e, f}}"] From 67442b9e11422ee7ec7520060161e431c9b7af7c Mon Sep 17 00:00:00 2001 From: Josh Robson Chase Date: Sat, 18 May 2019 17:24:04 -0400 Subject: [PATCH 3/3] Almost a fix --- src/imports.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/imports.rs b/src/imports.rs index 2128d69ba80..8dad9456fa4 100644 --- a/src/imports.rs +++ b/src/imports.rs @@ -578,7 +578,8 @@ impl UseTree { .path .clone() .iter_mut() - .zip(other.path.clone().into_iter()) + .take(self.path.len() - 1) + .zip(other.path.clone().into_iter().take(other.path.len() - 1)) { if *a == b { new_path.push(b);