From cb863390f23bc2eac6561d55def9bd3ba54605fc Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Fri, 15 Jan 2021 18:57:32 +0100 Subject: Handle self/super/crate in PathSegment as NameRef --- crates/ide_db/src/helpers/insert_use.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'crates/ide_db/src/helpers/insert_use.rs') diff --git a/crates/ide_db/src/helpers/insert_use.rs b/crates/ide_db/src/helpers/insert_use.rs index d6b498be3..0c180e9bc 100644 --- a/crates/ide_db/src/helpers/insert_use.rs +++ b/crates/ide_db/src/helpers/insert_use.rs @@ -444,8 +444,14 @@ fn use_tree_path_cmp(a: &ast::Path, a_has_tl: bool, b: &ast::Path, b_has_tl: boo } fn path_segment_cmp(a: &ast::PathSegment, b: &ast::PathSegment) -> Ordering { - let a = a.name_ref(); - let b = b.name_ref(); + let a = a.kind().and_then(|kind| match kind { + PathSegmentKind::Name(name_ref) => Some(name_ref), + _ => None, + }); + let b = b.kind().and_then(|kind| match kind { + PathSegmentKind::Name(name_ref) => Some(name_ref), + _ => None, + }); a.as_ref().map(ast::NameRef::text).cmp(&b.as_ref().map(ast::NameRef::text)) } -- cgit v1.2.3