Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Vec::remove_item as discussed in #40062 #71834

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/liballoc/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#![feature(associated_type_bounds)]
#![feature(binary_heap_into_iter_sorted)]
#![feature(binary_heap_drain_sorted)]
#![feature(vec_remove_item)]
#![feature(split_inclusive)]
#![feature(binary_heap_retain)]

Expand Down
15 changes: 0 additions & 15 deletions src/liballoc/tests/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,21 +131,6 @@ fn test_extend_ref() {
assert_eq!(v, [1, 2, 3, 4, 5, 6, 7]);
}

#[test]
fn test_remove_item() {
let mut v = vec![1, 2, 3];
v.remove_item(&1);

assert_eq!(v.len(), 2);
assert_eq!(v, [2, 3]);

let mut w = vec![1, 2, 3];
w.remove_item(&4);

assert_eq!(w.len(), 3);
w.remove_item(&4);
}

#[test]
fn test_slice_from_mut() {
let mut values = vec![1, 2, 3, 4, 5];
Expand Down
23 changes: 0 additions & 23 deletions src/liballoc/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1752,29 +1752,6 @@ impl<T: PartialEq> Vec<T> {
}
}

impl<T> Vec<T> {
/// Removes the first instance of `item` from the vector if the item exists.
///
/// # Examples
///
/// ```
/// # #![feature(vec_remove_item)]
/// let mut vec = vec![1, 2, 3, 1];
///
/// vec.remove_item(&1);
///
/// assert_eq!(vec, vec![2, 3, 1]);
/// ```
#[unstable(feature = "vec_remove_item", reason = "recently added", issue = "40062")]
pub fn remove_item<V>(&mut self, item: &V) -> Option<T>
where
T: PartialEq<V>,
{
let pos = self.iter().position(|x| *x == *item)?;
Some(self.remove(pos))
}
}

////////////////////////////////////////////////////////////////////////////////
// Internal methods and functions
////////////////////////////////////////////////////////////////////////////////
Expand Down
1 change: 0 additions & 1 deletion src/librustc_middle/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
#![feature(range_is_empty)]
#![feature(specialization)]
#![feature(trusted_len)]
#![feature(vec_remove_item)]
#![feature(stmt_expr_attributes)]
#![feature(test)]
#![feature(in_band_lifetimes)]
Expand Down
1 change: 0 additions & 1 deletion src/librustc_query_system/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#![feature(hash_raw_entry)]
#![feature(specialization)]
#![feature(stmt_expr_attributes)]
#![feature(vec_remove_item)]

#[macro_use]
extern crate log;
Expand Down
4 changes: 3 additions & 1 deletion src/librustc_query_system/query/job.rs
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,9 @@ fn remove_cycle<CTX: QueryContext>(

// Remove the queries in our cycle from the list of jobs to look at
for r in &stack {
jobs.remove_item(&r.1);
if let Some(pos) = jobs.iter().position(|j| j == &r.1) {
jobs.remove(pos);
}
LukasKalbertodt marked this conversation as resolved.
Show resolved Hide resolved
}

// Find the queries in the cycle which are
Expand Down
1 change: 0 additions & 1 deletion src/librustdoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#![feature(nll)]
#![feature(or_patterns)]
#![feature(test)]
#![feature(vec_remove_item)]
#![feature(ptr_offset_from)]
#![feature(crate_visibility_modifier)]
#![feature(never_type)]
Expand Down
1 change: 0 additions & 1 deletion src/tools/compiletest/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![crate_name = "compiletest"]
#![feature(vec_remove_item)]
#![deny(warnings)]
// The `test` crate is the only unstable feature
// allowed here, just to share similar code.
Expand Down