Added more consteval tests and fixed consteval result

This commit is contained in:
OleStrohm 2022-08-07 18:42:59 +02:00
parent ad0a6bf1a3
commit 301b8894ea
4 changed files with 18 additions and 45 deletions

View file

@ -351,7 +351,7 @@ pub(super) fn definition(
Definition::Variant(it) => label_value_and_docs(db, it, |&it| {
if it.parent.is_data_carrying(db) {
match it.eval(db) {
Ok(x) => Some(format!("{}", x.enum_value().unwrap_or(x))),
Ok(x) => Some(format!("{}", x)),
Err(_) => it.value(db).map(|x| format!("{:?}", x)),
}
} else {

View file

@ -3530,31 +3530,6 @@ impl<const LEN: usize> Foo<LEN$0> {}
#[test]
fn hover_const_eval_variant() {
check(
r#"
#[repr(u8)]
enum E {
A = 4,
/// This is a doc
B$0 = E::A as u8 + 1,
}
"#,
expect![[r#"
*B*
```rust
test::E
```
```rust
B = 5
```
---
This is a doc
"#]],
);
// show hex for <10
check(
r#"