Skip to content

Commit 569153a

Browse files
authored
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 rust-lang/rust-clippy#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.
2 parents 767ae2b + 13d5732 commit 569153a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+203
-163
lines changed

compiler/rustc_span/src/symbol.rs

+46
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,7 @@ symbols! {
342342
Upvars,
343343
Vec,
344344
VecDeque,
345+
Waker,
345346
Wrapper,
346347
Wrapping,
347348
Yield,
@@ -501,6 +502,7 @@ symbols! {
501502
black_box,
502503
block,
503504
bool,
505+
bool_then,
504506
borrowck_graphviz_format,
505507
borrowck_graphviz_postflow,
506508
box_new,
@@ -512,6 +514,8 @@ symbols! {
512514
breakpoint,
513515
bridge,
514516
bswap,
517+
btreemap_contains_key,
518+
btreemap_insert,
515519
btreeset_iter,
516520
builtin_syntax,
517521
c,
@@ -680,6 +684,7 @@ symbols! {
680684
crt_dash_static: "crt-static",
681685
csky_target_feature,
682686
cstr_type,
687+
cstring_as_c_str,
683688
cstring_type,
684689
ctlz,
685690
ctlz_nonzero,
@@ -835,6 +840,7 @@ symbols! {
835840
f16_nan,
836841
f16c_target_feature,
837842
f32,
843+
f32_epsilon,
838844
f32_legacy_const_digits,
839845
f32_legacy_const_epsilon,
840846
f32_legacy_const_infinity,
@@ -851,6 +857,7 @@ symbols! {
851857
f32_legacy_const_radix,
852858
f32_nan,
853859
f64,
860+
f64_epsilon,
854861
f64_legacy_const_digits,
855862
f64_legacy_const_epsilon,
856863
f64_legacy_const_infinity,
@@ -888,6 +895,7 @@ symbols! {
888895
field,
889896
field_init_shorthand,
890897
file,
898+
file_options,
891899
float,
892900
float_to_int_unchecked,
893901
floorf128,
@@ -973,7 +981,17 @@ symbols! {
973981
half_open_range_patterns,
974982
half_open_range_patterns_in_slices,
975983
hash,
984+
hashmap_contains_key,
985+
hashmap_drain_ty,
986+
hashmap_insert,
987+
hashmap_iter_mut_ty,
988+
hashmap_iter_ty,
989+
hashmap_keys_ty,
990+
hashmap_values_mut_ty,
991+
hashmap_values_ty,
992+
hashset_drain_ty,
976993
hashset_iter,
994+
hashset_iter_ty,
977995
hexagon_target_feature,
978996
hidden,
979997
homogeneous_aggregate,
@@ -1052,6 +1070,7 @@ symbols! {
10521070
inline_const,
10531071
inline_const_pat,
10541072
inout,
1073+
instant_now,
10551074
instruction_set,
10561075
integer_: "integer", // underscore to avoid clashing with the function `sym::integer` below
10571076
integral,
@@ -1352,17 +1371,22 @@ symbols! {
13521371
on,
13531372
on_unimplemented,
13541373
opaque,
1374+
open_options_new,
13551375
ops,
13561376
opt_out_copy,
13571377
optimize,
13581378
optimize_attribute,
13591379
optin_builtin_traits,
13601380
option,
13611381
option_env,
1382+
option_expect,
1383+
option_unwrap,
13621384
options,
13631385
or,
13641386
or_patterns,
13651387
ord_cmp_method,
1388+
os_str_to_os_string,
1389+
os_string_as_os_str,
13661390
other,
13671391
out,
13681392
overflow_checks,
@@ -1416,10 +1440,14 @@ symbols! {
14161440
pat_param,
14171441
patchable_function_entry,
14181442
path,
1443+
path_main_separator,
1444+
path_to_pathbuf,
1445+
pathbuf_as_path,
14191446
pattern_complexity,
14201447
pattern_parentheses,
14211448
pattern_type,
14221449
pattern_types,
1450+
permissions_from_mode,
14231451
phantom_data,
14241452
pic,
14251453
pie,
@@ -1571,6 +1599,7 @@ symbols! {
15711599
residual,
15721600
result,
15731601
result_ffi_guarantees,
1602+
result_ok_method,
15741603
resume,
15751604
return_position_impl_trait_in_trait,
15761605
return_type_notation,
@@ -1823,6 +1852,7 @@ symbols! {
18231852
slice,
18241853
slice_from_raw_parts,
18251854
slice_from_raw_parts_mut,
1855+
slice_into_vec,
18261856
slice_iter,
18271857
slice_len_fn,
18281858
slice_patterns,
@@ -1857,16 +1887,25 @@ symbols! {
18571887
store,
18581888
str,
18591889
str_chars,
1890+
str_ends_with,
18601891
str_from_utf8,
18611892
str_from_utf8_mut,
18621893
str_from_utf8_unchecked,
18631894
str_from_utf8_unchecked_mut,
1895+
str_len,
18641896
str_split_whitespace,
1897+
str_starts_with,
18651898
str_trim,
18661899
str_trim_end,
18671900
str_trim_start,
18681901
strict_provenance,
1902+
string_as_mut_str,
1903+
string_as_str,
18691904
string_deref_patterns,
1905+
string_from_utf8,
1906+
string_insert_str,
1907+
string_new,
1908+
string_push_str,
18701909
stringify,
18711910
struct_field_attributes,
18721911
struct_inherit,
@@ -2071,7 +2110,14 @@ symbols! {
20712110
var,
20722111
variant_count,
20732112
vec,
2113+
vec_as_mut_slice,
2114+
vec_as_slice,
2115+
vec_from_elem,
2116+
vec_is_empty,
20742117
vec_macro,
2118+
vec_new,
2119+
vec_pop,
2120+
vec_with_capacity,
20752121
vecdeque_iter,
20762122
version,
20772123
vfp2,

library/alloc/src/collections/btree/map.rs

+2
Original file line numberDiff line numberDiff line change
@@ -916,6 +916,7 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
916916
/// assert_eq!(map.contains_key(&2), false);
917917
/// ```
918918
#[stable(feature = "rust1", since = "1.0.0")]
919+
#[cfg_attr(not(test), rustc_diagnostic_item = "btreemap_contains_key")]
919920
pub fn contains_key<Q: ?Sized>(&self, key: &Q) -> bool
920921
where
921922
K: Borrow<Q> + Ord,
@@ -981,6 +982,7 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
981982
/// ```
982983
#[stable(feature = "rust1", since = "1.0.0")]
983984
#[rustc_confusables("push", "put", "set")]
985+
#[cfg_attr(not(test), rustc_diagnostic_item = "btreemap_insert")]
984986
pub fn insert(&mut self, key: K, value: V) -> Option<V>
985987
where
986988
K: Ord,

library/alloc/src/ffi/c_str.rs

+1
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,7 @@ impl CString {
576576
#[inline]
577577
#[must_use]
578578
#[stable(feature = "as_c_str", since = "1.20.0")]
579+
#[cfg_attr(not(test), rustc_diagnostic_item = "cstring_as_c_str")]
579580
pub fn as_c_str(&self) -> &CStr {
580581
&*self
581582
}

library/alloc/src/slice.rs

+1
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,7 @@ impl<T> [T] {
496496
#[rustc_allow_incoherent_impl]
497497
#[stable(feature = "rust1", since = "1.0.0")]
498498
#[inline]
499+
#[cfg_attr(not(test), rustc_diagnostic_item = "slice_into_vec")]
499500
pub fn into_vec<A: Allocator>(self: Box<Self, A>) -> Vec<T, A> {
500501
// N.B., see the `hack` module in this file for more details.
501502
hack::into_vec(self)

library/alloc/src/string.rs

+6
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,7 @@ impl String {
440440
/// ```
441441
#[inline]
442442
#[rustc_const_stable(feature = "const_string_new", since = "1.39.0")]
443+
#[cfg_attr(not(test), rustc_diagnostic_item = "string_new")]
443444
#[stable(feature = "rust1", since = "1.0.0")]
444445
#[must_use]
445446
pub const fn new() -> String {
@@ -571,6 +572,7 @@ impl String {
571572
/// [`into_bytes`]: String::into_bytes
572573
#[inline]
573574
#[stable(feature = "rust1", since = "1.0.0")]
575+
#[cfg_attr(not(test), rustc_diagnostic_item = "string_from_utf8")]
574576
pub fn from_utf8(vec: Vec<u8>) -> Result<String, FromUtf8Error> {
575577
match str::from_utf8(&vec) {
576578
Ok(..) => Ok(String { vec }),
@@ -1073,6 +1075,7 @@ impl String {
10731075
#[inline]
10741076
#[must_use]
10751077
#[stable(feature = "string_as_str", since = "1.7.0")]
1078+
#[cfg_attr(not(test), rustc_diagnostic_item = "string_as_str")]
10761079
pub fn as_str(&self) -> &str {
10771080
self
10781081
}
@@ -1092,6 +1095,7 @@ impl String {
10921095
#[inline]
10931096
#[must_use]
10941097
#[stable(feature = "string_as_str", since = "1.7.0")]
1098+
#[cfg_attr(not(test), rustc_diagnostic_item = "string_as_mut_str")]
10951099
pub fn as_mut_str(&mut self) -> &mut str {
10961100
self
10971101
}
@@ -1111,6 +1115,7 @@ impl String {
11111115
#[inline]
11121116
#[stable(feature = "rust1", since = "1.0.0")]
11131117
#[rustc_confusables("append", "push")]
1118+
#[cfg_attr(not(test), rustc_diagnostic_item = "string_push_str")]
11141119
pub fn push_str(&mut self, string: &str) {
11151120
self.vec.extend_from_slice(string.as_bytes())
11161121
}
@@ -1745,6 +1750,7 @@ impl String {
17451750
#[cfg(not(no_global_oom_handling))]
17461751
#[inline]
17471752
#[stable(feature = "insert_str", since = "1.16.0")]
1753+
#[cfg_attr(not(test), rustc_diagnostic_item = "string_insert_str")]
17481754
pub fn insert_str(&mut self, idx: usize, string: &str) {
17491755
assert!(self.is_char_boundary(idx));
17501756

library/alloc/src/vec/mod.rs

+7
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,7 @@ impl<T> Vec<T> {
416416
/// ```
417417
#[inline]
418418
#[rustc_const_stable(feature = "const_vec_new", since = "1.39.0")]
419+
#[cfg_attr(not(test), rustc_diagnostic_item = "vec_new")]
419420
#[stable(feature = "rust1", since = "1.0.0")]
420421
#[must_use]
421422
pub const fn new() -> Self {
@@ -476,6 +477,7 @@ impl<T> Vec<T> {
476477
#[inline]
477478
#[stable(feature = "rust1", since = "1.0.0")]
478479
#[must_use]
480+
#[cfg_attr(not(test), rustc_diagnostic_item = "vec_with_capacity")]
479481
pub fn with_capacity(capacity: usize) -> Self {
480482
Self::with_capacity_in(capacity, Global)
481483
}
@@ -1545,6 +1547,7 @@ impl<T, A: Allocator> Vec<T, A> {
15451547
/// ```
15461548
#[inline]
15471549
#[stable(feature = "vec_as_slice", since = "1.7.0")]
1550+
#[cfg_attr(not(test), rustc_diagnostic_item = "vec_as_slice")]
15481551
pub fn as_slice(&self) -> &[T] {
15491552
self
15501553
}
@@ -1562,6 +1565,7 @@ impl<T, A: Allocator> Vec<T, A> {
15621565
/// ```
15631566
#[inline]
15641567
#[stable(feature = "vec_as_slice", since = "1.7.0")]
1568+
#[cfg_attr(not(test), rustc_diagnostic_item = "vec_as_mut_slice")]
15651569
pub fn as_mut_slice(&mut self) -> &mut [T] {
15661570
self
15671571
}
@@ -2380,6 +2384,7 @@ impl<T, A: Allocator> Vec<T, A> {
23802384
/// Takes *O*(1) time.
23812385
#[inline]
23822386
#[stable(feature = "rust1", since = "1.0.0")]
2387+
#[cfg_attr(not(test), rustc_diagnostic_item = "vec_pop")]
23832388
pub fn pop(&mut self) -> Option<T> {
23842389
if self.len == 0 {
23852390
None
@@ -2573,6 +2578,7 @@ impl<T, A: Allocator> Vec<T, A> {
25732578
/// assert!(!v.is_empty());
25742579
/// ```
25752580
#[stable(feature = "rust1", since = "1.0.0")]
2581+
#[cfg_attr(not(test), rustc_diagnostic_item = "vec_is_empty")]
25762582
pub fn is_empty(&self) -> bool {
25772583
self.len() == 0
25782584
}
@@ -3044,6 +3050,7 @@ impl<T: PartialEq, A: Allocator> Vec<T, A> {
30443050
#[doc(hidden)]
30453051
#[cfg(not(no_global_oom_handling))]
30463052
#[stable(feature = "rust1", since = "1.0.0")]
3053+
#[cfg_attr(not(test), rustc_diagnostic_item = "vec_from_elem")]
30473054
pub fn from_elem<T: Clone>(elem: T, n: usize) -> Vec<T> {
30483055
<T as SpecFromElem>::from_elem(elem, n, Global)
30493056
}

library/core/src/bool.rs

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ impl bool {
5555
/// assert_eq!(a, 1);
5656
/// ```
5757
#[stable(feature = "lazy_bool_to_option", since = "1.50.0")]
58+
#[cfg_attr(not(test), rustc_diagnostic_item = "bool_then")]
5859
#[inline]
5960
pub fn then<T, F: FnOnce() -> T>(self, f: F) -> Option<T> {
6061
if self { Some(f()) } else { None }

library/core/src/num/f32.rs

+1
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,7 @@ impl f32 {
415415
/// [Machine epsilon]: https://en.wikipedia.org/wiki/Machine_epsilon
416416
/// [`MANTISSA_DIGITS`]: f32::MANTISSA_DIGITS
417417
#[stable(feature = "assoc_int_consts", since = "1.43.0")]
418+
#[cfg_attr(not(test), rustc_diagnostic_item = "f32_epsilon")]
418419
pub const EPSILON: f32 = 1.19209290e-07_f32;
419420

420421
/// Smallest finite `f32` value.

library/core/src/num/f64.rs

+1
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,7 @@ impl f64 {
414414
/// [Machine epsilon]: https://en.wikipedia.org/wiki/Machine_epsilon
415415
/// [`MANTISSA_DIGITS`]: f64::MANTISSA_DIGITS
416416
#[stable(feature = "assoc_int_consts", since = "1.43.0")]
417+
#[cfg_attr(not(test), rustc_diagnostic_item = "f64_epsilon")]
417418
pub const EPSILON: f64 = 2.2204460492503131e-16_f64;
418419

419420
/// Smallest finite `f64` value.

library/core/src/option.rs

+2
Original file line numberDiff line numberDiff line change
@@ -923,6 +923,7 @@ impl<T> Option<T> {
923923
#[inline]
924924
#[track_caller]
925925
#[stable(feature = "rust1", since = "1.0.0")]
926+
#[cfg_attr(not(test), rustc_diagnostic_item = "option_expect")]
926927
#[rustc_const_unstable(feature = "const_option", issue = "67441")]
927928
pub const fn expect(self, msg: &str) -> T {
928929
match self {
@@ -960,6 +961,7 @@ impl<T> Option<T> {
960961
#[inline(always)]
961962
#[track_caller]
962963
#[stable(feature = "rust1", since = "1.0.0")]
964+
#[cfg_attr(not(test), rustc_diagnostic_item = "option_unwrap")]
963965
#[rustc_const_unstable(feature = "const_option", issue = "67441")]
964966
pub const fn unwrap(self) -> T {
965967
match self {

library/core/src/result.rs

+1
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,7 @@ impl<T, E> Result<T, E> {
653653
/// ```
654654
#[inline]
655655
#[stable(feature = "rust1", since = "1.0.0")]
656+
#[cfg_attr(not(test), rustc_diagnostic_item = "result_ok_method")]
656657
pub fn ok(self) -> Option<T> {
657658
match self {
658659
Ok(x) => Some(x),

library/core/src/str/mod.rs

+3
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ impl str {
134134
/// ```
135135
#[stable(feature = "rust1", since = "1.0.0")]
136136
#[rustc_const_stable(feature = "const_str_len", since = "1.39.0")]
137+
#[cfg_attr(not(test), rustc_diagnostic_item = "str_len")]
137138
#[must_use]
138139
#[inline]
139140
pub const fn len(&self) -> usize {
@@ -1157,6 +1158,7 @@ impl str {
11571158
/// assert!(bananas.starts_with(&['a', 'b', 'c', 'd']));
11581159
/// ```
11591160
#[stable(feature = "rust1", since = "1.0.0")]
1161+
#[cfg_attr(not(test), rustc_diagnostic_item = "str_starts_with")]
11601162
pub fn starts_with<P: Pattern>(&self, pat: P) -> bool {
11611163
pat.is_prefix_of(self)
11621164
}
@@ -1181,6 +1183,7 @@ impl str {
11811183
/// assert!(!bananas.ends_with("nana"));
11821184
/// ```
11831185
#[stable(feature = "rust1", since = "1.0.0")]
1186+
#[cfg_attr(not(test), rustc_diagnostic_item = "str_ends_with")]
11841187
pub fn ends_with<P: Pattern>(&self, pat: P) -> bool
11851188
where
11861189
for<'a> P::Searcher<'a>: ReverseSearcher<'a>,

library/core/src/task/wake.rs

+1
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,7 @@ impl<'a> ContextBuilder<'a> {
414414
/// [`Wake`]: ../../alloc/task/trait.Wake.html
415415
#[repr(transparent)]
416416
#[stable(feature = "futures_api", since = "1.36.0")]
417+
#[cfg_attr(not(test), rustc_diagnostic_item = "Waker")]
417418
pub struct Waker {
418419
waker: RawWaker,
419420
}

0 commit comments

Comments
 (0)