Skip to content

Commit

Permalink
Add more diagnostic items for clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarcho committed Sep 29, 2023
1 parent a66e334 commit dc95481
Show file tree
Hide file tree
Showing 74 changed files with 284 additions and 264 deletions.
49 changes: 49 additions & 0 deletions compiler/rustc_span/src/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,11 @@ symbols! {
Alignment,
Any,
Arc,
ArcWeak,
Argument,
ArgumentMethods,
Arguments,
ArrayIntoIter,
AsMut,
AsRef,
AssertParamIsClone,
Expand Down Expand Up @@ -164,13 +166,15 @@ symbols! {
Capture,
Center,
Clone,
Command,
ConstParamTy,
Context,
Continue,
Copy,
Count,
Cow,
Debug,
DebugStruct,
Decodable,
Decoder,
DecorateLint,
Expand All @@ -194,6 +198,8 @@ symbols! {
From,
FromIterator,
FromResidual,
FsOpenOptions,
FsPermissions,
Future,
FutureOutput,
FxHashMap,
Expand All @@ -207,16 +213,22 @@ symbols! {
Implied,
IndexOutput,
Input,
Instant,
Into,
IntoDiagnostic,
IntoFuture,
IntoIterator,
IoLines,
IoRead,
IoSeek,
IoWrite,
IpAddr,
IrTyKind,
Is,
ItemContext,
IterEmpty,
IterOnce,
IterPeekable,
Iterator,
IteratorItem,
Layout,
Expand All @@ -227,6 +239,7 @@ symbols! {
Mutex,
MutexGuard,
N,
NonNull,
NonZeroI128,
NonZeroI16,
NonZeroI32,
Expand Down Expand Up @@ -259,15 +272,19 @@ symbols! {
ProcMacro,
ProceduralMasqueradeDummyType,
Range,
RangeBounds,
RangeFrom,
RangeFull,
RangeInclusive,
RangeTo,
RangeToInclusive,
Rc,
RcWeak,
Ready,
Receiver,
RefCell,
RefCellRef,
RefCellRefMut,
Relaxed,
Release,
Result,
Expand All @@ -284,6 +301,7 @@ symbols! {
Send,
SeqCst,
SliceIndex,
SliceIter,
Some,
String,
StructuralEq,
Expand Down Expand Up @@ -561,6 +579,7 @@ symbols! {
constant,
constructor,
context,
convert_identity,
copy,
copy_closures,
copy_nonoverlapping,
Expand Down Expand Up @@ -616,6 +635,7 @@ symbols! {
declare_lint_pass,
decode,
default_alloc_error_handler,
default_fn,
default_lib_allocator,
default_method_body_is_const,
default_type_parameter_fallback,
Expand All @@ -628,6 +648,7 @@ symbols! {
deref,
deref_method,
deref_mut,
deref_mut_method,
deref_target,
derive,
derive_const,
Expand Down Expand Up @@ -777,11 +798,14 @@ symbols! {
from_desugaring,
from_fn,
from_iter,
from_iterator_method,
from_output,
from_residual,
from_size_align_unchecked,
from_str_method,
from_usize,
from_yeet,
fs_create_dir,
fsub_fast,
fundamental,
future,
Expand Down Expand Up @@ -868,6 +892,10 @@ symbols! {
into_iter,
intra_doc_pointers,
intrinsics,
intrinsics_unaligned_volatile_load,
intrinsics_unaligned_volatile_store,
io_stderr,
io_stdout,
irrefutable_let_patterns,
isa_attribute,
isize,
Expand Down Expand Up @@ -962,6 +990,7 @@ symbols! {
mem_replace,
mem_size_of,
mem_size_of_val,
mem_swap,
mem_uninitialized,
mem_variant_count,
mem_zeroed,
Expand Down Expand Up @@ -1091,6 +1120,7 @@ symbols! {
options,
or,
or_patterns,
ord_cmp_method,
other,
out,
overflow_checks,
Expand Down Expand Up @@ -1172,13 +1202,18 @@ symbols! {
proc_macro_mod,
proc_macro_non_items,
proc_macro_path_invoc,
process_exit,
profiler_builtins,
profiler_runtime,
ptr,
ptr_cast,
ptr_cast_const,
ptr_cast_mut,
ptr_const_is_null,
ptr_copy,
ptr_copy_nonoverlapping,
ptr_drop_in_place,
ptr_eq,
ptr_from_ref,
ptr_guaranteed_cmp,
ptr_is_null,
Expand All @@ -1187,8 +1222,17 @@ symbols! {
ptr_null_mut,
ptr_offset_from,
ptr_offset_from_unsigned,
ptr_read,
ptr_read_unaligned,
ptr_read_volatile,
ptr_replace,
ptr_slice_from_raw_parts,
ptr_slice_from_raw_parts_mut,
ptr_swap,
ptr_swap_nonoverlapping,
ptr_unique,
ptr_write,
ptr_write_bytes,
ptr_write_unaligned,
ptr_write_volatile,
pub_macro_rules,
Expand Down Expand Up @@ -1477,6 +1521,8 @@ symbols! {
sized,
skip,
slice,
slice_from_raw_parts,
slice_from_raw_parts_mut,
slice_len_fn,
slice_patterns,
slicing_syntax,
Expand Down Expand Up @@ -1564,7 +1610,9 @@ symbols! {
thumb2,
thumb_mode: "thumb-mode",
tmm_reg,
to_owned_method,
to_string,
to_string_method,
to_vec,
todo_macro,
tool_attributes,
Expand All @@ -1587,6 +1635,7 @@ symbols! {
try_blocks,
try_capture,
try_from,
try_from_fn,
try_into,
try_trait_v2,
tt,
Expand Down
1 change: 1 addition & 0 deletions library/alloc/src/borrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ pub trait ToOwned {
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[must_use = "cloning is often expensive and is not expected to have side effects"]
#[cfg_attr(not(test), rustc_diagnostic_item = "to_owned_method")]
fn to_owned(&self) -> Self::Owned;

/// Uses borrowed data to replace owned data, usually by cloning.
Expand Down
1 change: 1 addition & 0 deletions library/alloc/src/rc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2701,6 +2701,7 @@ impl<T, I: iter::TrustedLen<Item = T>> ToRcSlice<T> for I {
///
/// [`upgrade`]: Weak::upgrade
#[stable(feature = "rc_weak", since = "1.4.0")]
#[cfg_attr(not(test), rustc_diagnostic_item = "RcWeak")]
pub struct Weak<
T: ?Sized,
#[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global,
Expand Down
1 change: 1 addition & 0 deletions library/alloc/src/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2435,6 +2435,7 @@ pub trait ToString {
/// ```
#[rustc_conversion_suggestion]
#[stable(feature = "rust1", since = "1.0.0")]
#[cfg_attr(not(test), rustc_diagnostic_item = "to_string_method")]
fn to_string(&self) -> String;
}

Expand Down
1 change: 1 addition & 0 deletions library/alloc/src/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ impl<T: ?Sized, A: Allocator> Arc<T, A> {
///
/// [`upgrade`]: Weak::upgrade
#[stable(feature = "arc_weak", since = "1.4.0")]
#[cfg_attr(not(test), rustc_diagnostic_item = "ArcWeak")]
pub struct Weak<
T: ?Sized,
#[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global,
Expand Down
1 change: 1 addition & 0 deletions library/core/src/array/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use crate::{
/// A by-value [array] iterator.
#[stable(feature = "array_value_iter", since = "1.51.0")]
#[rustc_insignificant_dtor]
#[rustc_diagnostic_item = "ArrayIntoIter"]
pub struct IntoIter<T, const N: usize> {
/// This is the array we are iterating over.
///
Expand Down
2 changes: 2 additions & 0 deletions library/core/src/cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1423,6 +1423,7 @@ impl Clone for BorrowRef<'_> {
/// See the [module-level documentation](self) for more.
#[stable(feature = "rust1", since = "1.0.0")]
#[must_not_suspend = "holding a Ref across suspend points can cause BorrowErrors"]
#[rustc_diagnostic_item = "RefCellRef"]
pub struct Ref<'b, T: ?Sized + 'b> {
// NB: we use a pointer instead of `&'b T` to avoid `noalias` violations, because a
// `Ref` argument doesn't hold immutability for its whole scope, only until it drops.
Expand Down Expand Up @@ -1804,6 +1805,7 @@ impl<'b> BorrowRefMut<'b> {
/// See the [module-level documentation](self) for more.
#[stable(feature = "rust1", since = "1.0.0")]
#[must_not_suspend = "holding a RefMut across suspend points can cause BorrowErrors"]
#[rustc_diagnostic_item = "RefCellRefMut"]
pub struct RefMut<'b, T: ?Sized + 'b> {
// NB: we use a pointer instead of `&'b mut T` to avoid `noalias` violations, because a
// `RefMut` argument doesn't hold exclusivity for its whole scope, only until it drops.
Expand Down
1 change: 1 addition & 0 deletions library/core/src/cmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,7 @@ pub trait Ord: Eq + PartialOrd<Self> {
/// ```
#[must_use]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_diagnostic_item = "ord_cmp_method"]
fn cmp(&self, other: &Self) -> Ordering;

/// Compares and returns the maximum of two values.
Expand Down
2 changes: 2 additions & 0 deletions library/core/src/convert/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ pub use num::FloatToInt;
#[stable(feature = "convert_id", since = "1.33.0")]
#[rustc_const_stable(feature = "const_identity", since = "1.33.0")]
#[inline(always)]
#[rustc_diagnostic_item = "convert_identity"]
pub const fn identity<T>(x: T) -> T {
x
}
Expand Down Expand Up @@ -642,6 +643,7 @@ pub trait TryFrom<T>: Sized {

/// Performs the conversion.
#[stable(feature = "try_from", since = "1.34.0")]
#[rustc_diagnostic_item = "try_from_fn"]
fn try_from(value: T) -> Result<Self, Self::Error>;
}

Expand Down
1 change: 1 addition & 0 deletions library/core/src/default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ pub trait Default: Sized {
/// }
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_diagnostic_item = "default_fn"]
fn default() -> Self;
}

Expand Down
1 change: 1 addition & 0 deletions library/core/src/fmt/builders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ impl fmt::Write for PadAdapter<'_, '_> {
#[must_use = "must eventually call `finish()` on Debug builders"]
#[allow(missing_debug_implementations)]
#[stable(feature = "debug_builders", since = "1.2.0")]
#[rustc_diagnostic_item = "DebugStruct"]
pub struct DebugStruct<'a, 'b: 'a> {
fmt: &'a mut fmt::Formatter<'b>,
result: fmt::Result,
Expand Down
1 change: 1 addition & 0 deletions library/core/src/fmt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ impl<W: Write + ?Sized> Write for &mut W {
/// documentation of the methods defined on `Formatter` below.
#[allow(missing_debug_implementations)]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_diagnostic_item = "Formatter"]
pub struct Formatter<'a> {
flags: u32,
fill: char,
Expand Down
5 changes: 5 additions & 0 deletions library/core/src/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1509,12 +1509,14 @@ extern "rust-intrinsic" {
///
/// This intrinsic does not have a stable counterpart.
#[rustc_nounwind]
#[rustc_diagnostic_item = "intrinsics_unaligned_volatile_load"]
pub fn unaligned_volatile_load<T>(src: *const T) -> T;
/// Performs a volatile store to the `dst` pointer.
/// The pointer is not required to be aligned.
///
/// This intrinsic does not have a stable counterpart.
#[rustc_nounwind]
#[rustc_diagnostic_item = "intrinsics_unaligned_volatile_store"]
pub fn unaligned_volatile_store<T>(dst: *mut T, val: T);

/// Returns the square root of an `f32`
Expand Down Expand Up @@ -2666,6 +2668,7 @@ pub(crate) fn is_nonoverlapping<T>(src: *const T, dst: *const T, count: usize) -
#[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.63.0")]
#[inline(always)]
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
#[rustc_diagnostic_item = "ptr_copy_nonoverlapping"]
pub const unsafe fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: usize) {
extern "rust-intrinsic" {
#[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.63.0")]
Expand Down Expand Up @@ -2761,6 +2764,7 @@ pub const unsafe fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: us
#[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.63.0")]
#[inline(always)]
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
#[rustc_diagnostic_item = "ptr_copy"]
pub const unsafe fn copy<T>(src: *const T, dst: *mut T, count: usize) {
extern "rust-intrinsic" {
#[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.63.0")]
Expand Down Expand Up @@ -2834,6 +2838,7 @@ pub const unsafe fn copy<T>(src: *const T, dst: *mut T, count: usize) {
#[rustc_const_unstable(feature = "const_ptr_write", issue = "86302")]
#[inline(always)]
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
#[rustc_diagnostic_item = "ptr_write_bytes"]
pub const unsafe fn write_bytes<T>(dst: *mut T, val: u8, count: usize) {
extern "rust-intrinsic" {
#[rustc_const_unstable(feature = "const_ptr_write", issue = "86302")]
Expand Down
1 change: 1 addition & 0 deletions library/core/src/iter/adapters/peekable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use crate::ops::{ControlFlow, Try};
#[derive(Clone, Debug)]
#[must_use = "iterators are lazy and do nothing unless consumed"]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_diagnostic_item = "IterPeekable"]
pub struct Peekable<I: Iterator> {
iter: I,
/// Remember a peeked value, even if it was None.
Expand Down
1 change: 1 addition & 0 deletions library/core/src/iter/sources/empty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ pub const fn empty<T>() -> Empty<T> {
/// This `struct` is created by the [`empty()`] function. See its documentation for more.
#[must_use = "iterators are lazy and do nothing unless consumed"]
#[stable(feature = "iter_empty", since = "1.2.0")]
#[rustc_diagnostic_item = "IterEmpty"]
pub struct Empty<T>(marker::PhantomData<fn() -> T>);

#[stable(feature = "core_impl_debug", since = "1.9.0")]
Expand Down
1 change: 1 addition & 0 deletions library/core/src/iter/sources/once.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ pub fn once<T>(value: T) -> Once<T> {
/// This `struct` is created by the [`once()`] function. See its documentation for more.
#[derive(Clone, Debug)]
#[stable(feature = "iter_once", since = "1.2.0")]
#[rustc_diagnostic_item = "IterOnce"]
pub struct Once<T> {
inner: crate::option::IntoIter<T>,
}
Expand Down
Loading

0 comments on commit dc95481

Please sign in to comment.