]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/src/docs/disallowed_types.txt
Auto merge of #104673 - matthiaskrgr:rollup-85f65ov, r=matthiaskrgr
[rust.git] / src / tools / clippy / src / docs / disallowed_types.txt
1 ### What it does
2 Denies the configured types in clippy.toml.
3
4 Note: Even though this lint is warn-by-default, it will only trigger if
5 types are defined in the clippy.toml file.
6
7 ### Why is this bad?
8 Some types are undesirable in certain contexts.
9
10 ### Example:
11 An example clippy.toml configuration:
12 ```
13 disallowed-types = [
14     # Can use a string as the path of the disallowed type.
15     "std::collections::BTreeMap",
16     # Can also use an inline table with a `path` key.
17     { path = "std::net::TcpListener" },
18     # When using an inline table, can add a `reason` for why the type
19     # is disallowed.
20     { path = "std::net::Ipv4Addr", reason = "no IPv4 allowed" },
21 ]
22 ```
23
24 ```
25 use std::collections::BTreeMap;
26 // or its use
27 let x = std::collections::BTreeMap::new();
28 ```
29 Use instead:
30 ```
31 // A similar type that is allowed by the config
32 use std::collections::HashMap;
33 ```