From 5007e115d4da80ea247c79225bce46d427faf9ce Mon Sep 17 00:00:00 2001 From: Lukas Kalbertodt Date: Sun, 3 May 2020 12:41:24 +0200 Subject: [PATCH] Remove `Vec::remove_item` as discussed in #40062 --- src/liballoc/tests/lib.rs | 1 - src/liballoc/tests/vec.rs | 15 --------------- src/liballoc/vec.rs | 23 ----------------------- src/librustc_middle/lib.rs | 1 - src/librustc_query_system/lib.rs | 1 - src/librustc_query_system/query/job.rs | 4 +++- src/librustdoc/lib.rs | 1 - src/tools/compiletest/src/main.rs | 1 - 8 files changed, 3 insertions(+), 44 deletions(-) diff --git a/src/liballoc/tests/lib.rs b/src/liballoc/tests/lib.rs index 78d49558262e3..1d5bb0759a0aa 100644 --- a/src/liballoc/tests/lib.rs +++ b/src/liballoc/tests/lib.rs @@ -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)] diff --git a/src/liballoc/tests/vec.rs b/src/liballoc/tests/vec.rs index 3d76324f7e880..78aa41d24a717 100644 --- a/src/liballoc/tests/vec.rs +++ b/src/liballoc/tests/vec.rs @@ -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]; diff --git a/src/liballoc/vec.rs b/src/liballoc/vec.rs index cbfbf4d1cd32d..d279a7dc11285 100644 --- a/src/liballoc/vec.rs +++ b/src/liballoc/vec.rs @@ -1752,29 +1752,6 @@ impl Vec { } } -impl Vec { - /// 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(&mut self, item: &V) -> Option - where - T: PartialEq, - { - let pos = self.iter().position(|x| *x == *item)?; - Some(self.remove(pos)) - } -} - //////////////////////////////////////////////////////////////////////////////// // Internal methods and functions //////////////////////////////////////////////////////////////////////////////// diff --git a/src/librustc_middle/lib.rs b/src/librustc_middle/lib.rs index 9b38b43c93ae2..36ab9dd19a93f 100644 --- a/src/librustc_middle/lib.rs +++ b/src/librustc_middle/lib.rs @@ -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)] diff --git a/src/librustc_query_system/lib.rs b/src/librustc_query_system/lib.rs index 0e6a07e06d0f2..8203115872536 100644 --- a/src/librustc_query_system/lib.rs +++ b/src/librustc_query_system/lib.rs @@ -6,7 +6,6 @@ #![feature(hash_raw_entry)] #![feature(specialization)] #![feature(stmt_expr_attributes)] -#![feature(vec_remove_item)] #[macro_use] extern crate log; diff --git a/src/librustc_query_system/query/job.rs b/src/librustc_query_system/query/job.rs index 5150b278a7722..190312bb33001 100644 --- a/src/librustc_query_system/query/job.rs +++ b/src/librustc_query_system/query/job.rs @@ -452,7 +452,9 @@ fn remove_cycle( // 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); + } } // Find the queries in the cycle which are diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index 5fb7b7bf959cf..c725d3805887e 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -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)] diff --git a/src/tools/compiletest/src/main.rs b/src/tools/compiletest/src/main.rs index 3a8a5491255a0..2a7f413ad8eab 100644 --- a/src/tools/compiletest/src/main.rs +++ b/src/tools/compiletest/src/main.rs @@ -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.