Skip to content

Commit 9566376

Browse files
authored
Rollup merge of rust-lang#62043 - Centril:remove-fnbox, r=cramertj
Remove `FnBox` Remove `FnBox` since we now have `Box<dyn FnOnce>`. Closes rust-lang#28796. r? @cramertj
2 parents d5f36b8 + a99a7b7 commit 9566376

File tree

5 files changed

+1
-128
lines changed

5 files changed

+1
-128
lines changed

src/doc/unstable-book/src/language-features/unsized-locals.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,7 @@ fn main () {
117117
}
118118
```
119119

120-
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.
121-
122-
[#28796]: https://github.com/rust-lang/rust/issues/28796
120+
One of the objectives of this feature is to allow `Box<dyn FnOnce>`.
123121

124122
## Variable length arrays
125123

src/doc/unstable-book/src/library-features/fnbox.md

-32
This file was deleted.

src/liballoc/boxed.rs

-79
Original file line numberDiff line numberDiff line change
@@ -761,85 +761,6 @@ impl<A, F: Fn<A> + ?Sized> Fn<A> for Box<F> {
761761
}
762762
}
763763

764-
/// `FnBox` is deprecated and will be removed.
765-
/// `Box<dyn FnOnce()>` can be called directly, since Rust 1.35.0.
766-
///
767-
/// `FnBox` is a version of the `FnOnce` intended for use with boxed
768-
/// closure objects. The idea was that where one would normally store a
769-
/// `Box<dyn FnOnce()>` in a data structure, you whould use
770-
/// `Box<dyn FnBox()>`. The two traits behave essentially the same, except
771-
/// that a `FnBox` closure can only be called if it is boxed.
772-
///
773-
/// # Examples
774-
///
775-
/// Here is a snippet of code which creates a hashmap full of boxed
776-
/// once closures and then removes them one by one, calling each
777-
/// closure as it is removed. Note that the type of the closures
778-
/// stored in the map is `Box<dyn FnBox() -> i32>` and not `Box<dyn FnOnce()
779-
/// -> i32>`.
780-
///
781-
/// ```
782-
/// #![feature(fnbox)]
783-
/// #![allow(deprecated)]
784-
///
785-
/// use std::boxed::FnBox;
786-
/// use std::collections::HashMap;
787-
///
788-
/// fn make_map() -> HashMap<i32, Box<dyn FnBox() -> i32>> {
789-
/// let mut map: HashMap<i32, Box<dyn FnBox() -> i32>> = HashMap::new();
790-
/// map.insert(1, Box::new(|| 22));
791-
/// map.insert(2, Box::new(|| 44));
792-
/// map
793-
/// }
794-
///
795-
/// fn main() {
796-
/// let mut map = make_map();
797-
/// for i in &[1, 2] {
798-
/// let f = map.remove(&i).unwrap();
799-
/// assert_eq!(f(), i * 22);
800-
/// }
801-
/// }
802-
/// ```
803-
///
804-
/// In Rust 1.35.0 or later, use `FnOnce`, `FnMut`, or `Fn` instead:
805-
///
806-
/// ```
807-
/// use std::collections::HashMap;
808-
///
809-
/// fn make_map() -> HashMap<i32, Box<dyn FnOnce() -> i32>> {
810-
/// let mut map: HashMap<i32, Box<dyn FnOnce() -> i32>> = HashMap::new();
811-
/// map.insert(1, Box::new(|| 22));
812-
/// map.insert(2, Box::new(|| 44));
813-
/// map
814-
/// }
815-
///
816-
/// fn main() {
817-
/// let mut map = make_map();
818-
/// for i in &[1, 2] {
819-
/// let f = map.remove(&i).unwrap();
820-
/// assert_eq!(f(), i * 22);
821-
/// }
822-
/// }
823-
/// ```
824-
#[rustc_paren_sugar]
825-
#[unstable(feature = "fnbox", issue = "28796")]
826-
#[rustc_deprecated(reason = "use `FnOnce`, `FnMut`, or `Fn` instead", since = "1.37.0")]
827-
pub trait FnBox<A>: FnOnce<A> {
828-
/// Performs the call operation.
829-
fn call_box(self: Box<Self>, args: A) -> Self::Output;
830-
}
831-
832-
#[unstable(feature = "fnbox", issue = "28796")]
833-
#[rustc_deprecated(reason = "use `FnOnce`, `FnMut`, or `Fn` instead", since = "1.37.0")]
834-
#[allow(deprecated, deprecated_in_future)]
835-
impl<A, F> FnBox<A> for F
836-
where F: FnOnce<A>
837-
{
838-
fn call_box(self: Box<F>, args: A) -> F::Output {
839-
self.call_once(args)
840-
}
841-
}
842-
843764
#[unstable(feature = "coerce_unsized", issue = "27732")]
844765
impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<Box<U>> for Box<T> {}
845766

src/libstd/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,6 @@
262262
#![feature(exhaustive_patterns)]
263263
#![feature(external_doc)]
264264
#![feature(fn_traits)]
265-
#![feature(fnbox)]
266265
#![feature(generator_trait)]
267266
#![feature(hash_raw_entry)]
268267
#![feature(hashmap_internals)]

src/test/run-pass/unsized-locals/fnbox-compat.rs

-13
This file was deleted.

0 commit comments

Comments
 (0)