Skip to content

Commit 4d9c882

Browse files
committed
Show const body in short_label
Signed-off-by: JmPotato <[email protected]>
1 parent 7a03f05 commit 4d9c882

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

crates/ra_ide/src/display/short_label.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,15 @@ impl ShortLabel for ast::TypeAlias {
6161

6262
impl ShortLabel for ast::Const {
6363
fn short_label(&self) -> Option<String> {
64-
short_label_from_ty(self, self.ty(), "const ")
64+
match short_label_from_ty(self, self.ty(), "const ") {
65+
Some(buf) => {
66+
let mut new_buf = buf;
67+
let body = self.body().unwrap();
68+
format_to!(new_buf, " = {}", body.syntax());
69+
Some(new_buf)
70+
}
71+
None => None,
72+
}
6573
}
6674
}
6775

crates/ra_ide/src/hover.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -590,16 +590,16 @@ fn main() {
590590
#[test]
591591
fn hover_const_static() {
592592
check(
593-
r#"const foo<|>: u32 = 0;"#,
593+
r#"const foo<|>: u32 = 123;"#,
594594
expect![[r#"
595595
*foo*
596596
```rust
597-
const foo: u32
597+
const foo: u32 = 123
598598
```
599599
"#]],
600600
);
601601
check(
602-
r#"static foo<|>: u32 = 0;"#,
602+
r#"static foo<|>: u32 = 456;"#,
603603
expect![[r#"
604604
*foo*
605605
```rust
@@ -834,7 +834,7 @@ fn main() {
834834
expect![[r#"
835835
*C*
836836
```rust
837-
const C: u32
837+
const C: u32 = 1
838838
```
839839
"#]],
840840
)

0 commit comments

Comments
 (0)