about summary refs log tree commit diff
path: root/library/core
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2024-09-19 20:37:07 +0200
committerGitHub <noreply@github.com>2024-09-19 20:37:07 +0200
commit569153a432775da4be886c0163030234880fc656 (patch)
tree6337e269869f1de7d427d1b6e8b1e19faf602c07 /library/core
parent767ae2b33d3a84502772b1ad9f80825b4e03ce22 (diff)
parent13d573281111fda85692623350a51640596847ee (diff)
downloadrust-569153a432775da4be886c0163030234880fc656.tar.gz
rust-569153a432775da4be886c0163030234880fc656.zip
Rollup merge of #130553 - GnomedDev:remove-clippy-paths, r=compiler-errors
[Clippy] Get rid of most `std` `match_def_path` usage, swap to diagnostic items.

Part of https://github.com/rust-lang/rust-clippy/issues/5393.

This was going to remove all `std` paths, but `SeekFrom` has issues being cleanly replaced with a diagnostic item as the paths are for variants, which currently cannot be diagnostic items.

This also, as a last step, categories the paths to help with future path removals.
Diffstat (limited to 'library/core')
-rw-r--r--library/core/src/bool.rs1
-rw-r--r--library/core/src/num/f32.rs1
-rw-r--r--library/core/src/num/f64.rs1
-rw-r--r--library/core/src/option.rs2
-rw-r--r--library/core/src/result.rs1
-rw-r--r--library/core/src/str/mod.rs3
-rw-r--r--library/core/src/task/wake.rs1
7 files changed, 10 insertions, 0 deletions
diff --git a/library/core/src/bool.rs b/library/core/src/bool.rs
index 03cdff9b13b..58a870d2e07 100644
--- a/library/core/src/bool.rs
+++ b/library/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, F: FnOnce() -> T>(self, f: F) -> Option<T> {
         if self { Some(f()) } else { None }
diff --git a/library/core/src/num/f32.rs b/library/core/src/num/f32.rs
index 4c2a4ee3b32..d0eb6bb3f28 100644
--- a/library/core/src/num/f32.rs
+++ b/library/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/library/core/src/num/f64.rs b/library/core/src/num/f64.rs
index 87fb5fe7ebe..4bc275ad147 100644
--- a/library/core/src/num/f64.rs
+++ b/library/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.
diff --git a/library/core/src/option.rs b/library/core/src/option.rs
index 265f056dc87..5ba13969605 100644
--- a/library/core/src/option.rs
+++ b/library/core/src/option.rs
@@ -923,6 +923,7 @@ impl<T> Option<T> {
     #[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<T> Option<T> {
     #[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 {
diff --git a/library/core/src/result.rs b/library/core/src/result.rs
index 02f6f783b51..9edd58259ba 100644
--- a/library/core/src/result.rs
+++ b/library/core/src/result.rs
@@ -653,6 +653,7 @@ impl<T, E> Result<T, E> {
     /// ```
     #[inline]
     #[stable(feature = "rust1", since = "1.0.0")]
+    #[cfg_attr(not(test), rustc_diagnostic_item = "result_ok_method")]
     pub fn ok(self) -> Option<T> {
         match self {
             Ok(x) => Some(x),
diff --git a/library/core/src/str/mod.rs b/library/core/src/str/mod.rs
index 9373d807f44..712bf011c27 100644
--- a/library/core/src/str/mod.rs
+++ b/library/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<P: Pattern>(&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<P: Pattern>(&self, pat: P) -> bool
     where
         for<'a> P::Searcher<'a>: ReverseSearcher<'a>,
diff --git a/library/core/src/task/wake.rs b/library/core/src/task/wake.rs
index 5e559ad8d2c..a5103499c8a 100644
--- a/library/core/src/task/wake.rs
+++ b/library/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,
 }