mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-14 17:07:26 +00:00
fix super
path wrong display
This commit is contained in:
parent
880af425d4
commit
87436a08fa
2 changed files with 29 additions and 5 deletions
|
@ -1141,13 +1141,15 @@ impl HirDisplay for Path {
|
|||
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}}")?,
|
||||
|
|
|
@ -963,7 +963,7 @@ fn main() { let foo_test = fo$0o(); }
|
|||
"#]],
|
||||
);
|
||||
|
||||
// use literal `crate` in path
|
||||
// Use literal `crate` in path
|
||||
check(
|
||||
r#"
|
||||
pub struct X;
|
||||
|
@ -984,6 +984,28 @@ fn main() { f$0oo(); }
|
|||
```
|
||||
"#]],
|
||||
);
|
||||
|
||||
// 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]
|
||||
|
|
Loading…
Reference in a new issue