question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

enum_dispatch cannot be properly indexed

See original GitHub issue

Environment

  • 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.

image

If I use simple version enum, it can be indexed.

#[enum_dispatch(DataType)]
enum DataTypeImpl {
    Foo,
    Bar,
}
image

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
antonok-edmcommented, May 6, 2022

@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 😅

1reaction
vlad20012commented, May 7, 2022

@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 and enum_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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found