Skip to content

Commit f552ddf

Browse files
committed
Add more diagnostic items for clippy
1 parent af68593 commit f552ddf

Some content is hidden

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

76 files changed

+290
-266
lines changed

compiler/rustc_lint/src/noop_method_call.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,12 @@ impl<'tcx> LateLintPass<'tcx> for NoopMethodCall {
114114

115115
let orig_ty = expr_ty.peel_refs();
116116

117-
if receiver_ty == expr_ty {
117+
if receiver_ty == expr_ty
118+
&& matches!(
119+
name,
120+
sym::noop_method_borrow | sym::noop_method_clone | sym::noop_method_deref
121+
)
122+
{
118123
cx.emit_spanned_lint(
119124
NOOP_METHOD_CALL,
120125
span,

compiler/rustc_span/src/symbol.rs

+50
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,11 @@ symbols! {
129129
Alignment,
130130
Any,
131131
Arc,
132+
ArcWeak,
132133
Argument,
133134
ArgumentMethods,
134135
Arguments,
136+
ArrayIntoIter,
135137
AsMut,
136138
AsRef,
137139
AssertParamIsClone,
@@ -164,13 +166,15 @@ symbols! {
164166
Capture,
165167
Center,
166168
Clone,
169+
Command,
167170
ConstParamTy,
168171
Context,
169172
Continue,
170173
Copy,
171174
Count,
172175
Cow,
173176
Debug,
177+
DebugStruct,
174178
Decodable,
175179
Decoder,
176180
DecorateLint,
@@ -194,6 +198,8 @@ symbols! {
194198
From,
195199
FromIterator,
196200
FromResidual,
201+
FsOpenOptions,
202+
FsPermissions,
197203
Future,
198204
FutureOutput,
199205
FxHashMap,
@@ -207,16 +213,22 @@ symbols! {
207213
Implied,
208214
IndexOutput,
209215
Input,
216+
Instant,
210217
Into,
211218
IntoDiagnostic,
212219
IntoFuture,
213220
IntoIterator,
221+
IoLines,
214222
IoRead,
223+
IoSeek,
215224
IoWrite,
216225
IpAddr,
217226
IrTyKind,
218227
Is,
219228
ItemContext,
229+
IterEmpty,
230+
IterOnce,
231+
IterPeekable,
220232
Iterator,
221233
IteratorItem,
222234
Layout,
@@ -227,6 +239,7 @@ symbols! {
227239
Mutex,
228240
MutexGuard,
229241
N,
242+
NonNull,
230243
NonZeroI128,
231244
NonZeroI16,
232245
NonZeroI32,
@@ -259,15 +272,19 @@ symbols! {
259272
ProcMacro,
260273
ProceduralMasqueradeDummyType,
261274
Range,
275+
RangeBounds,
262276
RangeFrom,
263277
RangeFull,
264278
RangeInclusive,
265279
RangeTo,
266280
RangeToInclusive,
267281
Rc,
282+
RcWeak,
268283
Ready,
269284
Receiver,
270285
RefCell,
286+
RefCellRef,
287+
RefCellRefMut,
271288
Relaxed,
272289
Release,
273290
Result,
@@ -284,6 +301,7 @@ symbols! {
284301
Send,
285302
SeqCst,
286303
SliceIndex,
304+
SliceIter,
287305
Some,
288306
String,
289307
StructuralEq,
@@ -493,6 +511,7 @@ symbols! {
493511
clone,
494512
clone_closures,
495513
clone_from,
514+
clone_method,
496515
closure,
497516
closure_lifetime_binder,
498517
closure_to_fn_coercion,
@@ -561,6 +580,7 @@ symbols! {
561580
constant,
562581
constructor,
563582
context,
583+
convert_identity,
564584
copy,
565585
copy_closures,
566586
copy_nonoverlapping,
@@ -583,6 +603,7 @@ symbols! {
583603
crate_name,
584604
crate_type,
585605
crate_visibility_modifier,
606+
create_dir,
586607
crt_dash_static: "crt-static",
587608
csky_target_feature,
588609
cstring_type,
@@ -617,6 +638,7 @@ symbols! {
617638
decode,
618639
default_alloc_error_handler,
619640
default_lib_allocator,
641+
default_method,
620642
default_method_body_is_const,
621643
default_type_parameter_fallback,
622644
default_type_params,
@@ -628,6 +650,7 @@ symbols! {
628650
deref,
629651
deref_method,
630652
deref_mut,
653+
deref_mut_method,
631654
deref_target,
632655
derive,
633656
derive_const,
@@ -777,9 +800,11 @@ symbols! {
777800
from_desugaring,
778801
from_fn,
779802
from_iter,
803+
from_iterator_method,
780804
from_output,
781805
from_residual,
782806
from_size_align_unchecked,
807+
from_str_method,
783808
from_usize,
784809
from_yeet,
785810
fsub_fast,
@@ -962,6 +987,7 @@ symbols! {
962987
mem_replace,
963988
mem_size_of,
964989
mem_size_of_val,
990+
mem_swap,
965991
mem_uninitialized,
966992
mem_variant_count,
967993
mem_zeroed,
@@ -1091,6 +1117,7 @@ symbols! {
10911117
options,
10921118
or,
10931119
or_patterns,
1120+
ord_cmp_method,
10941121
other,
10951122
out,
10961123
overflow_checks,
@@ -1172,13 +1199,18 @@ symbols! {
11721199
proc_macro_mod,
11731200
proc_macro_non_items,
11741201
proc_macro_path_invoc,
1202+
process_exit,
11751203
profiler_builtins,
11761204
profiler_runtime,
11771205
ptr,
11781206
ptr_cast,
11791207
ptr_cast_const,
11801208
ptr_cast_mut,
11811209
ptr_const_is_null,
1210+
ptr_copy,
1211+
ptr_copy_nonoverlapping,
1212+
ptr_drop_in_place,
1213+
ptr_eq,
11821214
ptr_from_ref,
11831215
ptr_guaranteed_cmp,
11841216
ptr_is_null,
@@ -1187,8 +1219,19 @@ symbols! {
11871219
ptr_null_mut,
11881220
ptr_offset_from,
11891221
ptr_offset_from_unsigned,
1222+
ptr_read,
1223+
ptr_read_unaligned,
1224+
ptr_read_volatile,
1225+
ptr_replace,
1226+
ptr_slice_from_raw_parts,
1227+
ptr_slice_from_raw_parts_mut,
1228+
ptr_swap,
1229+
ptr_swap_nonoverlapping,
1230+
ptr_unaligned_volatile_load,
1231+
ptr_unaligned_volatile_store,
11901232
ptr_unique,
11911233
ptr_write,
1234+
ptr_write_bytes,
11921235
ptr_write_unaligned,
11931236
ptr_write_volatile,
11941237
pub_macro_rules,
@@ -1477,6 +1520,8 @@ symbols! {
14771520
sized,
14781521
skip,
14791522
slice,
1523+
slice_from_raw_parts,
1524+
slice_from_raw_parts_mut,
14801525
slice_len_fn,
14811526
slice_patterns,
14821527
slicing_syntax,
@@ -1502,6 +1547,8 @@ symbols! {
15021547
std_panic,
15031548
std_panic_2015_macro,
15041549
std_panic_macro,
1550+
stderr,
1551+
stdout,
15051552
stmt,
15061553
stmt_expr_attributes,
15071554
stop_after_dataflow,
@@ -1564,7 +1611,9 @@ symbols! {
15641611
thumb2,
15651612
thumb_mode: "thumb-mode",
15661613
tmm_reg,
1614+
to_owned_method,
15671615
to_string,
1616+
to_string_method,
15681617
to_vec,
15691618
todo_macro,
15701619
tool_attributes,
@@ -1587,6 +1636,7 @@ symbols! {
15871636
try_blocks,
15881637
try_capture,
15891638
try_from,
1639+
try_from_method,
15901640
try_into,
15911641
try_trait_v2,
15921642
tt,

library/alloc/src/borrow.rs

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ pub trait ToOwned {
5555
/// ```
5656
#[stable(feature = "rust1", since = "1.0.0")]
5757
#[must_use = "cloning is often expensive and is not expected to have side effects"]
58+
#[rustc_diagnostic_item = "to_owned_method"]
5859
fn to_owned(&self) -> Self::Owned;
5960

6061
/// Uses borrowed data to replace owned data, usually by cloning.

library/alloc/src/rc.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2680,6 +2680,7 @@ impl<T, I: iter::TrustedLen<Item = T>> ToRcSlice<T> for I {
26802680
///
26812681
/// [`upgrade`]: Weak::upgrade
26822682
#[stable(feature = "rc_weak", since = "1.4.0")]
2683+
#[rustc_diagnostic_item = "RcWeak"]
26832684
pub struct Weak<
26842685
T: ?Sized,
26852686
#[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global,

library/alloc/src/string.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2435,6 +2435,7 @@ pub trait ToString {
24352435
/// ```
24362436
#[rustc_conversion_suggestion]
24372437
#[stable(feature = "rust1", since = "1.0.0")]
2438+
#[rustc_diagnostic_item = "to_string_method"]
24382439
fn to_string(&self) -> String;
24392440
}
24402441

library/alloc/src/sync.rs

+1
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@ impl<T: ?Sized, A: Allocator> Arc<T, A> {
311311
///
312312
/// [`upgrade`]: Weak::upgrade
313313
#[stable(feature = "arc_weak", since = "1.4.0")]
314+
#[rustc_diagnostic_item = "ArcWeak"]
314315
pub struct Weak<
315316
T: ?Sized,
316317
#[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global,

library/core/src/array/iter.rs

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use crate::{
1313
/// A by-value [array] iterator.
1414
#[stable(feature = "array_value_iter", since = "1.51.0")]
1515
#[rustc_insignificant_dtor]
16+
#[rustc_diagnostic_item = "ArrayIntoIter"]
1617
pub struct IntoIter<T, const N: usize> {
1718
/// This is the array we are iterating over.
1819
///

library/core/src/cell.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1423,6 +1423,7 @@ impl Clone for BorrowRef<'_> {
14231423
/// See the [module-level documentation](self) for more.
14241424
#[stable(feature = "rust1", since = "1.0.0")]
14251425
#[must_not_suspend = "holding a Ref across suspend points can cause BorrowErrors"]
1426+
#[rustc_diagnostic_item = "RefCellRef"]
14261427
pub struct Ref<'b, T: ?Sized + 'b> {
14271428
// NB: we use a pointer instead of `&'b T` to avoid `noalias` violations, because a
14281429
// `Ref` argument doesn't hold immutability for its whole scope, only until it drops.
@@ -1804,6 +1805,7 @@ impl<'b> BorrowRefMut<'b> {
18041805
/// See the [module-level documentation](self) for more.
18051806
#[stable(feature = "rust1", since = "1.0.0")]
18061807
#[must_not_suspend = "holding a RefMut across suspend points can cause BorrowErrors"]
1808+
#[rustc_diagnostic_item = "RefCellRefMut"]
18071809
pub struct RefMut<'b, T: ?Sized + 'b> {
18081810
// NB: we use a pointer instead of `&'b mut T` to avoid `noalias` violations, because a
18091811
// `RefMut` argument doesn't hold exclusivity for its whole scope, only until it drops.

library/core/src/clone.rs

+1
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ pub trait Clone: Sized {
157157
/// ```
158158
#[stable(feature = "rust1", since = "1.0.0")]
159159
#[must_use = "cloning is often expensive and is not expected to have side effects"]
160+
#[rustc_diagnostic_item = "clone_method"]
160161
fn clone(&self) -> Self;
161162

162163
/// Performs copy-assignment from `source`.

library/core/src/cmp.rs

+1
Original file line numberDiff line numberDiff line change
@@ -790,6 +790,7 @@ pub trait Ord: Eq + PartialOrd<Self> {
790790
/// ```
791791
#[must_use]
792792
#[stable(feature = "rust1", since = "1.0.0")]
793+
#[rustc_diagnostic_item = "ord_cmp_method"]
793794
fn cmp(&self, other: &Self) -> Ordering;
794795

795796
/// Compares and returns the maximum of two values.

library/core/src/convert/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ pub use num::FloatToInt;
100100
#[stable(feature = "convert_id", since = "1.33.0")]
101101
#[rustc_const_stable(feature = "const_identity", since = "1.33.0")]
102102
#[inline(always)]
103+
#[rustc_diagnostic_item = "convert_identity"]
103104
pub const fn identity<T>(x: T) -> T {
104105
x
105106
}
@@ -642,6 +643,7 @@ pub trait TryFrom<T>: Sized {
642643

643644
/// Performs the conversion.
644645
#[stable(feature = "try_from", since = "1.34.0")]
646+
#[rustc_diagnostic_item = "try_from_method"]
645647
fn try_from(value: T) -> Result<Self, Self::Error>;
646648
}
647649

library/core/src/default.rs

+1
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ pub trait Default: Sized {
130130
/// }
131131
/// ```
132132
#[stable(feature = "rust1", since = "1.0.0")]
133+
#[rustc_diagnostic_item = "default_method"]
133134
fn default() -> Self;
134135
}
135136

library/core/src/fmt/builders.rs

+1
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ impl fmt::Write for PadAdapter<'_, '_> {
8484
#[must_use = "must eventually call `finish()` on Debug builders"]
8585
#[allow(missing_debug_implementations)]
8686
#[stable(feature = "debug_builders", since = "1.2.0")]
87+
#[rustc_diagnostic_item = "DebugStruct"]
8788
pub struct DebugStruct<'a, 'b: 'a> {
8889
fmt: &'a mut fmt::Formatter<'b>,
8990
result: fmt::Result,

library/core/src/fmt/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ impl<W: Write + ?Sized> Write for &mut W {
239239
/// documentation of the methods defined on `Formatter` below.
240240
#[allow(missing_debug_implementations)]
241241
#[stable(feature = "rust1", since = "1.0.0")]
242+
#[rustc_diagnostic_item = "Formatter"]
242243
pub struct Formatter<'a> {
243244
flags: u32,
244245
fill: char,

0 commit comments

Comments
 (0)