diff options
| author | Wesley Wiser <wwiser@gmail.com> | 2019-12-31 19:18:08 -0500 |
|---|---|---|
| committer | Wesley Wiser <wwiser@gmail.com> | 2019-12-31 19:18:08 -0500 |
| commit | 717702dffdf9ddb84e1fd35f189511a307e350e1 (patch) | |
| tree | c34014104d73e4a6b70fec7a76b9a0e7f37b125a | |
| parent | 119307a83e12291a3fc126735d6bd0292c443464 (diff) | |
| download | rust-717702dffdf9ddb84e1fd35f189511a307e350e1.tar.gz rust-717702dffdf9ddb84e1fd35f189511a307e350e1.zip | |
Revert "core: add IntoFuture trait and support for await"
This reverts commit f35517ee861dc012ccc26083dd4520045e2c4f6f.
| -rw-r--r-- | src/libcore/future/future.rs | 25 | ||||
| -rw-r--r-- | src/libcore/future/mod.rs | 3 | ||||
| -rw-r--r-- | src/librustc_ast_lowering/expr.rs | 24 | ||||
| -rw-r--r-- | src/librustc_ast_lowering/lib.rs | 2 | ||||
| -rw-r--r-- | src/librustc_span/symbol.rs | 2 | ||||
| -rw-r--r-- | src/libstd/future.rs | 6 | ||||
| -rw-r--r-- | src/libstd/lib.rs | 1 | ||||
| -rw-r--r-- | src/test/ui/async-await/async-fn-size-moved-locals.rs | 6 | ||||
| -rw-r--r-- | src/test/ui/async-await/await-into-future.rs | 28 | ||||
| -rw-r--r-- | src/test/ui/async-await/issues/issue-62009-1.stderr | 5 |
10 files changed, 12 insertions, 90 deletions
diff --git a/src/libcore/future/future.rs b/src/libcore/future/future.rs index dcb819f9381..f14ed38b9b0 100644 --- a/src/libcore/future/future.rs +++ b/src/libcore/future/future.rs @@ -99,21 +99,6 @@ pub trait Future { fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output>; } -/// Conversion into a `Future`. -#[unstable(feature = "into_future", issue = "67644")] -pub trait IntoFuture { - /// The output that the future will produce on completion. - #[unstable(feature = "into_future", issue = "67644")] - type Output; - /// Which kind of future are we turning this into? - #[unstable(feature = "into_future", issue = "67644")] - type Future: Future<Output = Self::Output>; - - /// Creates a future from a value. - #[unstable(feature = "into_future", issue = "67644")] - fn into_future(self) -> Self::Future; -} - #[stable(feature = "futures_api", since = "1.36.0")] impl<F: ?Sized + Future + Unpin> Future for &mut F { type Output = F::Output; @@ -134,13 +119,3 @@ where Pin::get_mut(self).as_mut().poll(cx) } } - -#[unstable(feature = "into_future", issue = "67644")] -impl<F: Future> IntoFuture for F { - type Output = F::Output; - type Future = F; - - fn into_future(self) -> Self::Future { - self - } -} diff --git a/src/libcore/future/mod.rs b/src/libcore/future/mod.rs index aecd57b9ce7..89ea4713cfd 100644 --- a/src/libcore/future/mod.rs +++ b/src/libcore/future/mod.rs @@ -5,6 +5,3 @@ mod future; #[stable(feature = "futures_api", since = "1.36.0")] pub use self::future::Future; - -#[unstable(feature = "into_future", issue = "67644")] -pub use self::future::IntoFuture; diff --git a/src/librustc_ast_lowering/expr.rs b/src/librustc_ast_lowering/expr.rs index a3e2bc04bd5..591e869193d 100644 --- a/src/librustc_ast_lowering/expr.rs +++ b/src/librustc_ast_lowering/expr.rs @@ -517,7 +517,7 @@ impl<'hir> LoweringContext<'_, 'hir> { /// Desugar `<expr>.await` into: /// ```rust - /// match ::std::future::IntoFuture::into_future(<expr>) { + /// match <expr> { /// mut pinned => loop { /// match ::std::future::poll_with_tls_context(unsafe { /// <::std::pin::Pin>::new_unchecked(&mut pinned) @@ -641,27 +641,11 @@ impl<'hir> LoweringContext<'_, 'hir> { // mut pinned => loop { ... } let pinned_arm = self.arm(pinned_pat, loop_expr); - // `match ::std::future::IntoFuture::into_future(<expr>) { ... }` - let into_future_span = self.mark_span_with_reason( - DesugaringKind::Await, - await_span, - self.allow_into_future.clone(), - ); - let expr = self.lower_expr_mut(expr); - let into_future_expr = self.expr_call_std_path( - into_future_span, - &[sym::future, sym::IntoFuture, sym::into_future], - arena_vec![self; expr], - ); - - // match <into_future_expr> { + // match <expr> { // mut pinned => loop { .. } // } - hir::ExprKind::Match( - into_future_expr, - arena_vec![self; pinned_arm], - hir::MatchSource::AwaitDesugar, - ) + let expr = self.lower_expr(expr); + hir::ExprKind::Match(expr, arena_vec![self; pinned_arm], hir::MatchSource::AwaitDesugar) } fn lower_expr_closure( diff --git a/src/librustc_ast_lowering/lib.rs b/src/librustc_ast_lowering/lib.rs index a9214f31e7d..3b06a6969ac 100644 --- a/src/librustc_ast_lowering/lib.rs +++ b/src/librustc_ast_lowering/lib.rs @@ -167,7 +167,6 @@ struct LoweringContext<'a, 'hir: 'a> { allow_try_trait: Option<Lrc<[Symbol]>>, allow_gen_future: Option<Lrc<[Symbol]>>, - allow_into_future: Option<Lrc<[Symbol]>>, } pub trait Resolver { @@ -300,7 +299,6 @@ pub fn lower_crate<'a, 'hir>( in_scope_lifetimes: Vec::new(), allow_try_trait: Some([sym::try_trait][..].into()), allow_gen_future: Some([sym::gen_future][..].into()), - allow_into_future: Some([sym::into_future][..].into()), } .lower_crate(krate) } diff --git a/src/librustc_span/symbol.rs b/src/librustc_span/symbol.rs index 7ae037faf15..8fdc199d9ed 100644 --- a/src/librustc_span/symbol.rs +++ b/src/librustc_span/symbol.rs @@ -379,8 +379,6 @@ symbols! { infer_static_outlives_requirements, inline, intel, - into_future, - IntoFuture, into_iter, IntoIterator, into_result, diff --git a/src/libstd/future.rs b/src/libstd/future.rs index 908736c6393..9c7422c2b20 100644 --- a/src/libstd/future.rs +++ b/src/libstd/future.rs @@ -10,11 +10,7 @@ use core::task::{Context, Poll}; #[doc(inline)] #[stable(feature = "futures_api", since = "1.36.0")] -pub use core::future::Future; - -#[doc(inline)] -#[unstable(feature = "into_future", issue = "67644")] -pub use core::future::IntoFuture; +pub use core::future::*; /// Wrap a generator in a future. /// diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 930bf397bc4..4b15c9ba4f3 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -269,7 +269,6 @@ #![feature(hashmap_internals)] #![feature(int_error_internals)] #![feature(int_error_matching)] -#![feature(into_future)] #![feature(integer_atomics)] #![feature(lang_items)] #![feature(libc)] diff --git a/src/test/ui/async-await/async-fn-size-moved-locals.rs b/src/test/ui/async-await/async-fn-size-moved-locals.rs index f2469de7394..4a413381aa3 100644 --- a/src/test/ui/async-await/async-fn-size-moved-locals.rs +++ b/src/test/ui/async-await/async-fn-size-moved-locals.rs @@ -112,7 +112,7 @@ async fn mixed_sizes() { fn main() { assert_eq!(1028, std::mem::size_of_val(&single())); assert_eq!(1032, std::mem::size_of_val(&single_with_noop())); - assert_eq!(3080, std::mem::size_of_val(&joined())); - assert_eq!(3080, std::mem::size_of_val(&joined_with_noop())); - assert_eq!(6164, std::mem::size_of_val(&mixed_sizes())); + assert_eq!(3084, std::mem::size_of_val(&joined())); + assert_eq!(3084, std::mem::size_of_val(&joined_with_noop())); + assert_eq!(7188, std::mem::size_of_val(&mixed_sizes())); } diff --git a/src/test/ui/async-await/await-into-future.rs b/src/test/ui/async-await/await-into-future.rs deleted file mode 100644 index d5ff0eb3049..00000000000 --- a/src/test/ui/async-await/await-into-future.rs +++ /dev/null @@ -1,28 +0,0 @@ -// check-pass - -// edition:2018 - -#![feature(into_future)] - -use std::{future::{Future, IntoFuture}, pin::Pin}; - -struct AwaitMe; - -impl IntoFuture for AwaitMe { - type Output = i32; - type Future = Pin<Box<dyn Future<Output = i32>>>; - - fn into_future(self) -> Self::Future { - Box::pin(me()) - } -} - -async fn me() -> i32 { - 41 -} - -async fn run() { - assert_eq!(AwaitMe.await, 41); -} - -fn main() {} diff --git a/src/test/ui/async-await/issues/issue-62009-1.stderr b/src/test/ui/async-await/issues/issue-62009-1.stderr index 85e133912d3..cd6670923c2 100644 --- a/src/test/ui/async-await/issues/issue-62009-1.stderr +++ b/src/test/ui/async-await/issues/issue-62009-1.stderr @@ -32,8 +32,11 @@ error[E0277]: the trait bound `[closure@$DIR/issue-62009-1.rs:16:5: 16:15]: std: | LL | (|_| 2333).await; | ^^^^^^^^^^^^^^^^ the trait `std::future::Future` is not implemented for `[closure@$DIR/issue-62009-1.rs:16:5: 16:15]` + | + ::: $SRC_DIR/libstd/future.rs:LL:COL | - = note: required by `std::future::IntoFuture::into_future` +LL | F: Future, + | ------ required by this bound in `std::future::poll_with_tls_context` error: aborting due to 4 previous errors |
