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