Skip to content

Commit 82ae228

Browse files
committed
fix: path display error when start with crate
1 parent 86ebc36 commit 82ae228

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

crates/hir_ty/src/display.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1154,7 +1154,7 @@ impl HirDisplay for Path {
11541154
}
11551155

11561156
for (seg_idx, segment) in self.segments().iter().enumerate() {
1157-
if seg_idx != 0 {
1157+
if seg_idx != 0 || matches!(self.kind(), PathKind::Crate) {
11581158
write!(f, "::")?;
11591159
}
11601160
write!(f, "{}", segment.name)?;

crates/ide/src/hover.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -962,6 +962,25 @@ fn main() { let foo_test = fo$0o(); }
962962
```
963963
"#]],
964964
);
965+
966+
// use literal `crate` in path
967+
check(r#"
968+
pub struct X;
969+
970+
fn foo() -> crate::X { X }
971+
972+
fn main() { f$0oo(); }
973+
"#, expect![[r#"
974+
*foo*
975+
976+
```rust
977+
test
978+
```
979+
980+
```rust
981+
fn foo() -> crate::X
982+
```
983+
"#]]);
965984
}
966985

967986
#[test]

0 commit comments

Comments
 (0)