mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-03 07:04:49 +00:00
Added more consteval tests and fixed consteval result
This commit is contained in:
parent
ad0a6bf1a3
commit
301b8894ea
4 changed files with 18 additions and 45 deletions
|
@ -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 {
|
||||
|
|
|
@ -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#"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue