From 116e527af295803cc58302ed80f4de6636ff0612 Mon Sep 17 00:00:00 2001 From: GnomedDev Date: Wed, 18 Sep 2024 17:58:18 +0100 Subject: [PATCH 01/19] [Clippy] Swap `map_entry` to use diagnostic items instead of paths --- alloc/src/collections/btree/map.rs | 2 ++ std/src/collections/hash/map.rs | 2 ++ 2 files changed, 4 insertions(+) diff --git a/alloc/src/collections/btree/map.rs b/alloc/src/collections/btree/map.rs index 60e08b47e3d35..0eadc9ecac8fa 100644 --- a/alloc/src/collections/btree/map.rs +++ b/alloc/src/collections/btree/map.rs @@ -916,6 +916,7 @@ impl BTreeMap { /// assert_eq!(map.contains_key(&2), false); /// ``` #[stable(feature = "rust1", since = "1.0.0")] + #[cfg_attr(not(test), rustc_diagnostic_item = "btreemap_contains_key")] pub fn contains_key(&self, key: &Q) -> bool where K: Borrow + Ord, @@ -981,6 +982,7 @@ impl BTreeMap { /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[rustc_confusables("push", "put", "set")] + #[cfg_attr(not(test), rustc_diagnostic_item = "btreemap_insert")] pub fn insert(&mut self, key: K, value: V) -> Option where K: Ord, diff --git a/std/src/collections/hash/map.rs b/std/src/collections/hash/map.rs index 7d21d37f40df9..0d7346c7f1eae 100644 --- a/std/src/collections/hash/map.rs +++ b/std/src/collections/hash/map.rs @@ -1037,6 +1037,7 @@ where /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] + #[cfg_attr(not(test), rustc_diagnostic_item = "hashmap_contains_key")] pub fn contains_key(&self, k: &Q) -> bool where K: Borrow, @@ -1100,6 +1101,7 @@ where #[inline] #[stable(feature = "rust1", since = "1.0.0")] #[rustc_confusables("push", "append", "put")] + #[cfg_attr(not(test), rustc_diagnostic_item = "hashmap_insert")] pub fn insert(&mut self, k: K, v: V) -> Option { self.base.insert(k, v) } From b8c0c3b59d6d242f50eff5fdd45a4e71935ffa1c Mon Sep 17 00:00:00 2001 From: GnomedDev Date: Wed, 18 Sep 2024 19:36:12 +0100 Subject: [PATCH 02/19] [Clippy] Swap `lines_filter_map_ok` to use a diagnostic item instead of path --- core/src/result.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/core/src/result.rs b/core/src/result.rs index 02f6f783b512c..9edd58259ba0f 100644 --- a/core/src/result.rs +++ b/core/src/result.rs @@ -653,6 +653,7 @@ impl Result { /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] + #[cfg_attr(not(test), rustc_diagnostic_item = "result_ok_method")] pub fn ok(self) -> Option { match self { Ok(x) => Some(x), From 6ef72c4aead7ffa92d13c89dba87ff1e185627b5 Mon Sep 17 00:00:00 2001 From: GnomedDev Date: Wed, 18 Sep 2024 21:09:06 +0100 Subject: [PATCH 03/19] [Clippy] Swap `option_as_ref_deref` to use diagnostic items instead of paths --- alloc/src/ffi/c_str.rs | 1 + alloc/src/string.rs | 2 ++ alloc/src/vec/mod.rs | 2 ++ std/src/ffi/os_str.rs | 1 + std/src/path.rs | 1 + 5 files changed, 7 insertions(+) diff --git a/alloc/src/ffi/c_str.rs b/alloc/src/ffi/c_str.rs index e32676a65432b..45037aa1615b4 100644 --- a/alloc/src/ffi/c_str.rs +++ b/alloc/src/ffi/c_str.rs @@ -576,6 +576,7 @@ impl CString { #[inline] #[must_use] #[stable(feature = "as_c_str", since = "1.20.0")] + #[cfg_attr(not(test), rustc_diagnostic_item = "cstring_as_c_str")] pub fn as_c_str(&self) -> &CStr { &*self } diff --git a/alloc/src/string.rs b/alloc/src/string.rs index 6daab5bc73a9c..a2c70de3ed0e9 100644 --- a/alloc/src/string.rs +++ b/alloc/src/string.rs @@ -1073,6 +1073,7 @@ impl String { #[inline] #[must_use] #[stable(feature = "string_as_str", since = "1.7.0")] + #[cfg_attr(not(test), rustc_diagnostic_item = "string_as_str")] pub fn as_str(&self) -> &str { self } @@ -1092,6 +1093,7 @@ impl String { #[inline] #[must_use] #[stable(feature = "string_as_str", since = "1.7.0")] + #[cfg_attr(not(test), rustc_diagnostic_item = "string_as_mut_str")] pub fn as_mut_str(&mut self) -> &mut str { self } diff --git a/alloc/src/vec/mod.rs b/alloc/src/vec/mod.rs index 2afb5dd0d1a26..ac0db38eac3ef 100644 --- a/alloc/src/vec/mod.rs +++ b/alloc/src/vec/mod.rs @@ -1545,6 +1545,7 @@ impl Vec { /// ``` #[inline] #[stable(feature = "vec_as_slice", since = "1.7.0")] + #[cfg_attr(not(test), rustc_diagnostic_item = "vec_as_slice")] pub fn as_slice(&self) -> &[T] { self } @@ -1562,6 +1563,7 @@ impl Vec { /// ``` #[inline] #[stable(feature = "vec_as_slice", since = "1.7.0")] + #[cfg_attr(not(test), rustc_diagnostic_item = "vec_as_mut_slice")] pub fn as_mut_slice(&mut self) -> &mut [T] { self } diff --git a/std/src/ffi/os_str.rs b/std/src/ffi/os_str.rs index 99bea676e1224..8e1147338b047 100644 --- a/std/src/ffi/os_str.rs +++ b/std/src/ffi/os_str.rs @@ -196,6 +196,7 @@ impl OsString { /// let os_str = OsStr::new("foo"); /// assert_eq!(os_string.as_os_str(), os_str); /// ``` + #[cfg_attr(not(test), rustc_diagnostic_item = "os_string_as_os_str")] #[stable(feature = "rust1", since = "1.0.0")] #[must_use] #[inline] diff --git a/std/src/path.rs b/std/src/path.rs index c94df9b5366be..6d6aa92711ba4 100644 --- a/std/src/path.rs +++ b/std/src/path.rs @@ -1226,6 +1226,7 @@ impl PathBuf { /// let p = PathBuf::from("/test"); /// assert_eq!(Path::new("/test"), p.as_path()); /// ``` + #[cfg_attr(not(test), rustc_diagnostic_item = "pathbuf_as_path")] #[stable(feature = "rust1", since = "1.0.0")] #[must_use] #[inline] From 3310a0ba289d01c9c2fa809d94877920e00f4111 Mon Sep 17 00:00:00 2001 From: GnomedDev Date: Wed, 18 Sep 2024 21:15:03 +0100 Subject: [PATCH 04/19] [Clippy] Swap `float_equality_without_abs` to use diagnostic items instead of paths --- core/src/num/f32.rs | 1 + core/src/num/f64.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/core/src/num/f32.rs b/core/src/num/f32.rs index 4c2a4ee3b3255..d0eb6bb3f2879 100644 --- a/core/src/num/f32.rs +++ b/core/src/num/f32.rs @@ -415,6 +415,7 @@ impl f32 { /// [Machine epsilon]: https://en.wikipedia.org/wiki/Machine_epsilon /// [`MANTISSA_DIGITS`]: f32::MANTISSA_DIGITS #[stable(feature = "assoc_int_consts", since = "1.43.0")] + #[cfg_attr(not(test), rustc_diagnostic_item = "f32_epsilon")] pub const EPSILON: f32 = 1.19209290e-07_f32; /// Smallest finite `f32` value. diff --git a/core/src/num/f64.rs b/core/src/num/f64.rs index 87fb5fe7ebeea..4bc275ad14786 100644 --- a/core/src/num/f64.rs +++ b/core/src/num/f64.rs @@ -414,6 +414,7 @@ impl f64 { /// [Machine epsilon]: https://en.wikipedia.org/wiki/Machine_epsilon /// [`MANTISSA_DIGITS`]: f64::MANTISSA_DIGITS #[stable(feature = "assoc_int_consts", since = "1.43.0")] + #[cfg_attr(not(test), rustc_diagnostic_item = "f64_epsilon")] pub const EPSILON: f64 = 2.2204460492503131e-16_f64; /// Smallest finite `f64` value. From a61b7b74edc98746f93b2c78f37c7ed09546cb17 Mon Sep 17 00:00:00 2001 From: GnomedDev Date: Wed, 18 Sep 2024 21:21:17 +0100 Subject: [PATCH 05/19] [Clippy] Swap `redundant_clone` to use diagnostic items instead of paths --- std/src/ffi/os_str.rs | 1 + std/src/path.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/std/src/ffi/os_str.rs b/std/src/ffi/os_str.rs index 8e1147338b047..0f905803bb8b9 100644 --- a/std/src/ffi/os_str.rs +++ b/std/src/ffi/os_str.rs @@ -919,6 +919,7 @@ impl OsStr { #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline] + #[cfg_attr(not(test), rustc_diagnostic_item = "os_str_to_os_string")] pub fn to_os_string(&self) -> OsString { OsString { inner: self.inner.to_owned() } } diff --git a/std/src/path.rs b/std/src/path.rs index 6d6aa92711ba4..2ba3a9cdca251 100644 --- a/std/src/path.rs +++ b/std/src/path.rs @@ -2265,6 +2265,7 @@ impl Path { #[must_use = "this returns the result of the operation, \ without modifying the original"] #[stable(feature = "rust1", since = "1.0.0")] + #[cfg_attr(not(test), rustc_diagnostic_item = "path_to_pathbuf")] pub fn to_path_buf(&self) -> PathBuf { PathBuf::from(self.inner.to_os_string()) } From b2dc66e63fe6700e311bb2c1a0e16949d0ca2c1d Mon Sep 17 00:00:00 2001 From: GnomedDev Date: Wed, 18 Sep 2024 21:24:42 +0100 Subject: [PATCH 06/19] [Clippy] Swap `manual_main_separator_str` to use diagnostic item instead of path --- std/src/path.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/std/src/path.rs b/std/src/path.rs index 2ba3a9cdca251..aa9f63d915a24 100644 --- a/std/src/path.rs +++ b/std/src/path.rs @@ -263,6 +263,7 @@ pub fn is_separator(c: char) -> bool { /// /// For example, `/` on Unix and `\` on Windows. #[stable(feature = "rust1", since = "1.0.0")] +#[cfg_attr(not(test), rustc_diagnostic_item = "path_main_separator")] pub const MAIN_SEPARATOR: char = crate::sys::path::MAIN_SEP; /// The primary separator of path components for the current platform. From 6906fa9d9f53bb8c93e39723b89696be1de13a20 Mon Sep 17 00:00:00 2001 From: GnomedDev Date: Wed, 18 Sep 2024 21:37:12 +0100 Subject: [PATCH 07/19] [Clippy] Swap `single_char_add_str`/`format_push_string` to use diagnostic items instead of paths --- alloc/src/string.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/alloc/src/string.rs b/alloc/src/string.rs index a2c70de3ed0e9..c7e9931ed2a5a 100644 --- a/alloc/src/string.rs +++ b/alloc/src/string.rs @@ -1113,6 +1113,7 @@ impl String { #[inline] #[stable(feature = "rust1", since = "1.0.0")] #[rustc_confusables("append", "push")] + #[cfg_attr(not(test), rustc_diagnostic_item = "string_push_str")] pub fn push_str(&mut self, string: &str) { self.vec.extend_from_slice(string.as_bytes()) } @@ -1747,6 +1748,7 @@ impl String { #[cfg(not(no_global_oom_handling))] #[inline] #[stable(feature = "insert_str", since = "1.16.0")] + #[cfg_attr(not(test), rustc_diagnostic_item = "string_insert_str")] pub fn insert_str(&mut self, idx: usize, string: &str) { assert!(self.is_char_boundary(idx)); From b95bef03da4a6b90e9473e36bc79f77e242ccfb9 Mon Sep 17 00:00:00 2001 From: GnomedDev Date: Wed, 18 Sep 2024 21:42:38 +0100 Subject: [PATCH 08/19] [Clippy] Swap `VecArgs::hir` to use diagnostic items instead of paths --- alloc/src/slice.rs | 1 + alloc/src/vec/mod.rs | 2 ++ 2 files changed, 3 insertions(+) diff --git a/alloc/src/slice.rs b/alloc/src/slice.rs index 8cdba166c9dff..45fb88969c696 100644 --- a/alloc/src/slice.rs +++ b/alloc/src/slice.rs @@ -496,6 +496,7 @@ impl [T] { #[rustc_allow_incoherent_impl] #[stable(feature = "rust1", since = "1.0.0")] #[inline] + #[cfg_attr(not(test), rustc_diagnostic_item = "slice_into_vec")] pub fn into_vec(self: Box) -> Vec { // N.B., see the `hack` module in this file for more details. hack::into_vec(self) diff --git a/alloc/src/vec/mod.rs b/alloc/src/vec/mod.rs index ac0db38eac3ef..29ddf939499a8 100644 --- a/alloc/src/vec/mod.rs +++ b/alloc/src/vec/mod.rs @@ -416,6 +416,7 @@ impl Vec { /// ``` #[inline] #[rustc_const_stable(feature = "const_vec_new", since = "1.39.0")] + #[cfg_attr(not(test), rustc_diagnostic_item = "vec_new")] #[stable(feature = "rust1", since = "1.0.0")] #[must_use] pub const fn new() -> Self { @@ -3046,6 +3047,7 @@ impl Vec { #[doc(hidden)] #[cfg(not(no_global_oom_handling))] #[stable(feature = "rust1", since = "1.0.0")] +#[cfg_attr(not(test), rustc_diagnostic_item = "vec_from_elem")] pub fn from_elem(elem: T, n: usize) -> Vec { ::from_elem(elem, n, Global) } From 08b676d07d8ba4a0e5a3422db9bf96a96fcc24fb Mon Sep 17 00:00:00 2001 From: GnomedDev Date: Wed, 18 Sep 2024 21:53:28 +0100 Subject: [PATCH 09/19] [Clippy] Swap `repeat_vec_with_capacity` to use diagnostic item instead of path --- alloc/src/vec/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/alloc/src/vec/mod.rs b/alloc/src/vec/mod.rs index 29ddf939499a8..a7e736299bed6 100644 --- a/alloc/src/vec/mod.rs +++ b/alloc/src/vec/mod.rs @@ -477,6 +477,7 @@ impl Vec { #[inline] #[stable(feature = "rust1", since = "1.0.0")] #[must_use] + #[cfg_attr(not(test), rustc_diagnostic_item = "vec_with_capacity")] pub fn with_capacity(capacity: usize) -> Self { Self::with_capacity_in(capacity, Global) } From 7bc30a7e0d17c4b3831cf50b6c890298f84c5263 Mon Sep 17 00:00:00 2001 From: GnomedDev Date: Wed, 18 Sep 2024 21:59:31 +0100 Subject: [PATCH 10/19] [Clippy] Swap `manual_while_let_some` to use diagnostic items instead of paths --- alloc/src/vec/mod.rs | 2 ++ core/src/option.rs | 2 ++ 2 files changed, 4 insertions(+) diff --git a/alloc/src/vec/mod.rs b/alloc/src/vec/mod.rs index a7e736299bed6..13b06584223ba 100644 --- a/alloc/src/vec/mod.rs +++ b/alloc/src/vec/mod.rs @@ -2384,6 +2384,7 @@ impl Vec { /// Takes *O*(1) time. #[inline] #[stable(feature = "rust1", since = "1.0.0")] + #[cfg_attr(not(test), rustc_diagnostic_item = "vec_pop")] pub fn pop(&mut self) -> Option { if self.len == 0 { None @@ -2577,6 +2578,7 @@ impl Vec { /// assert!(!v.is_empty()); /// ``` #[stable(feature = "rust1", since = "1.0.0")] + #[cfg_attr(not(test), rustc_diagnostic_item = "vec_is_empty")] pub fn is_empty(&self) -> bool { self.len() == 0 } diff --git a/core/src/option.rs b/core/src/option.rs index 265f056dc8766..5ba13969605fc 100644 --- a/core/src/option.rs +++ b/core/src/option.rs @@ -923,6 +923,7 @@ impl Option { #[inline] #[track_caller] #[stable(feature = "rust1", since = "1.0.0")] + #[cfg_attr(not(test), rustc_diagnostic_item = "option_expect")] #[rustc_const_unstable(feature = "const_option", issue = "67441")] pub const fn expect(self, msg: &str) -> T { match self { @@ -960,6 +961,7 @@ impl Option { #[inline(always)] #[track_caller] #[stable(feature = "rust1", since = "1.0.0")] + #[cfg_attr(not(test), rustc_diagnostic_item = "option_unwrap")] #[rustc_const_unstable(feature = "const_option", issue = "67441")] pub const fn unwrap(self) -> T { match self { From 925c1c4ffc83e467f4ef301670739e9a2e20fb46 Mon Sep 17 00:00:00 2001 From: GnomedDev Date: Wed, 18 Sep 2024 22:01:52 +0100 Subject: [PATCH 11/19] [Clippy] Swap `filter_map_bool_then` to use diagnostic item instead of path --- core/src/bool.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/core/src/bool.rs b/core/src/bool.rs index 03cdff9b13be1..58a870d2e0725 100644 --- a/core/src/bool.rs +++ b/core/src/bool.rs @@ -55,6 +55,7 @@ impl bool { /// assert_eq!(a, 1); /// ``` #[stable(feature = "lazy_bool_to_option", since = "1.50.0")] + #[cfg_attr(not(test), rustc_diagnostic_item = "bool_then")] #[inline] pub fn then T>(self, f: F) -> Option { if self { Some(f()) } else { None } From beaebb53af0b2aeff3e016baa949d789eb2866aa Mon Sep 17 00:00:00 2001 From: GnomedDev Date: Wed, 18 Sep 2024 22:05:02 +0100 Subject: [PATCH 12/19] [Clippy] Swap `waker_clone_wake` to use diagnostic item instead of path --- core/src/task/wake.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/core/src/task/wake.rs b/core/src/task/wake.rs index 5e559ad8d2ca7..a5103499c8a0d 100644 --- a/core/src/task/wake.rs +++ b/core/src/task/wake.rs @@ -414,6 +414,7 @@ impl<'a> ContextBuilder<'a> { /// [`Wake`]: ../../alloc/task/trait.Wake.html #[repr(transparent)] #[stable(feature = "futures_api", since = "1.36.0")] +#[cfg_attr(not(test), rustc_diagnostic_item = "Waker")] pub struct Waker { waker: RawWaker, } From c1a4a69d65ac2de087f60a306f698625dc7632b0 Mon Sep 17 00:00:00 2001 From: GnomedDev Date: Wed, 18 Sep 2024 22:08:04 +0100 Subject: [PATCH 13/19] [Clippy] Swap `instant_subtraction` to use diagnostic item instead of path --- std/src/time.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/std/src/time.rs b/std/src/time.rs index ae46670c25e61..f28a0568a3c3d 100644 --- a/std/src/time.rs +++ b/std/src/time.rs @@ -280,6 +280,7 @@ impl Instant { /// ``` #[must_use] #[stable(feature = "time2", since = "1.8.0")] + #[cfg_attr(not(test), rustc_diagnostic_item = "instant_now")] pub fn now() -> Instant { Instant(time::Instant::now()) } From 995238ce3f5ad90c38fba07b70dfbdb1608ccc98 Mon Sep 17 00:00:00 2001 From: GnomedDev Date: Wed, 18 Sep 2024 22:10:05 +0100 Subject: [PATCH 14/19] [Clippy] Swap `unnecessary_to_owned` to use diagnostic item instead of path --- alloc/src/string.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/alloc/src/string.rs b/alloc/src/string.rs index c7e9931ed2a5a..0bad33c909d61 100644 --- a/alloc/src/string.rs +++ b/alloc/src/string.rs @@ -571,6 +571,7 @@ impl String { /// [`into_bytes`]: String::into_bytes #[inline] #[stable(feature = "rust1", since = "1.0.0")] + #[cfg_attr(not(test), rustc_diagnostic_item = "string_from_utf8")] pub fn from_utf8(vec: Vec) -> Result { match str::from_utf8(&vec) { Ok(..) => Ok(String { vec }), From 9edfe1dc97f2fa74a156f5bda1b7ad3ef0770243 Mon Sep 17 00:00:00 2001 From: GnomedDev Date: Wed, 18 Sep 2024 22:13:50 +0100 Subject: [PATCH 15/19] [Clippy] Swap `manual_strip` to use diagnostic items instead of paths --- core/src/str/mod.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/src/str/mod.rs b/core/src/str/mod.rs index 9373d807f44e3..712bf011c273e 100644 --- a/core/src/str/mod.rs +++ b/core/src/str/mod.rs @@ -134,6 +134,7 @@ impl str { /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_stable(feature = "const_str_len", since = "1.39.0")] + #[cfg_attr(not(test), rustc_diagnostic_item = "str_len")] #[must_use] #[inline] pub const fn len(&self) -> usize { @@ -1157,6 +1158,7 @@ impl str { /// assert!(bananas.starts_with(&['a', 'b', 'c', 'd'])); /// ``` #[stable(feature = "rust1", since = "1.0.0")] + #[cfg_attr(not(test), rustc_diagnostic_item = "str_starts_with")] pub fn starts_with(&self, pat: P) -> bool { pat.is_prefix_of(self) } @@ -1181,6 +1183,7 @@ impl str { /// assert!(!bananas.ends_with("nana")); /// ``` #[stable(feature = "rust1", since = "1.0.0")] + #[cfg_attr(not(test), rustc_diagnostic_item = "str_ends_with")] pub fn ends_with(&self, pat: P) -> bool where for<'a> P::Searcher<'a>: ReverseSearcher<'a>, From 1b0be2aa3177d0dc8ac41297e39aea93820711e2 Mon Sep 17 00:00:00 2001 From: GnomedDev Date: Wed, 18 Sep 2024 22:38:27 +0100 Subject: [PATCH 16/19] [Clippy] Swap `unnecessary_owned_empty_strings` to use diagnostic item instead of path --- alloc/src/string.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/alloc/src/string.rs b/alloc/src/string.rs index 0bad33c909d61..d58a016b502ca 100644 --- a/alloc/src/string.rs +++ b/alloc/src/string.rs @@ -440,6 +440,7 @@ impl String { /// ``` #[inline] #[rustc_const_stable(feature = "const_string_new", since = "1.39.0")] + #[cfg_attr(not(test), rustc_diagnostic_item = "string_new")] #[stable(feature = "rust1", since = "1.0.0")] #[must_use] pub const fn new() -> String { From 8147cf45a2639e1f8dc94630657e9af435822974 Mon Sep 17 00:00:00 2001 From: GnomedDev Date: Wed, 18 Sep 2024 23:01:37 +0100 Subject: [PATCH 17/19] [Clippy] Swap `non_octal_unix_permissions` to use diagnostic item instead of path --- std/src/os/unix/fs.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/std/src/os/unix/fs.rs b/std/src/os/unix/fs.rs index caf6980afd91b..a964db2e0ac38 100644 --- a/std/src/os/unix/fs.rs +++ b/std/src/os/unix/fs.rs @@ -334,6 +334,7 @@ pub trait PermissionsExt { /// assert_eq!(permissions.mode(), 0o644); /// ``` #[stable(feature = "fs_ext", since = "1.1.0")] + #[cfg_attr(not(test), rustc_diagnostic_item = "permissions_from_mode")] fn from_mode(mode: u32) -> Self; } From 04bd505e5451e5d52c357dffaae4d431609bacc3 Mon Sep 17 00:00:00 2001 From: GnomedDev Date: Wed, 18 Sep 2024 23:21:35 +0100 Subject: [PATCH 18/19] [Clippy] Swap `iter_over_hash_type` to use diagnostic items instead of paths --- std/src/collections/hash/map.rs | 6 ++++++ std/src/collections/hash/set.rs | 2 ++ 2 files changed, 8 insertions(+) diff --git a/std/src/collections/hash/map.rs b/std/src/collections/hash/map.rs index 0d7346c7f1eae..1a18721b15e92 100644 --- a/std/src/collections/hash/map.rs +++ b/std/src/collections/hash/map.rs @@ -1393,6 +1393,7 @@ where /// let iter = map.iter(); /// ``` #[stable(feature = "rust1", since = "1.0.0")] +#[cfg_attr(not(test), rustc_diagnostic_item = "hashmap_iter_ty")] pub struct Iter<'a, K: 'a, V: 'a> { base: base::Iter<'a, K, V>, } @@ -1431,6 +1432,7 @@ impl fmt::Debug for Iter<'_, K, V> { /// let iter = map.iter_mut(); /// ``` #[stable(feature = "rust1", since = "1.0.0")] +#[cfg_attr(not(test), rustc_diagnostic_item = "hashmap_iter_mut_ty")] pub struct IterMut<'a, K: 'a, V: 'a> { base: base::IterMut<'a, K, V>, } @@ -1491,6 +1493,7 @@ impl IntoIter { /// let iter_keys = map.keys(); /// ``` #[stable(feature = "rust1", since = "1.0.0")] +#[cfg_attr(not(test), rustc_diagnostic_item = "hashmap_keys_ty")] pub struct Keys<'a, K: 'a, V: 'a> { inner: Iter<'a, K, V>, } @@ -1529,6 +1532,7 @@ impl fmt::Debug for Keys<'_, K, V> { /// let iter_values = map.values(); /// ``` #[stable(feature = "rust1", since = "1.0.0")] +#[cfg_attr(not(test), rustc_diagnostic_item = "hashmap_values_ty")] pub struct Values<'a, K: 'a, V: 'a> { inner: Iter<'a, K, V>, } @@ -1567,6 +1571,7 @@ impl fmt::Debug for Values<'_, K, V> { /// let iter = map.drain(); /// ``` #[stable(feature = "drain", since = "1.6.0")] +#[cfg_attr(not(test), rustc_diagnostic_item = "hashmap_drain_ty")] pub struct Drain<'a, K: 'a, V: 'a> { base: base::Drain<'a, K, V>, } @@ -1624,6 +1629,7 @@ where /// let iter_values = map.values_mut(); /// ``` #[stable(feature = "map_values_mut", since = "1.10.0")] +#[cfg_attr(not(test), rustc_diagnostic_item = "hashmap_values_mut_ty")] pub struct ValuesMut<'a, K: 'a, V: 'a> { inner: IterMut<'a, K, V>, } diff --git a/std/src/collections/hash/set.rs b/std/src/collections/hash/set.rs index e63d90645f777..4a113ddea3a6b 100644 --- a/std/src/collections/hash/set.rs +++ b/std/src/collections/hash/set.rs @@ -1271,6 +1271,7 @@ where /// let mut iter = a.iter(); /// ``` #[stable(feature = "rust1", since = "1.0.0")] +#[cfg_attr(not(test), rustc_diagnostic_item = "hashset_iter_ty")] pub struct Iter<'a, K: 'a> { base: base::Iter<'a, K>, } @@ -1313,6 +1314,7 @@ pub struct IntoIter { /// let mut drain = a.drain(); /// ``` #[stable(feature = "rust1", since = "1.0.0")] +#[cfg_attr(not(test), rustc_diagnostic_item = "hashset_drain_ty")] pub struct Drain<'a, K: 'a> { base: base::Drain<'a, K>, } From cb771b22bc6f2581973a35076d01bc5ba0ccdb81 Mon Sep 17 00:00:00 2001 From: GnomedDev Date: Thu, 19 Sep 2024 12:19:48 +0100 Subject: [PATCH 19/19] [Clippy] Swap `open_options` to use diagnostic items instead of paths --- std/src/fs.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/std/src/fs.rs b/std/src/fs.rs index abf7d5d294af4..92d3838d9f28f 100644 --- a/std/src/fs.rs +++ b/std/src/fs.rs @@ -466,6 +466,7 @@ impl File { /// ``` #[must_use] #[stable(feature = "with_options", since = "1.58.0")] + #[cfg_attr(not(test), rustc_diagnostic_item = "file_options")] pub fn options() -> OpenOptions { OpenOptions::new() } @@ -1009,6 +1010,7 @@ impl OpenOptions { /// let mut options = OpenOptions::new(); /// let file = options.read(true).open("foo.txt"); /// ``` + #[cfg_attr(not(test), rustc_diagnostic_item = "open_options_new")] #[stable(feature = "rust1", since = "1.0.0")] #[must_use] pub fn new() -> Self {