Signed-off-by: JmPotato <ghzpotato@gmail.com>
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,
+ }
}
}
#[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
expect![[r#"
*C*
```rust
- const C: u32
+ const C: u32 = 1
```
"#]],
)