2 Checks for use of `crate` as opposed to `$crate` in a macro definition.
5 `crate` refers to the macro call's crate, whereas `$crate` refers to the macro definition's
6 crate. Rarely is the former intended. See:
7 https://doc.rust-lang.org/reference/macros-by-example.html#hygiene
12 macro_rules! print_message {
14 println!("{}", crate::MESSAGE);
17 pub const MESSAGE: &str = "Hello!";
22 macro_rules! print_message {
24 println!("{}", $crate::MESSAGE);
27 pub const MESSAGE: &str = "Hello!";
30 Note that if the use of `crate` is intentional, an `allow` attribute can be applied to the
31 macro definition, e.g.:
33 #[allow(clippy::crate_in_macro_def)]
34 macro_rules! ok { ... crate::foo ... }