mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-26 11:59:49 +00:00
Bring back the hex in const hover
This commit is contained in:
parent
e6ba791dce
commit
ae8ce99d97
4 changed files with 66 additions and 12 deletions
|
@ -432,9 +432,9 @@ pub(super) fn definition(
|
|||
}
|
||||
}),
|
||||
Definition::Const(it) => label_value_and_docs(db, it, |it| {
|
||||
let body = it.eval(db);
|
||||
let body = it.render_eval(db);
|
||||
match body {
|
||||
Ok(x) => Some(format!("{}", x.display(db))),
|
||||
Ok(x) => Some(x),
|
||||
Err(_) => {
|
||||
let source = it.source(db)?;
|
||||
let mut body = source.value.body()?.syntax().clone();
|
||||
|
|
|
@ -531,7 +531,7 @@ fn hover_const_static() {
|
|||
```
|
||||
|
||||
```rust
|
||||
const foo: u32 = 123
|
||||
const foo: u32 = 123 (0x7B)
|
||||
```
|
||||
"#]],
|
||||
);
|
||||
|
@ -3770,7 +3770,6 @@ const FOO$0: usize = 1 << 3;
|
|||
This is a doc
|
||||
"#]],
|
||||
);
|
||||
// FIXME: show hex for >10
|
||||
check(
|
||||
r#"
|
||||
/// This is a doc
|
||||
|
@ -3784,7 +3783,7 @@ const FOO$0: usize = (1 << 3) + (1 << 2);
|
|||
```
|
||||
|
||||
```rust
|
||||
const FOO: usize = 12
|
||||
const FOO: usize = 12 (0xC)
|
||||
```
|
||||
|
||||
---
|
||||
|
@ -3828,7 +3827,7 @@ const FOO$0: i32 = 2 - 3;
|
|||
```
|
||||
|
||||
```rust
|
||||
const FOO: i32 = -1
|
||||
const FOO: i32 = -1 (0xFFFFFFFF)
|
||||
```
|
||||
|
||||
---
|
||||
|
@ -3915,7 +3914,7 @@ const FOO$0: u8 = b'a';
|
|||
```
|
||||
|
||||
```rust
|
||||
const FOO: u8 = 97
|
||||
const FOO: u8 = 97 (0x61)
|
||||
```
|
||||
|
||||
---
|
||||
|
@ -3937,7 +3936,7 @@ const FOO$0: u8 = b'\x61';
|
|||
```
|
||||
|
||||
```rust
|
||||
const FOO: u8 = 97
|
||||
const FOO: u8 = 97 (0x61)
|
||||
```
|
||||
|
||||
---
|
||||
|
@ -3989,6 +3988,28 @@ const FOO$0: f32 = 1f32;
|
|||
This is a doc
|
||||
"#]],
|
||||
);
|
||||
// Don't show `<ref-not-supported>` in const hover
|
||||
check(
|
||||
r#"
|
||||
/// This is a doc
|
||||
const FOO$0: &i32 = &2;
|
||||
"#,
|
||||
expect![[r#"
|
||||
*FOO*
|
||||
|
||||
```rust
|
||||
test
|
||||
```
|
||||
|
||||
```rust
|
||||
const FOO: &i32 = &2
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
This is a doc
|
||||
"#]],
|
||||
);
|
||||
//show f64 typecasted from float
|
||||
check(
|
||||
r#"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue