Skip to content

Commit 1a90004

Browse files
committed
Added diagnostic items to functions for Clippy
1 parent 3982eb3 commit 1a90004

File tree

4 files changed

+18
-0
lines changed

4 files changed

+18
-0
lines changed

compiler/rustc_span/src/symbol.rs

+9
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,8 @@ symbols! {
368368
closure,
369369
closure_to_fn_coercion,
370370
cmp,
371+
cmp_max,
372+
cmp_min,
371373
cmpxchg16b_target_feature,
372374
cmse_nonsecure_entry,
373375
coerce_unsized,
@@ -672,6 +674,7 @@ symbols! {
672674
item,
673675
item_like_imports,
674676
iter,
677+
iter_repeat,
675678
keyword,
676679
kind,
677680
kreg,
@@ -738,6 +741,12 @@ symbols! {
738741
maybe_uninit,
739742
maybe_uninit_uninit,
740743
maybe_uninit_zeroed,
744+
mem_discriminant,
745+
mem_drop,
746+
mem_forget,
747+
mem_replace,
748+
mem_size_of,
749+
mem_size_of_val,
741750
mem_uninitialized,
742751
mem_zeroed,
743752
member_constraints,

library/core/src/cmp.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1104,6 +1104,7 @@ pub macro PartialOrd($item:item) {
11041104
#[inline]
11051105
#[must_use]
11061106
#[stable(feature = "rust1", since = "1.0.0")]
1107+
#[cfg_attr(not(test), rustc_diagnostic_item = "cmp_min")]
11071108
pub fn min<T: Ord>(v1: T, v2: T) -> T {
11081109
v1.min(v2)
11091110
}
@@ -1166,6 +1167,7 @@ pub fn min_by_key<T, F: FnMut(&T) -> K, K: Ord>(v1: T, v2: T, mut f: F) -> T {
11661167
#[inline]
11671168
#[must_use]
11681169
#[stable(feature = "rust1", since = "1.0.0")]
1170+
#[cfg_attr(not(test), rustc_diagnostic_item = "cmp_max")]
11691171
pub fn max<T: Ord>(v1: T, v2: T) -> T {
11701172
v1.max(v2)
11711173
}

library/core/src/iter/sources/repeat.rs

+1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ use crate::iter::{FusedIterator, TrustedLen};
5151
/// ```
5252
#[inline]
5353
#[stable(feature = "rust1", since = "1.0.0")]
54+
#[cfg_attr(not(test), rustc_diagnostic_item = "iter_repeat")]
5455
pub fn repeat<T: Clone>(elt: T) -> Repeat<T> {
5556
Repeat { element: elt }
5657
}

library/core/src/mem/mod.rs

+6
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ pub use crate::intrinsics::transmute;
140140
#[inline]
141141
#[rustc_const_stable(feature = "const_forget", since = "1.46.0")]
142142
#[stable(feature = "rust1", since = "1.0.0")]
143+
#[cfg_attr(not(test), rustc_diagnostic_item = "mem_forget")]
143144
pub const fn forget<T>(t: T) {
144145
let _ = ManuallyDrop::new(t);
145146
}
@@ -298,6 +299,7 @@ pub fn forget_unsized<T: ?Sized>(t: T) {
298299
#[stable(feature = "rust1", since = "1.0.0")]
299300
#[rustc_promotable]
300301
#[rustc_const_stable(feature = "const_size_of", since = "1.24.0")]
302+
#[cfg_attr(not(test), rustc_diagnostic_item = "mem_size_of")]
301303
pub const fn size_of<T>() -> usize {
302304
intrinsics::size_of::<T>()
303305
}
@@ -324,6 +326,7 @@ pub const fn size_of<T>() -> usize {
324326
#[inline]
325327
#[stable(feature = "rust1", since = "1.0.0")]
326328
#[rustc_const_unstable(feature = "const_size_of_val", issue = "46571")]
329+
#[cfg_attr(not(test), rustc_diagnostic_item = "mem_size_of_val")]
327330
pub const fn size_of_val<T: ?Sized>(val: &T) -> usize {
328331
// SAFETY: `val` is a reference, so it's a valid raw pointer
329332
unsafe { intrinsics::size_of_val(val) }
@@ -814,6 +817,7 @@ pub fn take<T: Default>(dest: &mut T) -> T {
814817
#[stable(feature = "rust1", since = "1.0.0")]
815818
#[must_use = "if you don't need the old value, you can just assign the new value directly"]
816819
#[rustc_const_unstable(feature = "const_replace", issue = "83164")]
820+
#[cfg_attr(not(test), rustc_diagnostic_item = "mem_replace")]
817821
pub const fn replace<T>(dest: &mut T, src: T) -> T {
818822
// SAFETY: We read from `dest` but directly write `src` into it afterwards,
819823
// such that the old value is not duplicated. Nothing is dropped and
@@ -888,6 +892,7 @@ pub const fn replace<T>(dest: &mut T, src: T) -> T {
888892
/// [`RefCell`]: crate::cell::RefCell
889893
#[inline]
890894
#[stable(feature = "rust1", since = "1.0.0")]
895+
#[cfg_attr(not(test), rustc_diagnostic_item = "mem_drop")]
891896
pub fn drop<T>(_x: T) {}
892897

893898
/// Interprets `src` as having type `&U`, and then reads `src` without moving
@@ -1015,6 +1020,7 @@ impl<T> fmt::Debug for Discriminant<T> {
10151020
/// ```
10161021
#[stable(feature = "discriminant_value", since = "1.21.0")]
10171022
#[rustc_const_unstable(feature = "const_discriminant", issue = "69821")]
1023+
#[cfg_attr(not(test), rustc_diagnostic_item = "mem_discriminant")]
10181024
pub const fn discriminant<T>(v: &T) -> Discriminant<T> {
10191025
Discriminant(intrinsics::discriminant_value(v))
10201026
}

0 commit comments

Comments
 (0)