mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-28 20:16:58 +03:00
fix super path wrong display
This commit is contained in:
@@ -1141,13 +1141,15 @@ fn hir_fmt(&self, f: &mut HirFormatter) -> Result<(), HirDisplayError> {
|
||||
write!(f, ">")?;
|
||||
}
|
||||
(_, PathKind::Plain) => {}
|
||||
(_, PathKind::Abs) => write!(f, "")?,
|
||||
(_, PathKind::Abs) => {}
|
||||
(_, PathKind::Crate) => write!(f, "crate")?,
|
||||
(_, PathKind::Super(0)) => write!(f, "self")?,
|
||||
(_, PathKind::Super(n)) => {
|
||||
write!(f, "super")?;
|
||||
for _ in 0..*n {
|
||||
write!(f, "::super")?;
|
||||
for i in 0..*n {
|
||||
if i > 0 {
|
||||
write!(f, "::")?;
|
||||
}
|
||||
write!(f, "super")?;
|
||||
}
|
||||
}
|
||||
(_, PathKind::DollarCrate(_)) => write!(f, "{{extern_crate}}")?,
|
||||
|
||||
+23
-1
@@ -963,7 +963,7 @@ pub fn foo(a: u32, b: u32) {}
|
||||
"#]],
|
||||
);
|
||||
|
||||
// use literal `crate` in path
|
||||
// Use literal `crate` in path
|
||||
check(
|
||||
r#"
|
||||
pub struct X;
|
||||
@@ -984,6 +984,28 @@ fn foo() -> crate::X
|
||||
```
|
||||
"#]],
|
||||
);
|
||||
|
||||
// Check `super` in path
|
||||
check(
|
||||
r#"
|
||||
pub struct X;
|
||||
|
||||
mod m { pub fn foo() -> super::X { super::X } }
|
||||
|
||||
fn main() { m::f$0oo(); }
|
||||
"#,
|
||||
expect![[r#"
|
||||
*foo*
|
||||
|
||||
```rust
|
||||
test::m
|
||||
```
|
||||
|
||||
```rust
|
||||
pub fn foo() -> super::X
|
||||
```
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user