diff options
Diffstat (limited to 'crates/ra_assists/src')
-rw-r--r-- | crates/ra_assists/src/auto_import.rs | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/crates/ra_assists/src/auto_import.rs b/crates/ra_assists/src/auto_import.rs index 1158adbbc..5ecda1ff5 100644 --- a/crates/ra_assists/src/auto_import.rs +++ b/crates/ra_assists/src/auto_import.rs | |||
@@ -504,7 +504,7 @@ fn apply_auto_import( | |||
504 | } | 504 | } |
505 | } | 505 | } |
506 | 506 | ||
507 | pub fn collect_hir_path_segments(path: &hir::Path) -> Vec<SmolStr> { | 507 | pub fn collect_hir_path_segments(path: &hir::Path) -> Option<Vec<SmolStr>> { |
508 | let mut ps = Vec::<SmolStr>::with_capacity(10); | 508 | let mut ps = Vec::<SmolStr>::with_capacity(10); |
509 | match path.kind { | 509 | match path.kind { |
510 | hir::PathKind::Abs => ps.push("".into()), | 510 | hir::PathKind::Abs => ps.push("".into()), |
@@ -512,11 +512,12 @@ pub fn collect_hir_path_segments(path: &hir::Path) -> Vec<SmolStr> { | |||
512 | hir::PathKind::Plain => {} | 512 | hir::PathKind::Plain => {} |
513 | hir::PathKind::Self_ => ps.push("self".into()), | 513 | hir::PathKind::Self_ => ps.push("self".into()), |
514 | hir::PathKind::Super => ps.push("super".into()), | 514 | hir::PathKind::Super => ps.push("super".into()), |
515 | hir::PathKind::Type => return None, | ||
515 | } | 516 | } |
516 | for s in path.segments.iter() { | 517 | for s in path.segments.iter() { |
517 | ps.push(s.name.to_string().into()); | 518 | ps.push(s.name.to_string().into()); |
518 | } | 519 | } |
519 | ps | 520 | Some(ps) |
520 | } | 521 | } |
521 | 522 | ||
522 | // This function produces sequence of text edits into edit | 523 | // This function produces sequence of text edits into edit |
@@ -552,7 +553,7 @@ pub(crate) fn auto_import(mut ctx: AssistCtx<impl HirDatabase>) -> Option<Assist | |||
552 | } | 553 | } |
553 | 554 | ||
554 | let hir_path = hir::Path::from_ast(path.clone())?; | 555 | let hir_path = hir::Path::from_ast(path.clone())?; |
555 | let segments = collect_hir_path_segments(&hir_path); | 556 | let segments = collect_hir_path_segments(&hir_path)?; |
556 | if segments.len() < 2 { | 557 | if segments.len() < 2 { |
557 | return None; | 558 | return None; |
558 | } | 559 | } |