aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_db/src/helpers/insert_use.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-01-15 18:40:47 +0000
committerGitHub <[email protected]>2021-01-15 18:40:47 +0000
commit8a869e870ac6328967fb120a0ebe44a9c900eaf0 (patch)
treef4ad40fc09483af3e9fea77d4b4156130539a70c /crates/ide_db/src/helpers/insert_use.rs
parent148e3d0f6a28f57565538dca7d9c0f5f726a5908 (diff)
parentcb863390f23bc2eac6561d55def9bd3ba54605fc (diff)
Merge #7288
7288: Handle self/super/crate in PathSegment as NameRef r=matklad a=Veykril Wrapping self/super/crate in NameRef as per https://github.com/rust-analyzer/rust-analyzer/pull/7261#issuecomment-760023172 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.rs10
1 files changed, 8 insertions, 2 deletions
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
444} 444}
445 445
446fn path_segment_cmp(a: &ast::PathSegment, b: &ast::PathSegment) -> Ordering { 446fn path_segment_cmp(a: &ast::PathSegment, b: &ast::PathSegment) -> Ordering {
447 let a = a.name_ref(); 447 let a = a.kind().and_then(|kind| match kind {
448 let b = b.name_ref(); 448 PathSegmentKind::Name(name_ref) => Some(name_ref),
449 _ => None,
450 });
451 let b = b.kind().and_then(|kind| match kind {
452 PathSegmentKind::Name(name_ref) => Some(name_ref),
453 _ => None,
454 });
449 a.as_ref().map(ast::NameRef::text).cmp(&b.as_ref().map(ast::NameRef::text)) 455 a.as_ref().map(ast::NameRef::text).cmp(&b.as_ref().map(ast::NameRef::text))
450} 456}
451 457