mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-23 19:43:23 +00:00
Show const body in short_label
Signed-off-by: JmPotato <ghzpotato@gmail.com>
This commit is contained in:
parent
7a03f05eac
commit
4d9c8821e5
2 changed files with 13 additions and 5 deletions
|
@ -61,7 +61,15 @@ impl ShortLabel for ast::TypeAlias {
|
|||
|
||||
impl ShortLabel for ast::Const {
|
||||
fn short_label(&self) -> Option<String> {
|
||||
short_label_from_ty(self, self.ty(), "const ")
|
||||
match short_label_from_ty(self, self.ty(), "const ") {
|
||||
Some(buf) => {
|
||||
let mut new_buf = buf;
|
||||
let body = self.body().unwrap();
|
||||
format_to!(new_buf, " = {}", body.syntax());
|
||||
Some(new_buf)
|
||||
}
|
||||
None => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -590,16 +590,16 @@ fn main() {
|
|||
#[test]
|
||||
fn hover_const_static() {
|
||||
check(
|
||||
r#"const foo<|>: u32 = 0;"#,
|
||||
r#"const foo<|>: u32 = 123;"#,
|
||||
expect![[r#"
|
||||
*foo*
|
||||
```rust
|
||||
const foo: u32
|
||||
const foo: u32 = 123
|
||||
```
|
||||
"#]],
|
||||
);
|
||||
check(
|
||||
r#"static foo<|>: u32 = 0;"#,
|
||||
r#"static foo<|>: u32 = 456;"#,
|
||||
expect![[r#"
|
||||
*foo*
|
||||
```rust
|
||||
|
@ -834,7 +834,7 @@ fn main() {
|
|||
expect![[r#"
|
||||
*C*
|
||||
```rust
|
||||
const C: u32
|
||||
const C: u32 = 1
|
||||
```
|
||||
"#]],
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue