From 23b9f46fff4453fb90611c2fb554e004f1cec096 Mon Sep 17 00:00:00 2001 From: Philipp Hansch Date: Wed, 22 Apr 2020 07:47:31 +0200 Subject: [PATCH] More diagnostic items for Clippy usage This adds a couple of more diagnostic items to be used in Clippy. I chose these particular ones because they were the types which we seem to check for the most in Clippy. I'm not sure if the `cfg_attr(not(test))` is needed, but it was also used for `Vec` and a few other types. --- src/liballoc/collections/vec_deque.rs | 1 + src/liballoc/string.rs | 1 + src/libstd/collections/hash/map.rs | 1 + src/libstd/collections/hash/set.rs | 1 + src/libstd/sync/mutex.rs | 1 + 5 files changed, 5 insertions(+) diff --git a/src/liballoc/collections/vec_deque.rs b/src/liballoc/collections/vec_deque.rs index 091b068b0b2..a3b61f1f4a5 100644 --- a/src/liballoc/collections/vec_deque.rs +++ b/src/liballoc/collections/vec_deque.rs @@ -50,6 +50,7 @@ const MAXIMUM_ZST_CAPACITY: usize = 1 << (64 - 1); // Largest possible power of /// [`pop_front`]: #method.pop_front /// [`extend`]: #method.extend /// [`append`]: #method.append +#[cfg_attr(not(test), rustc_diagnostic_item = "vecdeque_type")] #[stable(feature = "rust1", since = "1.0.0")] pub struct VecDeque { // tail and head are pointers into the buffer. Tail always points diff --git a/src/liballoc/string.rs b/src/liballoc/string.rs index 80fa8139915..f3fe1adebb1 100644 --- a/src/liballoc/string.rs +++ b/src/liballoc/string.rs @@ -278,6 +278,7 @@ use crate::vec::Vec; /// [`Deref`]: ../../std/ops/trait.Deref.html /// [`as_str()`]: struct.String.html#method.as_str #[derive(PartialOrd, Eq, Ord)] +#[cfg_attr(not(test), rustc_diagnostic_item = "string_type")] #[stable(feature = "rust1", since = "1.0.0")] pub struct String { vec: Vec, diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index 706b388f783..e6da7426eb4 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -198,6 +198,7 @@ use crate::sys; /// ``` #[derive(Clone)] +#[cfg_attr(not(test), rustc_diagnostic_item = "hashmap_type")] #[stable(feature = "rust1", since = "1.0.0")] pub struct HashMap { base: base::HashMap, diff --git a/src/libstd/collections/hash/set.rs b/src/libstd/collections/hash/set.rs index 1ad99f03703..c1a57f2ce61 100644 --- a/src/libstd/collections/hash/set.rs +++ b/src/libstd/collections/hash/set.rs @@ -105,6 +105,7 @@ use super::map::{self, HashMap, Keys, RandomState}; /// [`PartialEq`]: ../../std/cmp/trait.PartialEq.html /// [`RefCell`]: ../../std/cell/struct.RefCell.html #[derive(Clone)] +#[cfg_attr(not(test), rustc_diagnostic_item = "hashset_type")] #[stable(feature = "rust1", since = "1.0.0")] pub struct HashSet { map: HashMap, diff --git a/src/libstd/sync/mutex.rs b/src/libstd/sync/mutex.rs index 0cb16b19d73..797b22fdd12 100644 --- a/src/libstd/sync/mutex.rs +++ b/src/libstd/sync/mutex.rs @@ -108,6 +108,7 @@ use crate::sys_common::poison::{self, LockResult, TryLockError, TryLockResult}; /// *guard += 1; /// ``` #[stable(feature = "rust1", since = "1.0.0")] +#[cfg_attr(not(test), rustc_diagnostic_item = "mutex_type")] pub struct Mutex { // Note that this mutex is in a *box*, not inlined into the struct itself. // Once a native mutex has been used once, its address can never change (it