mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-13 21:54:42 +00:00
fix: path display error when start with crate
This commit is contained in:
parent
86ebc36fa3
commit
82ae228d98
2 changed files with 20 additions and 1 deletions
|
@ -1154,7 +1154,7 @@ impl HirDisplay for Path {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (seg_idx, segment) in self.segments().iter().enumerate() {
|
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, "::")?;
|
||||||
}
|
}
|
||||||
write!(f, "{}", segment.name)?;
|
write!(f, "{}", segment.name)?;
|
||||||
|
|
|
@ -962,6 +962,25 @@ fn main() { let foo_test = fo$0o(); }
|
||||||
```
|
```
|
||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// 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]
|
#[test]
|
||||||
|
|
Loading…
Reference in a new issue