mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-28 20:16:58 +03:00
fix: path display error when start with crate
This commit is contained in:
@@ -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)?;
|
||||
|
||||
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user