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.

False Error with strum #[derive(Display)]: enum doesn't implement Display

See original GitHub issue

Environment

  • IntelliJ Rust plugin version: 0.4.170.4627-221
  • Rust toolchain version: 1.60.0
  • IDE name and version: CLion 2022.1.1
  • Operating system: Windows 11

Problem description

After using strum to derive Display causes the IDE to report that enum does not implement the Display trait when trying to print it. image

Steps to reproduce

This code compiles and runs correctly, yet reports an error both with and without external linter enabled.

[package]
name = "bugexample"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
strum = "0.24"
strum_macros = "0.24"
use strum_macros::Display;

#[derive(Display)]
enum Example {
    VariantA,
    VariantB
}

fn main() {
    println!("{} {}", Example::VariantA, Example::VariantB);
}

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
Undincommented, May 17, 2022

Hey @pedrofgodinho have you tried invalidating the cache as suggested by @Undin here?

It shouldn’t help in this case since the reasons differ. Cache invalidation may help in some weird situations when something stops working unexpectedly (for example, after upgrading). In some cases, it’s caused by cache corruption and, as a result, cache invalidation helps

The current example is about procedural macro support. And the support is not enabled by default for now @pedrofgodinho Try to enable org.rust.cargo.evaluate.build.scripts and org.rust.macros.proc experimental features to turn it on and reload the project model via Refresh Cargo Projects action. See #6908 for more details

0reactions
Undincommented, May 18, 2022

Let’s keep it open since procedural macro expansion is not enabled by default yet

Read more comments on GitHub >

github_iconTop Results From Across the Web

strum - Rust - Docs.rs
Display , ToString : both derives print out the given enum variant. This enables you to perform round trip style conversions from enum...
Read more >
Implementing fmt::Display for enum with fields - rust
The problem here is that your match arm binding f: &u32 shadows the value parameter f: &mut Formatter . So instead of passing...
Read more >
strum - crates.io: Rust Package Registry
Strum is a set of macros and traits for working with enums and strings ... use std::string::ToString; #[derive(Display, Debug)] enum Color ...
Read more >
How can I implement fmt::Display for Enum - Rust Users Forum
error[E0277 ]: `Day` doesn't implement `std::fmt::Display` ... #[derive(Debug)] enum Day { Saturday, Sunday ,Monday, Tuesday, Wednesday, Thursday, Friday }.
Read more >
Procedural macros — list of Rust libraries/crates // Lib.rs
strum. Helpful macros for working with enums and strings ... A derive macro for implementing the display Trait via a doc comment and...
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