rust-analyzer/crates/ide-db/src
bors 817a6a8609 Auto merge of #12966 - OleStrohm:master, r=Veykril
feat: Display the value of enum variant on hover

fixes #12955

This PR adds const eval support for enums, as well as showing their value on hover, just as consts currently have.

I developed these two things at the same time, but I've realized now that they are separate. However since the hover is just a 10 line change (not including tests), I figured I may as well put them in the same PR. Though if you want them split up into "enum const eval support"  and "show enum variant value on hover", I think that's reasonable too.

Since this adds const eval support for enums this also allows consts that reference enums to have their values computed now too.

The const evaluation itself is quite rudimentary, it doesn't keep track of the actual type of the enum, but it turns out that Rust doesn't actually either, and `E::A as u8` is valid regardless of the `repr` on `E`.

It also doesn't really care about what expression the enum variant contains, it could for example be a string, despite that not being allowed, but I guess it's up to the `cargo check` diagnostics to inform of such issues anyway?
2022-09-20 14:01:16 +00:00
..
generated style: rename crates to kebab case 2022-05-01 10:48:58 +00:00
imports Restructure find_path into a separate functions for modules and non-module items 2022-09-13 15:15:27 +02:00
syntax_helpers suggest ExtractRefactor if no expressions found 2022-09-11 10:39:25 +05:30
test_data style: rename crates to kebab case 2022-05-01 10:48:58 +00:00
tests Run cargo fix --edition-idioms 2022-07-20 15:02:08 +02:00
active_parameter.rs complete full struct in enum varaint 2022-09-05 03:36:14 +08:00
apply_change.rs minor: Change tracing event level in apply_change 2022-08-17 09:32:25 +02:00
assists.rs style: rename crates to kebab case 2022-05-01 10:48:58 +00:00
defs.rs feat: Handle operators like their trait functions in the IDE 2022-08-05 14:16:36 +02:00
famous_defs.rs Improve "Generate Deref impl" assist 2022-05-16 20:10:46 +02:00
helpers.rs Run cargo fix --edition-idioms 2022-07-20 15:02:08 +02:00
items_locator.rs style: rename crates to kebab case 2022-05-01 10:48:58 +00:00
label.rs style: rename crates to kebab case 2022-05-01 10:48:58 +00:00
lib.rs wip 2022-09-10 20:13:46 +05:30
line_index.rs Make use of NoHash hashing for FileId and CrateId 2022-08-25 20:41:49 +02:00
path_transform.rs Add config to unconditionally prefer core imports over std 2022-09-09 20:04:56 +02:00
rename.rs fix: a bunch of typos 2022-08-17 21:44:58 +08:00
rust_doc.rs style: rename crates to kebab case 2022-05-01 10:48:58 +00:00
search.rs Auto merge of #12966 - OleStrohm:master, r=Veykril 2022-09-20 14:01:16 +00:00
source_change.rs Make use of NoHash hashing for FileId and CrateId 2022-08-25 20:41:49 +02:00
symbol_index.rs Run cargo fix --edition-idioms 2022-07-20 15:02:08 +02:00
traits.rs Run cargo fix --edition-idioms 2022-07-20 15:02:08 +02:00
ty_filter.rs Run cargo fix --edition-idioms 2022-07-20 15:02:08 +02:00
use_trivial_contructor.rs add doc strings to use_trivial_contructor.rs 2022-06-22 16:49:50 +02:00