enum_dispatch cannot be properly indexed
See original GitHub issueEnvironment
- IntelliJ Rust plugin version: 0.4.162.4321-212
- Rust toolchain version: nightly-2022-04-03-aarch64-apple-darwin
- IDE name and version: Clion 21.2.3
- Operating system: Darwin m1max.local 21.3.0 Darwin Kernel Version 21.3.0 arm64
Problem description
Steps to reproduce
Use enum_dispatch
can’t be properly indexed.

If I use simple version enum, it can be indexed.
#[enum_dispatch(DataType)]
enum DataTypeImpl {
Foo,
Bar,
}

Issue Analytics
- State:
- Created a year ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
enum_dispatch - Rust - Docs.rs
enum_dispatch ` provides a set of macros that can be used to easily refactor dynamically dispatched trait accesses to improve their performance by...
Read more >Dispatch on enumerated type without match? : r/rust - Reddit
I'm working with LLVM IR, using the llvm-ir crate . llvm-ir uses, not unreasonably, an enum to represent LLVM instructions.
Read more >Sealed protocols - Pitches - Swift Forums
We should support this for all protocols which cannot be conformed to outside the module. ... Well, for one thing, open is more...
Read more >rust - Match on pair of enum when both are of the same kind
SomeTrait (as well as Interpolate ) isn't object safe, so you can't solve this with dynamic dispatch either. Am I missing something? –...
Read more >Rust patterns — list of Rust libraries/crates // Lib.rs
Safe, strongly typed array indexes and wrappers for rust with zero dependencies ... local errors (which can be handled) and fatal errors (which...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@vlad20012 I’m the author of
enum_dispatch
, please let me know if there’s anything I can do to make it more IDE-friendly! In particular, if you have a list of the "imaginable rule"s, I’d be happy to look into following them. I wasn’t aware such a list existed 😅@sundy-li It works in rust-analyzer by chance. And it doesn’t work if you start modifying a enum or a trait under
enum_dispath
macro. In short, rust-analyzer uses single long-living process that expands macros for all crates. IntelliJ Rust uses up to 4 processes that expands macors in parallel. Hence,enum_dispatch
macro for a enum andenum_dispatch
macro for a trait may fall into different processes and be expanded without knowing each other.P.S. Don’t try fixing it from the IDE side. Such stateful macros just should not exist. In some day they will stop working even in rustc.