mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 05:15:04 +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, ">")?;
|
write!(f, ">")?;
|
||||||
}
|
}
|
||||||
(_, PathKind::Plain) => {}
|
(_, PathKind::Plain) => {}
|
||||||
(_, PathKind::Abs) => write!(f, "")?,
|
(_, PathKind::Abs) => {}
|
||||||
(_, PathKind::Crate) => write!(f, "crate")?,
|
(_, PathKind::Crate) => write!(f, "crate")?,
|
||||||
(_, PathKind::Super(0)) => write!(f, "self")?,
|
(_, PathKind::Super(0)) => write!(f, "self")?,
|
||||||
(_, PathKind::Super(n)) => {
|
(_, PathKind::Super(n)) => {
|
||||||
|
for i in 0..*n {
|
||||||
|
if i > 0 {
|
||||||
|
write!(f, "::")?;
|
||||||
|
}
|
||||||
write!(f, "super")?;
|
write!(f, "super")?;
|
||||||
for _ in 0..*n {
|
|
||||||
write!(f, "::super")?;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(_, PathKind::DollarCrate(_)) => write!(f, "{{extern_crate}}")?,
|
(_, 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(
|
check(
|
||||||
r#"
|
r#"
|
||||||
pub struct X;
|
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]
|
#[test]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue