5

I ran this code on my previous desktop and it worked fine:

use serde::Deserialize;

#[derive(Deserialize)]
struct Foo {
    bar: i64,
}

fn main() {}

Cargo.toml:

[dependencies]
serde = "1.0"

but now I see

error: cannot find derive macro `Deserialize` in this scope
  --> src/main.rs:1:5
   |
2  | #[derive(Deserialize)]
   |          ^^^^^^^^^^^

warning: unused import: `serde::Deserialize`
  --> src/main.rs:2:10
   |
1  | use serde::Deserialize;
   |     ^^^^^^^^^^^^^^^^^^
   |
   = note: #[warn(unused_imports)] on by default

What can cause the issue? I'm using Rust 1.33.0.

Shepmaster
  • 388,571
  • 95
  • 1,107
  • 1,366
Alex
  • 579
  • 1
  • 6
  • 14
  • 11
    You should add enable serde derive macros by adding the following to you cargo.toml `[dependencies] serde = { version = "1.0", features = ["derive"] }` – Thom Mar 26 '19 at 19:18

0 Answers0