]> git.lizzy.rs Git - rust.git/blob - clippy_utils/src/paths.rs
Add manual_bits lint
[rust.git] / clippy_utils / src / paths.rs
1 //! This module contains paths to types and functions Clippy needs to know
2 //! about.
3 //!
4 //! Whenever possible, please consider diagnostic items over hardcoded paths.
5 //! See <https://github.com/rust-lang/rust-clippy/issues/5393> for more information.
6
7 pub const ANY_TRAIT: [&str; 3] = ["core", "any", "Any"];
8 #[cfg(feature = "internal")]
9 pub const APPLICABILITY: [&str; 2] = ["rustc_lint_defs", "Applicability"];
10 #[cfg(feature = "internal")]
11 pub const APPLICABILITY_VALUES: [[&str; 3]; 4] = [
12     ["rustc_lint_defs", "Applicability", "Unspecified"],
13     ["rustc_lint_defs", "Applicability", "HasPlaceholders"],
14     ["rustc_lint_defs", "Applicability", "MaybeIncorrect"],
15     ["rustc_lint_defs", "Applicability", "MachineApplicable"],
16 ];
17 #[cfg(feature = "internal")]
18 pub const DIAGNOSTIC_BUILDER: [&str; 3] = ["rustc_errors", "diagnostic_builder", "DiagnosticBuilder"];
19 pub const ARC_PTR_EQ: [&str; 4] = ["alloc", "sync", "Arc", "ptr_eq"];
20 #[allow(clippy::invalid_paths)] // `check_path` does not seem to work for macros
21 pub const ASSERT_EQ_MACRO: [&str; 3] = ["core", "macros", "assert_eq"];
22 #[allow(clippy::invalid_paths)] // `check_path` does not seem to work for macros
23 pub const ASSERT_MACRO: [&str; 4] = ["core", "macros", "builtin", "assert"];
24 #[allow(clippy::invalid_paths)] // `check_path` does not seem to work for macros
25 pub const ASSERT_NE_MACRO: [&str; 3] = ["core", "macros", "assert_ne"];
26 pub const ASMUT_TRAIT: [&str; 3] = ["core", "convert", "AsMut"];
27 pub const ASREF_TRAIT: [&str; 3] = ["core", "convert", "AsRef"];
28 /// Preferably use the diagnostic item `sym::Borrow` where possible
29 pub const BORROW_TRAIT: [&str; 3] = ["core", "borrow", "Borrow"];
30 pub const BORROW_MUT_TRAIT: [&str; 3] = ["core", "borrow", "BorrowMut"];
31 pub const BTREEMAP_CONTAINS_KEY: [&str; 6] = ["alloc", "collections", "btree", "map", "BTreeMap", "contains_key"];
32 pub const BTREEMAP_ENTRY: [&str; 6] = ["alloc", "collections", "btree", "map", "entry", "Entry"];
33 pub const BTREEMAP_INSERT: [&str; 6] = ["alloc", "collections", "btree", "map", "BTreeMap", "insert"];
34 pub const CLONE_TRAIT_METHOD: [&str; 4] = ["core", "clone", "Clone", "clone"];
35 pub const CMP_MAX: [&str; 3] = ["core", "cmp", "max"];
36 pub const CMP_MIN: [&str; 3] = ["core", "cmp", "min"];
37 pub const COW: [&str; 3] = ["alloc", "borrow", "Cow"];
38 pub const CSTRING_AS_C_STR: [&str; 5] = ["std", "ffi", "c_str", "CString", "as_c_str"];
39 pub const DEFAULT_TRAIT_METHOD: [&str; 4] = ["core", "default", "Default", "default"];
40 pub const DEREF_MUT_TRAIT_METHOD: [&str; 5] = ["core", "ops", "deref", "DerefMut", "deref_mut"];
41 /// Preferably use the diagnostic item `sym::deref_method` where possible
42 pub const DEREF_TRAIT_METHOD: [&str; 5] = ["core", "ops", "deref", "Deref", "deref"];
43 pub const DIR_BUILDER: [&str; 3] = ["std", "fs", "DirBuilder"];
44 pub const DISPLAY_TRAIT: [&str; 3] = ["core", "fmt", "Display"];
45 pub const DOUBLE_ENDED_ITERATOR: [&str; 4] = ["core", "iter", "traits", "DoubleEndedIterator"];
46 pub const DROP: [&str; 3] = ["core", "mem", "drop"];
47 pub const DURATION: [&str; 3] = ["core", "time", "Duration"];
48 #[cfg(feature = "internal")]
49 pub const EARLY_CONTEXT: [&str; 2] = ["rustc_lint", "EarlyContext"];
50 #[allow(clippy::invalid_paths)] // `check_path` does not seem to work for macros
51 pub const EPRINT_MACRO: [&str; 3] = ["std", "macros", "eprint"];
52 #[allow(clippy::invalid_paths)] // `check_path` does not seem to work for macros
53 pub const EPRINTLN_MACRO: [&str; 3] = ["std", "macros", "eprintln"];
54 pub const EXIT: [&str; 3] = ["std", "process", "exit"];
55 pub const F32_EPSILON: [&str; 4] = ["core", "f32", "<impl f32>", "EPSILON"];
56 pub const F64_EPSILON: [&str; 4] = ["core", "f64", "<impl f64>", "EPSILON"];
57 pub const FILE: [&str; 3] = ["std", "fs", "File"];
58 pub const FILE_TYPE: [&str; 3] = ["std", "fs", "FileType"];
59 #[allow(clippy::invalid_paths)] // `check_path` does not seem to work for macros
60 pub const FORMAT_ARGS_MACRO: [&str; 4] = ["core", "macros", "builtin", "format_args"];
61 pub const FROM_FROM: [&str; 4] = ["core", "convert", "From", "from"];
62 pub const FROM_ITERATOR: [&str; 5] = ["core", "iter", "traits", "collect", "FromIterator"];
63 pub const FROM_ITERATOR_METHOD: [&str; 6] = ["core", "iter", "traits", "collect", "FromIterator", "from_iter"];
64 pub const FROM_STR_METHOD: [&str; 5] = ["core", "str", "traits", "FromStr", "from_str"];
65 pub const FUTURE_FROM_GENERATOR: [&str; 3] = ["core", "future", "from_generator"];
66 #[allow(clippy::invalid_paths)] // internal lints do not know about all external crates
67 pub const FUTURES_IO_ASYNCREADEXT: [&str; 3] = ["futures_util", "io", "AsyncReadExt"];
68 #[allow(clippy::invalid_paths)] // internal lints do not know about all external crates
69 pub const FUTURES_IO_ASYNCWRITEEXT: [&str; 3] = ["futures_util", "io", "AsyncWriteExt"];
70 pub const HASH: [&str; 3] = ["core", "hash", "Hash"];
71 pub const HASHMAP_CONTAINS_KEY: [&str; 6] = ["std", "collections", "hash", "map", "HashMap", "contains_key"];
72 pub const HASHMAP_ENTRY: [&str; 5] = ["std", "collections", "hash", "map", "Entry"];
73 pub const HASHMAP_INSERT: [&str; 6] = ["std", "collections", "hash", "map", "HashMap", "insert"];
74 #[cfg(feature = "internal")]
75 pub const IDENT: [&str; 3] = ["rustc_span", "symbol", "Ident"];
76 #[cfg(feature = "internal")]
77 pub const IDENT_AS_STR: [&str; 4] = ["rustc_span", "symbol", "Ident", "as_str"];
78 pub const INDEX: [&str; 3] = ["core", "ops", "Index"];
79 pub const INDEX_MUT: [&str; 3] = ["core", "ops", "IndexMut"];
80 pub const INSERT_STR: [&str; 4] = ["alloc", "string", "String", "insert_str"];
81 pub const IO_READ: [&str; 3] = ["std", "io", "Read"];
82 pub const IO_WRITE: [&str; 3] = ["std", "io", "Write"];
83 pub const IPADDR_V4: [&str; 5] = ["std", "net", "ip", "IpAddr", "V4"];
84 pub const IPADDR_V6: [&str; 5] = ["std", "net", "ip", "IpAddr", "V6"];
85 pub const ITER_REPEAT: [&str; 5] = ["core", "iter", "sources", "repeat", "repeat"];
86 #[allow(clippy::invalid_paths)] // internal lints do not know about all external crates
87 pub const ITERTOOLS_NEXT_TUPLE: [&str; 3] = ["itertools", "Itertools", "next_tuple"];
88 #[cfg(feature = "internal")]
89 pub const KW_MODULE: [&str; 3] = ["rustc_span", "symbol", "kw"];
90 #[cfg(feature = "internal")]
91 pub const LATE_CONTEXT: [&str; 2] = ["rustc_lint", "LateContext"];
92 #[cfg(feature = "internal")]
93 pub const LINT: [&str; 2] = ["rustc_lint_defs", "Lint"];
94 pub const MEM_DISCRIMINANT: [&str; 3] = ["core", "mem", "discriminant"];
95 pub const MEM_FORGET: [&str; 3] = ["core", "mem", "forget"];
96 pub const MEM_MANUALLY_DROP: [&str; 4] = ["core", "mem", "manually_drop", "ManuallyDrop"];
97 pub const MEM_MAYBEUNINIT: [&str; 4] = ["core", "mem", "maybe_uninit", "MaybeUninit"];
98 pub const MEM_MAYBEUNINIT_UNINIT: [&str; 5] = ["core", "mem", "maybe_uninit", "MaybeUninit", "uninit"];
99 pub const MEM_REPLACE: [&str; 3] = ["core", "mem", "replace"];
100 pub const MEM_SIZE_OF: [&str; 3] = ["core", "mem", "size_of"];
101 pub const MEM_SIZE_OF_VAL: [&str; 3] = ["core", "mem", "size_of_val"];
102 pub const MUTEX_GUARD: [&str; 4] = ["std", "sync", "mutex", "MutexGuard"];
103 pub const OPEN_OPTIONS: [&str; 3] = ["std", "fs", "OpenOptions"];
104 pub const OPS_MODULE: [&str; 2] = ["core", "ops"];
105 /// Preferably use the diagnostic item `sym::Option` where possible
106 pub const OPTION: [&str; 3] = ["core", "option", "Option"];
107 pub const OPTION_NONE: [&str; 4] = ["core", "option", "Option", "None"];
108 pub const OPTION_SOME: [&str; 4] = ["core", "option", "Option", "Some"];
109 pub const ORD: [&str; 3] = ["core", "cmp", "Ord"];
110 pub const OS_STRING_AS_OS_STR: [&str; 5] = ["std", "ffi", "os_str", "OsString", "as_os_str"];
111 pub const OS_STR_TO_OS_STRING: [&str; 5] = ["std", "ffi", "os_str", "OsStr", "to_os_string"];
112 pub const PARKING_LOT_RAWMUTEX: [&str; 3] = ["parking_lot", "raw_mutex", "RawMutex"];
113 pub const PARKING_LOT_RAWRWLOCK: [&str; 3] = ["parking_lot", "raw_rwlock", "RawRwLock"];
114 pub const PARKING_LOT_MUTEX_GUARD: [&str; 2] = ["parking_lot", "MutexGuard"];
115 pub const PARKING_LOT_RWLOCK_READ_GUARD: [&str; 2] = ["parking_lot", "RwLockReadGuard"];
116 pub const PARKING_LOT_RWLOCK_WRITE_GUARD: [&str; 2] = ["parking_lot", "RwLockWriteGuard"];
117 pub const PATH_BUF_AS_PATH: [&str; 4] = ["std", "path", "PathBuf", "as_path"];
118 pub const PATH_TO_PATH_BUF: [&str; 4] = ["std", "path", "Path", "to_path_buf"];
119 pub const PERMISSIONS: [&str; 3] = ["std", "fs", "Permissions"];
120 pub const PERMISSIONS_FROM_MODE: [&str; 6] = ["std", "os", "unix", "fs", "PermissionsExt", "from_mode"];
121 pub const POLL: [&str; 4] = ["core", "task", "poll", "Poll"];
122 pub const POLL_PENDING: [&str; 5] = ["core", "task", "poll", "Poll", "Pending"];
123 pub const POLL_READY: [&str; 5] = ["core", "task", "poll", "Poll", "Ready"];
124 #[allow(clippy::invalid_paths)] // `check_path` does not seem to work for macros
125 pub const PRINT_MACRO: [&str; 3] = ["std", "macros", "print"];
126 #[allow(clippy::invalid_paths)] // `check_path` does not seem to work for macros
127 pub const PRINTLN_MACRO: [&str; 3] = ["std", "macros", "println"];
128 pub const PTR_COPY: [&str; 3] = ["core", "intrinsics", "copy"];
129 pub const PTR_COPY_NONOVERLAPPING: [&str; 3] = ["core", "intrinsics", "copy_nonoverlapping"];
130 pub const PTR_EQ: [&str; 3] = ["core", "ptr", "eq"];
131 pub const PTR_SLICE_FROM_RAW_PARTS: [&str; 3] = ["core", "ptr", "slice_from_raw_parts"];
132 pub const PTR_SLICE_FROM_RAW_PARTS_MUT: [&str; 3] = ["core", "ptr", "slice_from_raw_parts_mut"];
133 pub const PTR_SWAP_NONOVERLAPPING: [&str; 3] = ["core", "ptr", "swap_nonoverlapping"];
134 pub const PTR_READ: [&str; 3] = ["core", "ptr", "read"];
135 pub const PTR_READ_UNALIGNED: [&str; 3] = ["core", "ptr", "read_unaligned"];
136 pub const PTR_READ_VOLATILE: [&str; 3] = ["core", "ptr", "read_volatile"];
137 pub const PTR_REPLACE: [&str; 3] = ["core", "ptr", "replace"];
138 pub const PTR_SWAP: [&str; 3] = ["core", "ptr", "swap"];
139 pub const PTR_WRITE: [&str; 3] = ["core", "ptr", "write"];
140 pub const PTR_WRITE_BYTES: [&str; 3] = ["core", "intrinsics", "write_bytes"];
141 pub const PTR_WRITE_UNALIGNED: [&str; 3] = ["core", "ptr", "write_unaligned"];
142 pub const PTR_WRITE_VOLATILE: [&str; 3] = ["core", "ptr", "write_volatile"];
143 pub const PUSH_STR: [&str; 4] = ["alloc", "string", "String", "push_str"];
144 pub const RANGE_ARGUMENT_TRAIT: [&str; 3] = ["core", "ops", "RangeBounds"];
145 pub const RC_PTR_EQ: [&str; 4] = ["alloc", "rc", "Rc", "ptr_eq"];
146 pub const REFCELL_REF: [&str; 3] = ["core", "cell", "Ref"];
147 pub const REFCELL_REFMUT: [&str; 3] = ["core", "cell", "RefMut"];
148 #[allow(clippy::invalid_paths)] // internal lints do not know about all external crates
149 pub const REGEX_BUILDER_NEW: [&str; 5] = ["regex", "re_builder", "unicode", "RegexBuilder", "new"];
150 #[allow(clippy::invalid_paths)] // internal lints do not know about all external crates
151 pub const REGEX_BYTES_BUILDER_NEW: [&str; 5] = ["regex", "re_builder", "bytes", "RegexBuilder", "new"];
152 #[allow(clippy::invalid_paths)] // internal lints do not know about all external crates
153 pub const REGEX_BYTES_NEW: [&str; 4] = ["regex", "re_bytes", "Regex", "new"];
154 #[allow(clippy::invalid_paths)] // internal lints do not know about all external crates
155 pub const REGEX_BYTES_SET_NEW: [&str; 5] = ["regex", "re_set", "bytes", "RegexSet", "new"];
156 #[allow(clippy::invalid_paths)] // internal lints do not know about all external crates
157 pub const REGEX_NEW: [&str; 4] = ["regex", "re_unicode", "Regex", "new"];
158 #[allow(clippy::invalid_paths)] // internal lints do not know about all external crates
159 pub const REGEX_SET_NEW: [&str; 5] = ["regex", "re_set", "unicode", "RegexSet", "new"];
160 /// Preferably use the diagnostic item `sym::Result` where possible
161 pub const RESULT: [&str; 3] = ["core", "result", "Result"];
162 pub const RESULT_ERR: [&str; 4] = ["core", "result", "Result", "Err"];
163 pub const RESULT_OK: [&str; 4] = ["core", "result", "Result", "Ok"];
164 pub const RWLOCK_READ_GUARD: [&str; 4] = ["std", "sync", "rwlock", "RwLockReadGuard"];
165 pub const RWLOCK_WRITE_GUARD: [&str; 4] = ["std", "sync", "rwlock", "RwLockWriteGuard"];
166 pub const SERDE_DESERIALIZE: [&str; 3] = ["serde", "de", "Deserialize"];
167 pub const SERDE_DE_VISITOR: [&str; 3] = ["serde", "de", "Visitor"];
168 pub const SLICE_FROM_RAW_PARTS: [&str; 4] = ["core", "slice", "raw", "from_raw_parts"];
169 pub const SLICE_FROM_RAW_PARTS_MUT: [&str; 4] = ["core", "slice", "raw", "from_raw_parts_mut"];
170 pub const SLICE_INTO_VEC: [&str; 4] = ["alloc", "slice", "<impl [T]>", "into_vec"];
171 pub const SLICE_ITER: [&str; 4] = ["core", "slice", "iter", "Iter"];
172 pub const STDERR: [&str; 4] = ["std", "io", "stdio", "stderr"];
173 pub const STDOUT: [&str; 4] = ["std", "io", "stdio", "stdout"];
174 pub const CONVERT_IDENTITY: [&str; 3] = ["core", "convert", "identity"];
175 pub const STD_FS_CREATE_DIR: [&str; 3] = ["std", "fs", "create_dir"];
176 pub const STRING_AS_MUT_STR: [&str; 4] = ["alloc", "string", "String", "as_mut_str"];
177 pub const STRING_AS_STR: [&str; 4] = ["alloc", "string", "String", "as_str"];
178 pub const STR_ENDS_WITH: [&str; 4] = ["core", "str", "<impl str>", "ends_with"];
179 pub const STR_FROM_UTF8: [&str; 4] = ["core", "str", "converts", "from_utf8"];
180 pub const STR_LEN: [&str; 4] = ["core", "str", "<impl str>", "len"];
181 pub const STR_STARTS_WITH: [&str; 4] = ["core", "str", "<impl str>", "starts_with"];
182 #[cfg(feature = "internal")]
183 pub const SYMBOL: [&str; 3] = ["rustc_span", "symbol", "Symbol"];
184 #[cfg(feature = "internal")]
185 pub const SYMBOL_AS_STR: [&str; 4] = ["rustc_span", "symbol", "Symbol", "as_str"];
186 #[cfg(feature = "internal")]
187 pub const SYMBOL_INTERN: [&str; 4] = ["rustc_span", "symbol", "Symbol", "intern"];
188 #[cfg(feature = "internal")]
189 pub const SYMBOL_TO_IDENT_STRING: [&str; 4] = ["rustc_span", "symbol", "Symbol", "to_ident_string"];
190 #[cfg(feature = "internal")]
191 pub const SYM_MODULE: [&str; 3] = ["rustc_span", "symbol", "sym"];
192 #[cfg(feature = "internal")]
193 pub const SYNTAX_CONTEXT: [&str; 3] = ["rustc_span", "hygiene", "SyntaxContext"];
194 pub const TO_OWNED_METHOD: [&str; 4] = ["alloc", "borrow", "ToOwned", "to_owned"];
195 pub const TO_STRING_METHOD: [&str; 4] = ["alloc", "string", "ToString", "to_string"];
196 #[allow(clippy::invalid_paths)] // internal lints do not know about all external crates
197 pub const TOKIO_IO_ASYNCREADEXT: [&str; 5] = ["tokio", "io", "util", "async_read_ext", "AsyncReadExt"];
198 #[allow(clippy::invalid_paths)] // internal lints do not know about all external crates
199 pub const TOKIO_IO_ASYNCWRITEEXT: [&str; 5] = ["tokio", "io", "util", "async_write_ext", "AsyncWriteExt"];
200 pub const TRY_FROM: [&str; 4] = ["core", "convert", "TryFrom", "try_from"];
201 pub const VEC_AS_MUT_SLICE: [&str; 4] = ["alloc", "vec", "Vec", "as_mut_slice"];
202 pub const VEC_AS_SLICE: [&str; 4] = ["alloc", "vec", "Vec", "as_slice"];
203 pub const VEC_FROM_ELEM: [&str; 3] = ["alloc", "vec", "from_elem"];
204 pub const VEC_NEW: [&str; 4] = ["alloc", "vec", "Vec", "new"];
205 pub const VEC_RESIZE: [&str; 4] = ["alloc", "vec", "Vec", "resize"];
206 pub const WEAK_ARC: [&str; 3] = ["alloc", "sync", "Weak"];
207 pub const WEAK_RC: [&str; 3] = ["alloc", "rc", "Weak"];
208 #[allow(clippy::invalid_paths)] // `check_path` does not seem to work for macros
209 pub const WRITE_MACRO: [&str; 3] = ["core", "macros", "write"];
210 #[allow(clippy::invalid_paths)] // `check_path` does not seem to work for macros
211 pub const WRITELN_MACRO: [&str; 3] = ["core", "macros", "writeln"];
212 pub const PTR_NON_NULL: [&str; 4] = ["core", "ptr", "non_null", "NonNull"];