]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/clippy_utils/src/paths.rs
Merge commit 'e36a20c24f35a4cee82bbdc600289104c9237c22' into ra-sync-and-pms-component
[rust.git] / src / tools / clippy / 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 #[cfg(feature = "internal")]
8 pub const APPLICABILITY: [&str; 2] = ["rustc_lint_defs", "Applicability"];
9 #[cfg(feature = "internal")]
10 pub const APPLICABILITY_VALUES: [[&str; 3]; 4] = [
11     ["rustc_lint_defs", "Applicability", "Unspecified"],
12     ["rustc_lint_defs", "Applicability", "HasPlaceholders"],
13     ["rustc_lint_defs", "Applicability", "MaybeIncorrect"],
14     ["rustc_lint_defs", "Applicability", "MachineApplicable"],
15 ];
16 #[cfg(feature = "internal")]
17 pub const DIAGNOSTIC_BUILDER: [&str; 3] = ["rustc_errors", "diagnostic_builder", "DiagnosticBuilder"];
18 pub const ARC_PTR_EQ: [&str; 4] = ["alloc", "sync", "Arc", "ptr_eq"];
19 pub const ASMUT_TRAIT: [&str; 3] = ["core", "convert", "AsMut"];
20 pub const ASREF_TRAIT: [&str; 3] = ["core", "convert", "AsRef"];
21 pub const BTREEMAP_CONTAINS_KEY: [&str; 6] = ["alloc", "collections", "btree", "map", "BTreeMap", "contains_key"];
22 pub const BTREEMAP_ENTRY: [&str; 6] = ["alloc", "collections", "btree", "map", "entry", "Entry"];
23 pub const BTREEMAP_INSERT: [&str; 6] = ["alloc", "collections", "btree", "map", "BTreeMap", "insert"];
24 pub const BTREESET_ITER: [&str; 6] = ["alloc", "collections", "btree", "set", "BTreeSet", "iter"];
25 pub const CLONE_TRAIT_METHOD: [&str; 4] = ["core", "clone", "Clone", "clone"];
26 pub const COW: [&str; 3] = ["alloc", "borrow", "Cow"];
27 pub const CORE_ITER_COLLECT: [&str; 6] = ["core", "iter", "traits", "iterator", "Iterator", "collect"];
28 pub const CORE_ITER_CLONED: [&str; 6] = ["core", "iter", "traits", "iterator", "Iterator", "cloned"];
29 pub const CORE_ITER_COPIED: [&str; 6] = ["core", "iter", "traits", "iterator", "Iterator", "copied"];
30 pub const CORE_ITER_FILTER: [&str; 6] = ["core", "iter", "traits", "iterator", "Iterator", "filter"];
31 pub const CORE_ITER_INTO_ITER: [&str; 6] = ["core", "iter", "traits", "collect", "IntoIterator", "into_iter"];
32 pub const CSTRING_AS_C_STR: [&str; 5] = ["alloc", "ffi", "c_str", "CString", "as_c_str"];
33 pub const DEFAULT_TRAIT_METHOD: [&str; 4] = ["core", "default", "Default", "default"];
34 pub const DEREF_MUT_TRAIT_METHOD: [&str; 5] = ["core", "ops", "deref", "DerefMut", "deref_mut"];
35 /// Preferably use the diagnostic item `sym::deref_method` where possible
36 pub const DEREF_TRAIT_METHOD: [&str; 5] = ["core", "ops", "deref", "Deref", "deref"];
37 pub const DIR_BUILDER: [&str; 3] = ["std", "fs", "DirBuilder"];
38 pub const DISPLAY_TRAIT: [&str; 3] = ["core", "fmt", "Display"];
39 #[cfg(feature = "internal")]
40 pub const EARLY_CONTEXT: [&str; 2] = ["rustc_lint", "EarlyContext"];
41 #[cfg(feature = "internal")]
42 pub const EARLY_LINT_PASS: [&str; 3] = ["rustc_lint", "passes", "EarlyLintPass"];
43 pub const EXIT: [&str; 3] = ["std", "process", "exit"];
44 pub const F32_EPSILON: [&str; 4] = ["core", "f32", "<impl f32>", "EPSILON"];
45 pub const F64_EPSILON: [&str; 4] = ["core", "f64", "<impl f64>", "EPSILON"];
46 pub const FILE: [&str; 3] = ["std", "fs", "File"];
47 pub const FILE_TYPE: [&str; 3] = ["std", "fs", "FileType"];
48 pub const FROM_FROM: [&str; 4] = ["core", "convert", "From", "from"];
49 pub const FROM_ITERATOR_METHOD: [&str; 6] = ["core", "iter", "traits", "collect", "FromIterator", "from_iter"];
50 pub const FROM_STR_METHOD: [&str; 5] = ["core", "str", "traits", "FromStr", "from_str"];
51 pub const FUTURE_FROM_GENERATOR: [&str; 3] = ["core", "future", "from_generator"];
52 #[expect(clippy::invalid_paths)] // internal lints do not know about all external crates
53 pub const FUTURES_IO_ASYNCREADEXT: [&str; 3] = ["futures_util", "io", "AsyncReadExt"];
54 #[expect(clippy::invalid_paths)] // internal lints do not know about all external crates
55 pub const FUTURES_IO_ASYNCWRITEEXT: [&str; 3] = ["futures_util", "io", "AsyncWriteExt"];
56 pub const HASHMAP_CONTAINS_KEY: [&str; 6] = ["std", "collections", "hash", "map", "HashMap", "contains_key"];
57 pub const HASHMAP_ENTRY: [&str; 5] = ["std", "collections", "hash", "map", "Entry"];
58 pub const HASHMAP_INSERT: [&str; 6] = ["std", "collections", "hash", "map", "HashMap", "insert"];
59 pub const HASHSET_ITER: [&str; 6] = ["std", "collections", "hash", "set", "HashSet", "iter"];
60 #[cfg(feature = "internal")]
61 pub const IDENT: [&str; 3] = ["rustc_span", "symbol", "Ident"];
62 #[cfg(feature = "internal")]
63 pub const IDENT_AS_STR: [&str; 4] = ["rustc_span", "symbol", "Ident", "as_str"];
64 pub const INDEX: [&str; 3] = ["core", "ops", "Index"];
65 pub const INDEX_MUT: [&str; 3] = ["core", "ops", "IndexMut"];
66 pub const INSERT_STR: [&str; 4] = ["alloc", "string", "String", "insert_str"];
67 pub const IO_READ: [&str; 3] = ["std", "io", "Read"];
68 pub const IO_WRITE: [&str; 3] = ["std", "io", "Write"];
69 pub const IPADDR_V4: [&str; 5] = ["std", "net", "ip", "IpAddr", "V4"];
70 pub const IPADDR_V6: [&str; 5] = ["std", "net", "ip", "IpAddr", "V6"];
71 pub const ITER_COUNT: [&str; 6] = ["core", "iter", "traits", "iterator", "Iterator", "count"];
72 pub const ITER_EMPTY: [&str; 5] = ["core", "iter", "sources", "empty", "Empty"];
73 pub const ITER_REPEAT: [&str; 5] = ["core", "iter", "sources", "repeat", "repeat"];
74 #[expect(clippy::invalid_paths)] // internal lints do not know about all external crates
75 pub const ITERTOOLS_NEXT_TUPLE: [&str; 3] = ["itertools", "Itertools", "next_tuple"];
76 #[cfg(feature = "internal")]
77 pub const KW_MODULE: [&str; 3] = ["rustc_span", "symbol", "kw"];
78 #[cfg(feature = "internal")]
79 pub const LATE_CONTEXT: [&str; 2] = ["rustc_lint", "LateContext"];
80 #[cfg(feature = "internal")]
81 pub const LATE_LINT_PASS: [&str; 3] = ["rustc_lint", "passes", "LateLintPass"];
82 #[cfg(feature = "internal")]
83 pub const LINT: [&str; 2] = ["rustc_lint_defs", "Lint"];
84 pub const MEM_SWAP: [&str; 3] = ["core", "mem", "swap"];
85 pub const MUTEX_GUARD: [&str; 4] = ["std", "sync", "mutex", "MutexGuard"];
86 pub const OPEN_OPTIONS: [&str; 3] = ["std", "fs", "OpenOptions"];
87 /// Preferably use the diagnostic item `sym::Option` where possible
88 pub const OPTION: [&str; 3] = ["core", "option", "Option"];
89 pub const OPTION_NONE: [&str; 4] = ["core", "option", "Option", "None"];
90 pub const OPTION_SOME: [&str; 4] = ["core", "option", "Option", "Some"];
91 pub const ORD: [&str; 3] = ["core", "cmp", "Ord"];
92 pub const OS_STRING_AS_OS_STR: [&str; 5] = ["std", "ffi", "os_str", "OsString", "as_os_str"];
93 pub const OS_STR_TO_OS_STRING: [&str; 5] = ["std", "ffi", "os_str", "OsStr", "to_os_string"];
94 pub const PARKING_LOT_MUTEX_GUARD: [&str; 3] = ["lock_api", "mutex", "MutexGuard"];
95 pub const PARKING_LOT_RWLOCK_READ_GUARD: [&str; 3] = ["lock_api", "rwlock", "RwLockReadGuard"];
96 pub const PARKING_LOT_RWLOCK_WRITE_GUARD: [&str; 3] = ["lock_api", "rwlock", "RwLockWriteGuard"];
97 pub const PATH_BUF_AS_PATH: [&str; 4] = ["std", "path", "PathBuf", "as_path"];
98 pub const PATH_TO_PATH_BUF: [&str; 4] = ["std", "path", "Path", "to_path_buf"];
99 pub const PERMISSIONS: [&str; 3] = ["std", "fs", "Permissions"];
100 #[cfg_attr(not(unix), allow(clippy::invalid_paths))]
101 pub const PERMISSIONS_FROM_MODE: [&str; 6] = ["std", "os", "unix", "fs", "PermissionsExt", "from_mode"];
102 pub const POLL: [&str; 4] = ["core", "task", "poll", "Poll"];
103 pub const POLL_PENDING: [&str; 5] = ["core", "task", "poll", "Poll", "Pending"];
104 pub const POLL_READY: [&str; 5] = ["core", "task", "poll", "Poll", "Ready"];
105 pub const PTR_COPY: [&str; 3] = ["core", "intrinsics", "copy"];
106 pub const PTR_COPY_NONOVERLAPPING: [&str; 3] = ["core", "intrinsics", "copy_nonoverlapping"];
107 pub const PTR_EQ: [&str; 3] = ["core", "ptr", "eq"];
108 pub const PTR_SLICE_FROM_RAW_PARTS: [&str; 3] = ["core", "ptr", "slice_from_raw_parts"];
109 pub const PTR_SLICE_FROM_RAW_PARTS_MUT: [&str; 3] = ["core", "ptr", "slice_from_raw_parts_mut"];
110 pub const PTR_SWAP_NONOVERLAPPING: [&str; 3] = ["core", "ptr", "swap_nonoverlapping"];
111 pub const PTR_READ: [&str; 3] = ["core", "ptr", "read"];
112 pub const PTR_READ_UNALIGNED: [&str; 3] = ["core", "ptr", "read_unaligned"];
113 pub const PTR_READ_VOLATILE: [&str; 3] = ["core", "ptr", "read_volatile"];
114 pub const PTR_REPLACE: [&str; 3] = ["core", "ptr", "replace"];
115 pub const PTR_SWAP: [&str; 3] = ["core", "ptr", "swap"];
116 pub const PTR_UNALIGNED_VOLATILE_LOAD: [&str; 3] = ["core", "intrinsics", "unaligned_volatile_load"];
117 pub const PTR_UNALIGNED_VOLATILE_STORE: [&str; 3] = ["core", "intrinsics", "unaligned_volatile_store"];
118 pub const PTR_WRITE: [&str; 3] = ["core", "ptr", "write"];
119 pub const PTR_WRITE_BYTES: [&str; 3] = ["core", "intrinsics", "write_bytes"];
120 pub const PTR_WRITE_UNALIGNED: [&str; 3] = ["core", "ptr", "write_unaligned"];
121 pub const PTR_WRITE_VOLATILE: [&str; 3] = ["core", "ptr", "write_volatile"];
122 pub const PUSH_STR: [&str; 4] = ["alloc", "string", "String", "push_str"];
123 pub const RANGE_ARGUMENT_TRAIT: [&str; 3] = ["core", "ops", "RangeBounds"];
124 pub const RC_PTR_EQ: [&str; 4] = ["alloc", "rc", "Rc", "ptr_eq"];
125 pub const REFCELL_REF: [&str; 3] = ["core", "cell", "Ref"];
126 pub const REFCELL_REFMUT: [&str; 3] = ["core", "cell", "RefMut"];
127 #[expect(clippy::invalid_paths)] // internal lints do not know about all external crates
128 pub const REGEX_BUILDER_NEW: [&str; 5] = ["regex", "re_builder", "unicode", "RegexBuilder", "new"];
129 #[expect(clippy::invalid_paths)] // internal lints do not know about all external crates
130 pub const REGEX_BYTES_BUILDER_NEW: [&str; 5] = ["regex", "re_builder", "bytes", "RegexBuilder", "new"];
131 #[expect(clippy::invalid_paths)] // internal lints do not know about all external crates
132 pub const REGEX_BYTES_NEW: [&str; 4] = ["regex", "re_bytes", "Regex", "new"];
133 #[expect(clippy::invalid_paths)] // internal lints do not know about all external crates
134 pub const REGEX_BYTES_SET_NEW: [&str; 5] = ["regex", "re_set", "bytes", "RegexSet", "new"];
135 #[expect(clippy::invalid_paths)] // internal lints do not know about all external crates
136 pub const REGEX_NEW: [&str; 4] = ["regex", "re_unicode", "Regex", "new"];
137 #[expect(clippy::invalid_paths)] // internal lints do not know about all external crates
138 pub const REGEX_SET_NEW: [&str; 5] = ["regex", "re_set", "unicode", "RegexSet", "new"];
139 /// Preferably use the diagnostic item `sym::Result` where possible
140 pub const RESULT: [&str; 3] = ["core", "result", "Result"];
141 pub const RESULT_ERR: [&str; 4] = ["core", "result", "Result", "Err"];
142 pub const RESULT_OK: [&str; 4] = ["core", "result", "Result", "Ok"];
143 #[cfg(feature = "internal")]
144 pub const RUSTC_VERSION: [&str; 2] = ["rustc_semver", "RustcVersion"];
145 pub const RWLOCK_READ_GUARD: [&str; 4] = ["std", "sync", "rwlock", "RwLockReadGuard"];
146 pub const RWLOCK_WRITE_GUARD: [&str; 4] = ["std", "sync", "rwlock", "RwLockWriteGuard"];
147 pub const SERDE_DESERIALIZE: [&str; 3] = ["serde", "de", "Deserialize"];
148 pub const SERDE_DE_VISITOR: [&str; 3] = ["serde", "de", "Visitor"];
149 pub const SLICE_FROM_RAW_PARTS: [&str; 4] = ["core", "slice", "raw", "from_raw_parts"];
150 pub const SLICE_FROM_RAW_PARTS_MUT: [&str; 4] = ["core", "slice", "raw", "from_raw_parts_mut"];
151 pub const SLICE_GET: [&str; 4] = ["core", "slice", "<impl [T]>", "get"];
152 pub const SLICE_INTO_VEC: [&str; 4] = ["alloc", "slice", "<impl [T]>", "into_vec"];
153 pub const SLICE_INTO: [&str; 4] = ["core", "slice", "<impl [T]>", "iter"];
154 pub const SLICE_ITER: [&str; 4] = ["core", "slice", "iter", "Iter"];
155 pub const STDERR: [&str; 4] = ["std", "io", "stdio", "stderr"];
156 pub const STDOUT: [&str; 4] = ["std", "io", "stdio", "stdout"];
157 pub const CONVERT_IDENTITY: [&str; 3] = ["core", "convert", "identity"];
158 pub const STD_FS_CREATE_DIR: [&str; 3] = ["std", "fs", "create_dir"];
159 pub const STRING_AS_MUT_STR: [&str; 4] = ["alloc", "string", "String", "as_mut_str"];
160 pub const STRING_AS_STR: [&str; 4] = ["alloc", "string", "String", "as_str"];
161 pub const STRING_NEW: [&str; 4] = ["alloc", "string", "String", "new"];
162 pub const STR_BYTES: [&str; 4] = ["core", "str", "<impl str>", "bytes"];
163 pub const STR_CHARS: [&str; 4] = ["core", "str", "<impl str>", "chars"];
164 pub const STR_ENDS_WITH: [&str; 4] = ["core", "str", "<impl str>", "ends_with"];
165 pub const STR_FROM_UTF8: [&str; 4] = ["core", "str", "converts", "from_utf8"];
166 pub const STR_FROM_UTF8_UNCHECKED: [&str; 4] = ["core", "str", "converts", "from_utf8_unchecked"];
167 pub const STR_LEN: [&str; 4] = ["core", "str", "<impl str>", "len"];
168 pub const STR_STARTS_WITH: [&str; 4] = ["core", "str", "<impl str>", "starts_with"];
169 #[cfg(feature = "internal")]
170 pub const SYMBOL: [&str; 3] = ["rustc_span", "symbol", "Symbol"];
171 #[cfg(feature = "internal")]
172 pub const SYMBOL_AS_STR: [&str; 4] = ["rustc_span", "symbol", "Symbol", "as_str"];
173 #[cfg(feature = "internal")]
174 pub const SYMBOL_INTERN: [&str; 4] = ["rustc_span", "symbol", "Symbol", "intern"];
175 #[cfg(feature = "internal")]
176 pub const SYMBOL_TO_IDENT_STRING: [&str; 4] = ["rustc_span", "symbol", "Symbol", "to_ident_string"];
177 #[cfg(feature = "internal")]
178 pub const SYM_MODULE: [&str; 3] = ["rustc_span", "symbol", "sym"];
179 #[cfg(feature = "internal")]
180 pub const SYNTAX_CONTEXT: [&str; 3] = ["rustc_span", "hygiene", "SyntaxContext"];
181 pub const TO_OWNED_METHOD: [&str; 4] = ["alloc", "borrow", "ToOwned", "to_owned"];
182 pub const TO_STRING_METHOD: [&str; 4] = ["alloc", "string", "ToString", "to_string"];
183 #[expect(clippy::invalid_paths)] // internal lints do not know about all external crates
184 pub const TOKIO_IO_ASYNCREADEXT: [&str; 5] = ["tokio", "io", "util", "async_read_ext", "AsyncReadExt"];
185 #[expect(clippy::invalid_paths)] // internal lints do not know about all external crates
186 pub const TOKIO_IO_ASYNCWRITEEXT: [&str; 5] = ["tokio", "io", "util", "async_write_ext", "AsyncWriteExt"];
187 pub const TRY_FROM: [&str; 4] = ["core", "convert", "TryFrom", "try_from"];
188 pub const VEC_AS_MUT_SLICE: [&str; 4] = ["alloc", "vec", "Vec", "as_mut_slice"];
189 pub const VEC_AS_SLICE: [&str; 4] = ["alloc", "vec", "Vec", "as_slice"];
190 pub const VEC_DEQUE_ITER: [&str; 5] = ["alloc", "collections", "vec_deque", "VecDeque", "iter"];
191 pub const VEC_FROM_ELEM: [&str; 3] = ["alloc", "vec", "from_elem"];
192 pub const VEC_NEW: [&str; 4] = ["alloc", "vec", "Vec", "new"];
193 pub const VEC_RESIZE: [&str; 4] = ["alloc", "vec", "Vec", "resize"];
194 pub const WEAK_ARC: [&str; 3] = ["alloc", "sync", "Weak"];
195 pub const WEAK_RC: [&str; 3] = ["alloc", "rc", "Weak"];
196 pub const PTR_NON_NULL: [&str; 4] = ["core", "ptr", "non_null", "NonNull"];