about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2025-01-28 18:17:26 +0100
committerGitHub <noreply@github.com>2025-01-28 18:17:26 +0100
commitd43e78d6eaede16edc5cd398c102021903507d38 (patch)
tree14a0d843059f9b161b7763d2c1c98b94b1ed48e1
parent9f22f358767d87146f956d77f4434ebe76ef751d (diff)
parent2117afdef8a3dfd82c6a3dd4d974a2213c2aeb1f (diff)
Rollup merge of #136071 - wowinter13:clippy-add-diagnostic-items, r=flip1995
[Clippy] Add vec_reserve & vecdeque_reserve diagnostic items

I’m currently working on reviving this lint (https://github.com/rust-lang/rust-clippy/pull/10157), and there was [a comment](https://github.com/rust-lang/rust-clippy/pull/10157#discussion_r1091591057) from ``@flip1995`` regarding the necessity of adding new diagnostic items.
-rw-r--r--compiler/rustc_span/src/symbol.rs2
-rw-r--r--library/alloc/src/collections/vec_deque/mod.rs1
-rw-r--r--library/alloc/src/vec/mod.rs1
3 files changed, 4 insertions, 0 deletions
diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs
index 1fb15fe9800..6f1d3a74a81 100644
--- a/compiler/rustc_span/src/symbol.rs
+++ b/compiler/rustc_span/src/symbol.rs
@@ -2184,8 +2184,10 @@ symbols! {
         vec_macro,
         vec_new,
         vec_pop,
+        vec_reserve,
         vec_with_capacity,
         vecdeque_iter,
+        vecdeque_reserve,
         vector,
         version,
         vfp2,
diff --git a/library/alloc/src/collections/vec_deque/mod.rs b/library/alloc/src/collections/vec_deque/mod.rs
index 1c33f8f60d8..299c8b8679e 100644
--- a/library/alloc/src/collections/vec_deque/mod.rs
+++ b/library/alloc/src/collections/vec_deque/mod.rs
@@ -823,6 +823,7 @@ impl<T, A: Allocator> VecDeque<T, A> {
     /// assert!(buf.capacity() >= 11);
     /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
+    #[cfg_attr(not(test), rustc_diagnostic_item = "vecdeque_reserve")]
     #[track_caller]
     pub fn reserve(&mut self, additional: usize) {
         let new_cap = self.len.checked_add(additional).expect("capacity overflow");
diff --git a/library/alloc/src/vec/mod.rs b/library/alloc/src/vec/mod.rs
index 54673ceb1da..48afcf6e064 100644
--- a/library/alloc/src/vec/mod.rs
+++ b/library/alloc/src/vec/mod.rs
@@ -1267,6 +1267,7 @@ impl<T, A: Allocator> Vec<T, A> {
     #[cfg(not(no_global_oom_handling))]
     #[stable(feature = "rust1", since = "1.0.0")]
     #[track_caller]
+    #[cfg_attr(not(test), rustc_diagnostic_item = "vec_reserve")]
     pub fn reserve(&mut self, additional: usize) {
         self.buf.reserve(self.len, additional);
     }