diff options
Diffstat (limited to 'crates/ide_db/src/helpers')
-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", |