diff options
Diffstat (limited to 'crates/ra_assists/src/assists/add_import.rs')
-rw-r--r-- | crates/ra_assists/src/assists/add_import.rs | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/crates/ra_assists/src/assists/add_import.rs b/crates/ra_assists/src/assists/add_import.rs index 363ade016..b8752cbad 100644 --- a/crates/ra_assists/src/assists/add_import.rs +++ b/crates/ra_assists/src/assists/add_import.rs | |||
@@ -578,17 +578,21 @@ fn apply_auto_import( | |||
578 | 578 | ||
579 | fn collect_hir_path_segments(path: &hir::Path) -> Option<Vec<SmolStr>> { | 579 | fn collect_hir_path_segments(path: &hir::Path) -> Option<Vec<SmolStr>> { |
580 | let mut ps = Vec::<SmolStr>::with_capacity(10); | 580 | let mut ps = Vec::<SmolStr>::with_capacity(10); |
581 | match path.kind { | 581 | match path.kind() { |
582 | hir::PathKind::Abs => ps.push("".into()), | 582 | hir::PathKind::Abs => ps.push("".into()), |
583 | hir::PathKind::Crate => ps.push("crate".into()), | 583 | hir::PathKind::Crate => ps.push("crate".into()), |
584 | hir::PathKind::Plain => {} | 584 | hir::PathKind::Plain => {} |
585 | hir::PathKind::Self_ => ps.push("self".into()), | 585 | hir::PathKind::Super(0) => ps.push("self".into()), |
586 | hir::PathKind::Super => ps.push("super".into()), | 586 | hir::PathKind::Super(lvl) => { |
587 | hir::PathKind::Type(_) | hir::PathKind::DollarCrate(_) => return None, | 587 | let mut chain = "super".to_string(); |
588 | } | 588 | for _ in 0..*lvl { |
589 | for s in path.segments.iter() { | 589 | chain += "::super"; |
590 | ps.push(s.name.to_string().into()); | 590 | } |
591 | ps.push(chain.into()); | ||
592 | } | ||
593 | hir::PathKind::DollarCrate(_) => return None, | ||
591 | } | 594 | } |
595 | ps.extend(path.segments().iter().map(|it| it.name.to_string().into())); | ||
592 | Some(ps) | 596 | Some(ps) |
593 | } | 597 | } |
594 | 598 | ||