Skip to content

Commit c1cad70

Browse files
authored
Rollup merge of #73539 - LukasKalbertodt:deprecate-vec-remove-item, r=Mark-Simulacrum
Deprecate `Vec::remove_item` In #40062 we decided to remove that method. In #71834 it was said that we want to deprecate it for a few cycles before removing it. That's what this PR does.
2 parents 96b86ea + 1e6e082 commit c1cad70

File tree

8 files changed

+11
-31
lines changed

8 files changed

+11
-31
lines changed

src/liballoc/tests/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#![feature(associated_type_bounds)]
1313
#![feature(binary_heap_into_iter_sorted)]
1414
#![feature(binary_heap_drain_sorted)]
15-
#![feature(vec_remove_item)]
1615
#![feature(split_inclusive)]
1716
#![feature(binary_heap_retain)]
1817

src/liballoc/tests/vec.rs

-15
Original file line numberDiff line numberDiff line change
@@ -131,21 +131,6 @@ fn test_extend_ref() {
131131
assert_eq!(v, [1, 2, 3, 4, 5, 6, 7]);
132132
}
133133

134-
#[test]
135-
fn test_remove_item() {
136-
let mut v = vec![1, 2, 3];
137-
v.remove_item(&1);
138-
139-
assert_eq!(v.len(), 2);
140-
assert_eq!(v, [2, 3]);
141-
142-
let mut w = vec![1, 2, 3];
143-
w.remove_item(&4);
144-
145-
assert_eq!(w.len(), 3);
146-
w.remove_item(&4);
147-
}
148-
149134
#[test]
150135
fn test_slice_from_mut() {
151136
let mut values = vec![1, 2, 3, 4, 5];

src/liballoc/vec.rs

+8-10
Original file line numberDiff line numberDiff line change
@@ -1760,17 +1760,15 @@ impl<T: PartialEq> Vec<T> {
17601760
impl<T> Vec<T> {
17611761
/// Removes the first instance of `item` from the vector if the item exists.
17621762
///
1763-
/// # Examples
1764-
///
1765-
/// ```
1766-
/// # #![feature(vec_remove_item)]
1767-
/// let mut vec = vec![1, 2, 3, 1];
1768-
///
1769-
/// vec.remove_item(&1);
1770-
///
1771-
/// assert_eq!(vec, vec![2, 3, 1]);
1772-
/// ```
1763+
/// This method will be removed soon.
17731764
#[unstable(feature = "vec_remove_item", reason = "recently added", issue = "40062")]
1765+
#[rustc_deprecated(
1766+
reason = "Removing the first item equal to a needle is already easily possible \
1767+
with iterators and the current Vec methods. Furthermore, having a method for \
1768+
one particular case of removal (linear search, only the first item, no swap remove) \
1769+
but not for others is inconsistent. This method will be removed soon.",
1770+
since = "1.46.0"
1771+
)]
17741772
pub fn remove_item<V>(&mut self, item: &V) -> Option<T>
17751773
where
17761774
T: PartialEq<V>,

src/librustc_middle/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
#![feature(min_specialization)]
4646
#![feature(track_caller)]
4747
#![feature(trusted_len)]
48-
#![feature(vec_remove_item)]
4948
#![feature(stmt_expr_attributes)]
5049
#![feature(test)]
5150
#![feature(in_band_lifetimes)]

src/librustc_query_system/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
#![feature(hash_raw_entry)]
77
#![feature(min_specialization)]
88
#![feature(stmt_expr_attributes)]
9-
#![feature(vec_remove_item)]
109

1110
#[macro_use]
1211
extern crate log;

src/librustc_query_system/query/job.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,9 @@ fn remove_cycle<CTX: QueryContext>(
452452

453453
// Remove the queries in our cycle from the list of jobs to look at
454454
for r in &stack {
455-
jobs.remove_item(&r.1);
455+
if let Some(pos) = jobs.iter().position(|j| j == &r.1) {
456+
jobs.remove(pos);
457+
}
456458
}
457459

458460
// Find the queries in the cycle which are

src/librustdoc/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#![feature(nll)]
1010
#![feature(or_patterns)]
1111
#![feature(test)]
12-
#![feature(vec_remove_item)]
1312
#![feature(ptr_offset_from)]
1413
#![feature(crate_visibility_modifier)]
1514
#![feature(never_type)]

src/tools/compiletest/src/main.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#![crate_name = "compiletest"]
2-
#![feature(vec_remove_item)]
32
#![deny(warnings)]
43
// The `test` crate is the only unstable feature
54
// allowed here, just to share similar code.

0 commit comments

Comments
 (0)