Error

"cannot find macro" — How to Fix

Fix the 'cannot find macro' error by adding the missing crate to Cargo.toml and using the #[macro_use] attribute or a use statement.

The "cannot find macro" error occurs because the macro is not in scope or the crate defining it is missing from your dependencies. Add the missing crate to your Cargo.toml and bring the macro into scope with a use statement or the #[macro_use] attribute.

// Cargo.toml
[dependencies]
my_macro_crate = "1.0"

// src/main.rs
#[macro_use]
extern crate my_macro_crate;

fn main() {
    my_macro!();
}