From 3aee6b99623e4ae848ae635272ea3ff521be6ec3 Mon Sep 17 00:00:00 2001 From: Liu Dingming Date: Thu, 6 Jan 2022 17:38:38 +0800 Subject: [PATCH] Fix lost import on Crate granularity --- src/imports.rs | 4 ++-- tests/source/imports_granularity_crate.rs | 6 ++++++ tests/target/imports_granularity_crate.rs | 6 ++++++ tests/target/imports_granularity_one.rs | 3 ++- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/imports.rs b/src/imports.rs index 40e0d06f99d..d67fe2c8274 100644 --- a/src/imports.rs +++ b/src/imports.rs @@ -622,7 +622,7 @@ impl UseTree { fn merge(&mut self, other: &UseTree, merge_by: SharedPrefix) { let mut prefix = 0; for (a, b) in self.path.iter().zip(other.path.iter()) { - if a.equal_except_alias(b) { + if *a == *b { prefix += 1; } else { break; @@ -700,7 +700,7 @@ fn merge_use_trees_inner(trees: &mut Vec, use_tree: UseTree, merge_by: tree.path .iter() .zip(&use_tree.path) - .take_while(|(a, b)| a.equal_except_alias(b)) + .take_while(|(a, b)| *a == *b) .count() } else { 0 diff --git a/tests/source/imports_granularity_crate.rs b/tests/source/imports_granularity_crate.rs index d16681b01b5..f87506e858f 100644 --- a/tests/source/imports_granularity_crate.rs +++ b/tests/source/imports_granularity_crate.rs @@ -33,5 +33,11 @@ use h::{a}; use i::a::{self}; use j::{a::{self}}; +use a::{c as cc, c}; + +use a::{c as c1, c as c2}; + +use a::{c, c as c1, c as c2}; + use {k::{a, b}, l::{a, b}}; use {k::{c, d}, l::{c, d}}; diff --git a/tests/target/imports_granularity_crate.rs b/tests/target/imports_granularity_crate.rs index d75906d30f1..2736bff94d8 100644 --- a/tests/target/imports_granularity_crate.rs +++ b/tests/target/imports_granularity_crate.rs @@ -24,5 +24,11 @@ use h::a; use i::a::{self}; use j::a::{self}; +use a::{c as cc, c}; + +use a::{c as c1, c as c2}; + +use a::{c, c as c1, c as c2}; + use k::{a, b, c, d}; use l::{a, b, c, d}; diff --git a/tests/target/imports_granularity_one.rs b/tests/target/imports_granularity_one.rs index 78ec5e7325c..ba8d60957b0 100644 --- a/tests/target/imports_granularity_one.rs +++ b/tests/target/imports_granularity_one.rs @@ -10,7 +10,8 @@ use { }; use { - a::{self as x, aa, ab}, + a as x, + a::{aa, ab}, b::ba, };