about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2019-06-22 06:59:27 +0200
committerMazdak Farrokhzad <twingoow@gmail.com>2019-06-22 06:59:27 +0200
commita99a7b7f35e3b30862058cc28ed4b0cf51638cf4 (patch)
treebf1a2ed3f3e3719a86cb8a75251f9d618631e982
parent8d6f4b96df0a837036fa0f58541cd32c6c56a463 (diff)
downloadrust-a99a7b7f35e3b30862058cc28ed4b0cf51638cf4.tar.gz
rust-a99a7b7f35e3b30862058cc28ed4b0cf51638cf4.zip
Remove FnBox.
-rw-r--r--src/doc/unstable-book/src/language-features/unsized-locals.md4
-rw-r--r--src/doc/unstable-book/src/library-features/fnbox.md32
-rw-r--r--src/liballoc/boxed.rs79
-rw-r--r--src/libstd/lib.rs1
-rw-r--r--src/test/run-pass/unsized-locals/fnbox-compat.rs13
5 files changed, 1 insertions, 128 deletions
diff --git a/src/doc/unstable-book/src/language-features/unsized-locals.md b/src/doc/unstable-book/src/language-features/unsized-locals.md
index edc039f896b..343084b7db5 100644
--- a/src/doc/unstable-book/src/language-features/unsized-locals.md
+++ b/src/doc/unstable-book/src/language-features/unsized-locals.md
@@ -117,9 +117,7 @@ fn main () {
 }
 ```
 
-One of the objectives of this feature is to allow `Box<dyn FnOnce>`, instead of `Box<dyn FnBox>` in the future. See [#28796] for details.
-
-[#28796]: https://github.com/rust-lang/rust/issues/28796
+One of the objectives of this feature is to allow `Box<dyn FnOnce>`.
 
 ## Variable length arrays
 
diff --git a/src/doc/unstable-book/src/library-features/fnbox.md b/src/doc/unstable-book/src/library-features/fnbox.md
deleted file mode 100644
index 97e32cc0acb..00000000000
--- a/src/doc/unstable-book/src/library-features/fnbox.md
+++ /dev/null
@@ -1,32 +0,0 @@
-# `fnbox`
-
-The tracking issue for this feature is [#28796]
-
-[#28796]: https://github.com/rust-lang/rust/issues/28796
-
-------------------------
-
-This had been a temporary alternative to the following impls:
-
-```rust,ignore
-impl<A, F> FnOnce for Box<F> where F: FnOnce<A> + ?Sized {}
-impl<A, F> FnMut for Box<F> where F: FnMut<A> + ?Sized {}
-impl<A, F> Fn for Box<F> where F: Fn<A> + ?Sized {}
-```
-
-The impls are parallel to these (relatively old) impls:
-
-```rust,ignore
-impl<A, F> FnOnce for &mut F where F: FnMut<A> + ?Sized {}
-impl<A, F> FnMut for &mut F where F: FnMut<A> + ?Sized {}
-impl<A, F> Fn for &mut F where F: Fn<A> + ?Sized {}
-impl<A, F> FnOnce for &F where F: Fn<A> + ?Sized {}
-impl<A, F> FnMut for &F where F: Fn<A> + ?Sized {}
-impl<A, F> Fn for &F where F: Fn<A> + ?Sized {}
-```
-
-Before the introduction of [`unsized_locals`][unsized_locals], we had been unable to provide the former impls. That means, unlike `&dyn Fn()` or `&mut dyn FnMut()` we could not use `Box<dyn FnOnce()>` at that time.
-
-[unsized_locals]: ../language-features/unsized-locals.md
-
-`FnBox()` is an alternative approach to `Box<dyn FnBox()>` is delegated to `FnBox::call_box` which doesn't need unsized locals. As we now have `Box<dyn FnOnce()>` working, the `fnbox` feature is going to be removed.
diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs
index 76b660fba68..9109a730cce 100644
--- a/src/liballoc/boxed.rs
+++ b/src/liballoc/boxed.rs
@@ -761,85 +761,6 @@ impl<A, F: Fn<A> + ?Sized> Fn<A> for Box<F> {
     }
 }
 
-/// `FnBox` is deprecated and will be removed.
-/// `Box<dyn FnOnce()>` can be called directly, since Rust 1.35.0.
-///
-/// `FnBox` is a version of the `FnOnce` intended for use with boxed
-/// closure objects. The idea was that where one would normally store a
-/// `Box<dyn FnOnce()>` in a data structure, you whould use
-/// `Box<dyn FnBox()>`. The two traits behave essentially the same, except
-/// that a `FnBox` closure can only be called if it is boxed.
-///
-/// # Examples
-///
-/// Here is a snippet of code which creates a hashmap full of boxed
-/// once closures and then removes them one by one, calling each
-/// closure as it is removed. Note that the type of the closures
-/// stored in the map is `Box<dyn FnBox() -> i32>` and not `Box<dyn FnOnce()
-/// -> i32>`.
-///
-/// ```
-/// #![feature(fnbox)]
-/// #![allow(deprecated)]
-///
-/// use std::boxed::FnBox;
-/// use std::collections::HashMap;
-///
-/// fn make_map() -> HashMap<i32, Box<dyn FnBox() -> i32>> {
-///     let mut map: HashMap<i32, Box<dyn FnBox() -> i32>> = HashMap::new();
-///     map.insert(1, Box::new(|| 22));
-///     map.insert(2, Box::new(|| 44));
-///     map
-/// }
-///
-/// fn main() {
-///     let mut map = make_map();
-///     for i in &[1, 2] {
-///         let f = map.remove(&i).unwrap();
-///         assert_eq!(f(), i * 22);
-///     }
-/// }
-/// ```
-///
-/// In Rust 1.35.0 or later, use `FnOnce`, `FnMut`, or `Fn` instead:
-///
-/// ```
-/// use std::collections::HashMap;
-///
-/// fn make_map() -> HashMap<i32, Box<dyn FnOnce() -> i32>> {
-///     let mut map: HashMap<i32, Box<dyn FnOnce() -> i32>> = HashMap::new();
-///     map.insert(1, Box::new(|| 22));
-///     map.insert(2, Box::new(|| 44));
-///     map
-/// }
-///
-/// fn main() {
-///     let mut map = make_map();
-///     for i in &[1, 2] {
-///         let f = map.remove(&i).unwrap();
-///         assert_eq!(f(), i * 22);
-///     }
-/// }
-/// ```
-#[rustc_paren_sugar]
-#[unstable(feature = "fnbox", issue = "28796")]
-#[rustc_deprecated(reason = "use `FnOnce`, `FnMut`, or `Fn` instead", since = "1.37.0")]
-pub trait FnBox<A>: FnOnce<A> {
-    /// Performs the call operation.
-    fn call_box(self: Box<Self>, args: A) -> Self::Output;
-}
-
-#[unstable(feature = "fnbox", issue = "28796")]
-#[rustc_deprecated(reason = "use `FnOnce`, `FnMut`, or `Fn` instead", since = "1.37.0")]
-#[allow(deprecated, deprecated_in_future)]
-impl<A, F> FnBox<A> for F
-    where F: FnOnce<A>
-{
-    fn call_box(self: Box<F>, args: A) -> F::Output {
-        self.call_once(args)
-    }
-}
-
 #[unstable(feature = "coerce_unsized", issue = "27732")]
 impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<Box<U>> for Box<T> {}
 
diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs
index e0ffc9ba92f..60e06139eba 100644
--- a/src/libstd/lib.rs
+++ b/src/libstd/lib.rs
@@ -262,7 +262,6 @@
 #![feature(exhaustive_patterns)]
 #![feature(external_doc)]
 #![feature(fn_traits)]
-#![feature(fnbox)]
 #![feature(generator_trait)]
 #![feature(hash_raw_entry)]
 #![feature(hashmap_internals)]
diff --git a/src/test/run-pass/unsized-locals/fnbox-compat.rs b/src/test/run-pass/unsized-locals/fnbox-compat.rs
deleted file mode 100644
index 74a4dd5d851..00000000000
--- a/src/test/run-pass/unsized-locals/fnbox-compat.rs
+++ /dev/null
@@ -1,13 +0,0 @@
-#![feature(fnbox)]
-#![allow(deprecated, deprecated_in_future)]
-
-use std::boxed::FnBox;
-
-fn call_it<T>(f: Box<dyn FnBox() -> T>) -> T {
-    f()
-}
-
-fn main() {
-    let s = "hello".to_owned();
-    assert_eq!(&call_it(Box::new(|| s)) as &str, "hello");
-}