### What it does Checks for use of `crate` as opposed to `$crate` in a macro definition. ### Why is this bad? `crate` refers to the macro call's crate, whereas `$crate` refers to the macro definition's crate. Rarely is the former intended. See: https://doc.rust-lang.org/reference/macros-by-example.html#hygiene ### Example ``` #[macro_export] macro_rules! print_message { () => { println!("{}", crate::MESSAGE); }; } pub const MESSAGE: &str = "Hello!"; ``` Use instead: ``` #[macro_export] macro_rules! print_message { () => { println!("{}", $crate::MESSAGE); }; } pub const MESSAGE: &str = "Hello!"; ``` Note that if the use of `crate` is intentional, an `allow` attribute can be applied to the macro definition, e.g.: ``` #[allow(clippy::crate_in_macro_def)] macro_rules! ok { ... crate::foo ... } ```