diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-11-30 16:22:56 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-11-30 16:22:56 +0000 |
commit | 70eb17027151b4e85cbda2765f7289585b26a823 (patch) | |
tree | 1ab42350b15cd93ae8124c823fab048515244822 /crates/ide_db/src/helpers/insert_use.rs | |
parent | 9cbea21aa5a928d9020af63d101b5933ce9cc774 (diff) | |
parent | ec946570772a286e9c3cbd57c34bb40d36131275 (diff) |
Merge #6680
6680: Fix use merging not using the first path segment r=Veykril a=Veykril
Finally figured out why nested imports don't properly merge in some cases
Co-authored-by: Lukas Wirth <[email protected]>
Diffstat (limited to 'crates/ide_db/src/helpers/insert_use.rs')
-rw-r--r-- | crates/ide_db/src/helpers/insert_use.rs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/crates/ide_db/src/helpers/insert_use.rs b/crates/ide_db/src/helpers/insert_use.rs index 67e800fad..08d246c16 100644 --- a/crates/ide_db/src/helpers/insert_use.rs +++ b/crates/ide_db/src/helpers/insert_use.rs | |||
@@ -384,7 +384,7 @@ fn path_cmp_for_sort(a: Option<ast::Path>, b: Option<ast::Path>) -> Ordering { | |||
384 | 384 | ||
385 | /// Path comparison func for binary searching for merging. | 385 | /// Path comparison func for binary searching for merging. |
386 | fn path_cmp_bin_search(lhs: Option<ast::Path>, rhs: Option<ast::Path>) -> Ordering { | 386 | fn path_cmp_bin_search(lhs: Option<ast::Path>, rhs: Option<ast::Path>) -> Ordering { |
387 | match (lhs.and_then(|path| path.segment()), rhs.and_then(|path| path.segment())) { | 387 | match (lhs.as_ref().and_then(first_segment), rhs.as_ref().and_then(first_segment)) { |
388 | (None, None) => Ordering::Equal, | 388 | (None, None) => Ordering::Equal, |
389 | (None, Some(_)) => Ordering::Less, | 389 | (None, Some(_)) => Ordering::Less, |
390 | (Some(_), None) => Ordering::Greater, | 390 | (Some(_), None) => Ordering::Greater, |
@@ -1082,6 +1082,15 @@ use std::io;", | |||
1082 | } | 1082 | } |
1083 | 1083 | ||
1084 | #[test] | 1084 | #[test] |
1085 | fn merge_nested_considers_first_segments() { | ||
1086 | check_full( | ||
1087 | "hir_ty::display::write_bounds_like_dyn_trait", | ||
1088 | r"use hir_ty::{autoderef, display::{HirDisplayError, HirFormatter}, method_resolution};", | ||
1089 | r"use hir_ty::{autoderef, display::{HirDisplayError, HirFormatter, write_bounds_like_dyn_trait}, method_resolution};", | ||
1090 | ); | ||
1091 | } | ||
1092 | |||
1093 | #[test] | ||
1085 | fn skip_merge_last_too_long() { | 1094 | fn skip_merge_last_too_long() { |
1086 | check_last( | 1095 | check_last( |
1087 | "foo::bar", | 1096 | "foo::bar", |