Derive macro giving trouble with the rust-analyser in VSCode when I add to Serde

I'm using Axum and created a datatype as below. I also included the Serde crate.

#[derive(Serialize)]
struct MyData {
    id: String,
    data: HashMap<String, String>,
}

By default, the derive(Serialize) macro does not seem to work on a struct I created. I get a "Cannot find derive macro 'Serialize' in this scope" message in VSCode on MacOS.

I went to the Cargo.toml and edited the Serde entry to the following:

serde = {"1.0.197", features = ["derive"]}

Now the code is fine, but the rust-analyser gives me the below error:

ERROR flycheck: Flycheck failed to run the following command: CommandHandle { program: "/Users/<username>/.cargo/bin/cargo", arguments: ["check", "--workspace", "--message-format=json-diagnostic-rendered-ansi", "--manifest-path", "/Users/<username>/repos/learn-rust/gupt/Cargo.toml", "--all-targets"], current_dir: Some("/Users/<username>/repos/learn-rust/gupt") }

Looking it up online and running rustup update or other similar recommended fixes doesn't resolve the issue. Could I get some help?

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.