fix: path display error when start with crate

This commit is contained in:
Dezhi Wu
2021-09-07 14:44:30 +08:00
parent 86ebc36fa3
commit 82ae228d98
2 changed files with 20 additions and 1 deletions
+1 -1
View File
@@ -1154,7 +1154,7 @@ fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
}
for (seg_idx, segment) in self.segments().iter().enumerate() {
if seg_idx != 0 {
if seg_idx != 0 || matches!(self.kind(), PathKind::Crate) {
write!(f, "::")?;
}
write!(f, "{}", segment.name)?;
+19
View File
@@ -962,6 +962,25 @@ pub fn foo(a: u32, b: u32) {}
```
"#]],
);
// use literal `crate` in path
check(r#"
pub struct X;
fn foo() -> crate::X { X }
fn main() { f$0oo(); }
"#, expect![[r#"
*foo*
```rust
test
```
```rust
fn foo() -> crate::X
```
"#]]);
}
#[test]