aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_db/src
diff options
context:
space:
mode:
authorLukas Wirth <[email protected]>2020-11-30 14:35:55 +0000
committerLukas Wirth <[email protected]>2020-11-30 16:21:07 +0000
commitec946570772a286e9c3cbd57c34bb40d36131275 (patch)
treed02e350be0554b1523d5341a8f862af18053cbb8 /crates/ide_db/src
parent13025ae2a121be8320a6ec40ad3519df5640c927 (diff)
Fix use merging not using the first path segment
Diffstat (limited to 'crates/ide_db/src')
-rw-r--r--crates/ide_db/src/helpers/insert_use.rs11
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.
386fn path_cmp_bin_search(lhs: Option<ast::Path>, rhs: Option<ast::Path>) -> Ordering { 386fn 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",