RS.CLIPPY.DISALLOWED_MACROS

Use of a disallowed macro

This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: disallowed_macros. Copyright ©2025 The Rust Team. All rights reserved.

What it does

Denies the configured macros in clippy.toml

Note: Even though this lint is warn-by-default, it will only trigger if macros are defined in the clippy.toml file.

Why is this bad?

Some macros are undesirable in certain contexts, and it's beneficial to lint for them as needed.

Example

An example clippy.toml configuration:

disallowed-macros = [
    # Can use a string as the path of the disallowed macro.
    "std::print",
    # Can also use an inline table with a `path` key.
    { path = "std::println" },
    # When using an inline table, can add a `reason` for why the macro
    # is disallowed.
    { path = "serde::Serialize", reason = "no serializing" },
]
use serde::Serialize;

println!("warns");

// The diagnostic will contain the message "no serializing"
#[derive(Serialize)]
struct Data {
    name: String,
    value: usize,
}

Configuration

  • disallowed-macros: The list of disallowed macros, written as fully qualified paths.

    (default: [])