Skip to content

Commit 87436a0

Browse files
committed
fix super path wrong display
1 parent 880af42 commit 87436a0

File tree

2 files changed

+29
-5
lines changed

2 files changed

+29
-5
lines changed

crates/hir_ty/src/display.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,13 +1141,15 @@ impl HirDisplay for Path {
11411141
write!(f, ">")?;
11421142
}
11431143
(_, PathKind::Plain) => {}
1144-
(_, PathKind::Abs) => write!(f, "")?,
1144+
(_, PathKind::Abs) => {}
11451145
(_, PathKind::Crate) => write!(f, "crate")?,
11461146
(_, PathKind::Super(0)) => write!(f, "self")?,
11471147
(_, PathKind::Super(n)) => {
1148-
write!(f, "super")?;
1149-
for _ in 0..*n {
1150-
write!(f, "::super")?;
1148+
for i in 0..*n {
1149+
if i > 0 {
1150+
write!(f, "::")?;
1151+
}
1152+
write!(f, "super")?;
11511153
}
11521154
}
11531155
(_, PathKind::DollarCrate(_)) => write!(f, "{{extern_crate}}")?,

crates/ide/src/hover.rs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -963,7 +963,7 @@ fn main() { let foo_test = fo$0o(); }
963963
"#]],
964964
);
965965

966-
// use literal `crate` in path
966+
// Use literal `crate` in path
967967
check(
968968
r#"
969969
pub struct X;
@@ -984,6 +984,28 @@ fn main() { f$0oo(); }
984984
```
985985
"#]],
986986
);
987+
988+
// Check `super` in path
989+
check(
990+
r#"
991+
pub struct X;
992+
993+
mod m { pub fn foo() -> super::X { super::X } }
994+
995+
fn main() { m::f$0oo(); }
996+
"#,
997+
expect![[r#"
998+
*foo*
999+
1000+
```rust
1001+
test::m
1002+
```
1003+
1004+
```rust
1005+
pub fn foo() -> super::X
1006+
```
1007+
"#]],
1008+
);
9871009
}
9881010

9891011
#[test]

0 commit comments

Comments
 (0)