]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/src/docs/disallowed_macros.txt
Rollup merge of #101118 - devnexen:fs_getmode_bsd, r=Mark-Simulacrum
[rust.git] / src / tools / clippy / src / docs / disallowed_macros.txt
1 ### What it does
2 Denies the configured macros in clippy.toml
3
4 Note: Even though this lint is warn-by-default, it will only trigger if
5 macros are defined in the clippy.toml file.
6
7 ### Why is this bad?
8 Some macros are undesirable in certain contexts, and it's beneficial to
9 lint for them as needed.
10
11 ### Example
12 An example clippy.toml configuration:
13 ```
14 disallowed-macros = [
15     # Can use a string as the path of the disallowed macro.
16     "std::print",
17     # Can also use an inline table with a `path` key.
18     { path = "std::println" },
19     # When using an inline table, can add a `reason` for why the macro
20     # is disallowed.
21     { path = "serde::Serialize", reason = "no serializing" },
22 ]
23 ```
24 ```
25 use serde::Serialize;
26
27 // Example code where clippy issues a warning
28 println!("warns");
29
30 // The diagnostic will contain the message "no serializing"
31 #[derive(Serialize)]
32 struct Data {
33     name: String,
34     value: usize,
35 }
36 ```