From 6ef72c4aead7ffa92d13c89dba87ff1e185627b5 Mon Sep 17 00:00:00 2001 From: GnomedDev Date: Wed, 18 Sep 2024 21:09:06 +0100 Subject: [PATCH] [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]