Unnamed repository; edit this file 'description' to name the repository.
fix `super` path wrong display
Dezhi Wu 2021-09-07
parent 880af42 · commit 87436a0
-rw-r--r--crates/hir_ty/src/display.rs10
-rw-r--r--crates/ide/src/hover.rs24
2 files changed, 29 insertions, 5 deletions
diff --git a/crates/hir_ty/src/display.rs b/crates/hir_ty/src/display.rs
index e394b72d5d..1ae718a36b 100644
--- a/crates/hir_ty/src/display.rs
+++ b/crates/hir_ty/src/display.rs
@@ -1141,13 +1141,15 @@ impl HirDisplay for Path {
write!(f, ">")?;
}
(_, PathKind::Plain) => {}
- (_, PathKind::Abs) => write!(f, "")?,
+ (_, PathKind::Abs) => {}
(_, PathKind::Crate) => write!(f, "crate")?,
(_, PathKind::Super(0)) => write!(f, "self")?,
(_, PathKind::Super(n)) => {
- write!(f, "super")?;
- for _ in 0..*n {
- write!(f, "::super")?;
+ for i in 0..*n {
+ if i > 0 {
+ write!(f, "::")?;
+ }
+ write!(f, "super")?;
}
}
(_, PathKind::DollarCrate(_)) => write!(f, "{{extern_crate}}")?,
diff --git a/crates/ide/src/hover.rs b/crates/ide/src/hover.rs
index f9000ca000..62a322f976 100644
--- a/crates/ide/src/hover.rs
+++ b/crates/ide/src/hover.rs
@@ -963,7 +963,7 @@ fn main() { let foo_test = fo$0o(); }
"#]],
);
- // use literal `crate` in path
+ // Use literal `crate` in path
check(
r#"
pub struct X;
@@ -984,6 +984,28 @@ fn main() { f$0oo(); }
```
"#]],
);
+
+ // Check `super` in path
+ check(
+ r#"
+pub struct X;
+
+mod m { pub fn foo() -> super::X { super::X } }
+
+fn main() { m::f$0oo(); }
+ "#,
+ expect![[r#"
+ *foo*
+
+ ```rust
+ test::m
+ ```
+
+ ```rust
+ pub fn foo() -> super::X
+ ```
+ "#]],
+ );
}
#[test]