Skip to content

Commit

Permalink
[Clippy] Swap option_as_ref_deref to use diagnostic items instead o…
Browse files Browse the repository at this point in the history
…f paths
  • Loading branch information
GnomedDev committed Sep 19, 2024
1 parent b8c0c3b commit 6ef72c4
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions alloc/src/ffi/c_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 2 additions & 0 deletions alloc/src/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
}
Expand Down
2 changes: 2 additions & 0 deletions alloc/src/vec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1545,6 +1545,7 @@ impl<T, A: Allocator> Vec<T, A> {
/// ```
#[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
}
Expand All @@ -1562,6 +1563,7 @@ impl<T, A: Allocator> Vec<T, A> {
/// ```
#[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
}
Expand Down
1 change: 1 addition & 0 deletions std/src/ffi/os_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
1 change: 1 addition & 0 deletions std/src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit 6ef72c4

Please sign in to comment.