mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 21:35:20 +00:00
Fix use merging not using the first path segment
This commit is contained in:
parent
13025ae2a1
commit
ec94657077
2 changed files with 11 additions and 2 deletions
|
@ -407,7 +407,7 @@ impl std::fmt::Display<|> for Foo {
|
||||||
}
|
}
|
||||||
",
|
",
|
||||||
r"
|
r"
|
||||||
use std::fmt::{nested::Debug, Display};
|
use std::fmt::{Display, nested::Debug};
|
||||||
|
|
||||||
impl Display for Foo {
|
impl Display for Foo {
|
||||||
}
|
}
|
||||||
|
|
|
@ -384,7 +384,7 @@ fn path_cmp_for_sort(a: Option<ast::Path>, b: Option<ast::Path>) -> Ordering {
|
||||||
|
|
||||||
/// Path comparison func for binary searching for merging.
|
/// Path comparison func for binary searching for merging.
|
||||||
fn path_cmp_bin_search(lhs: Option<ast::Path>, rhs: Option<ast::Path>) -> Ordering {
|
fn path_cmp_bin_search(lhs: Option<ast::Path>, rhs: Option<ast::Path>) -> Ordering {
|
||||||
match (lhs.and_then(|path| path.segment()), rhs.and_then(|path| path.segment())) {
|
match (lhs.as_ref().and_then(first_segment), rhs.as_ref().and_then(first_segment)) {
|
||||||
(None, None) => Ordering::Equal,
|
(None, None) => Ordering::Equal,
|
||||||
(None, Some(_)) => Ordering::Less,
|
(None, Some(_)) => Ordering::Less,
|
||||||
(Some(_), None) => Ordering::Greater,
|
(Some(_), None) => Ordering::Greater,
|
||||||
|
@ -1081,6 +1081,15 @@ use std::io;",
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn merge_nested_considers_first_segments() {
|
||||||
|
check_full(
|
||||||
|
"hir_ty::display::write_bounds_like_dyn_trait",
|
||||||
|
r"use hir_ty::{autoderef, display::{HirDisplayError, HirFormatter}, method_resolution};",
|
||||||
|
r"use hir_ty::{autoderef, display::{HirDisplayError, HirFormatter, write_bounds_like_dyn_trait}, method_resolution};",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn skip_merge_last_too_long() {
|
fn skip_merge_last_too_long() {
|
||||||
check_last(
|
check_last(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue