Skip to content

Commit 717702d

Browse files
committed
Revert "core: add IntoFuture trait and support for await"
This reverts commit f35517e.
1 parent 119307a commit 717702d

File tree

10 files changed

+12
-90
lines changed

10 files changed

+12
-90
lines changed

src/libcore/future/future.rs

-25
Original file line numberDiff line numberDiff line change
@@ -99,21 +99,6 @@ pub trait Future {
9999
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output>;
100100
}
101101

102-
/// Conversion into a `Future`.
103-
#[unstable(feature = "into_future", issue = "67644")]
104-
pub trait IntoFuture {
105-
/// The output that the future will produce on completion.
106-
#[unstable(feature = "into_future", issue = "67644")]
107-
type Output;
108-
/// Which kind of future are we turning this into?
109-
#[unstable(feature = "into_future", issue = "67644")]
110-
type Future: Future<Output = Self::Output>;
111-
112-
/// Creates a future from a value.
113-
#[unstable(feature = "into_future", issue = "67644")]
114-
fn into_future(self) -> Self::Future;
115-
}
116-
117102
#[stable(feature = "futures_api", since = "1.36.0")]
118103
impl<F: ?Sized + Future + Unpin> Future for &mut F {
119104
type Output = F::Output;
@@ -134,13 +119,3 @@ where
134119
Pin::get_mut(self).as_mut().poll(cx)
135120
}
136121
}
137-
138-
#[unstable(feature = "into_future", issue = "67644")]
139-
impl<F: Future> IntoFuture for F {
140-
type Output = F::Output;
141-
type Future = F;
142-
143-
fn into_future(self) -> Self::Future {
144-
self
145-
}
146-
}

src/libcore/future/mod.rs

-3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,3 @@
55
mod future;
66
#[stable(feature = "futures_api", since = "1.36.0")]
77
pub use self::future::Future;
8-
9-
#[unstable(feature = "into_future", issue = "67644")]
10-
pub use self::future::IntoFuture;

src/librustc_ast_lowering/expr.rs

+4-20
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
517517

518518
/// Desugar `<expr>.await` into:
519519
/// ```rust
520-
/// match ::std::future::IntoFuture::into_future(<expr>) {
520+
/// match <expr> {
521521
/// mut pinned => loop {
522522
/// match ::std::future::poll_with_tls_context(unsafe {
523523
/// <::std::pin::Pin>::new_unchecked(&mut pinned)
@@ -641,27 +641,11 @@ impl<'hir> LoweringContext<'_, 'hir> {
641641
// mut pinned => loop { ... }
642642
let pinned_arm = self.arm(pinned_pat, loop_expr);
643643

644-
// `match ::std::future::IntoFuture::into_future(<expr>) { ... }`
645-
let into_future_span = self.mark_span_with_reason(
646-
DesugaringKind::Await,
647-
await_span,
648-
self.allow_into_future.clone(),
649-
);
650-
let expr = self.lower_expr_mut(expr);
651-
let into_future_expr = self.expr_call_std_path(
652-
into_future_span,
653-
&[sym::future, sym::IntoFuture, sym::into_future],
654-
arena_vec![self; expr],
655-
);
656-
657-
// match <into_future_expr> {
644+
// match <expr> {
658645
// mut pinned => loop { .. }
659646
// }
660-
hir::ExprKind::Match(
661-
into_future_expr,
662-
arena_vec![self; pinned_arm],
663-
hir::MatchSource::AwaitDesugar,
664-
)
647+
let expr = self.lower_expr(expr);
648+
hir::ExprKind::Match(expr, arena_vec![self; pinned_arm], hir::MatchSource::AwaitDesugar)
665649
}
666650

667651
fn lower_expr_closure(

src/librustc_ast_lowering/lib.rs

-2
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,6 @@ struct LoweringContext<'a, 'hir: 'a> {
167167

168168
allow_try_trait: Option<Lrc<[Symbol]>>,
169169
allow_gen_future: Option<Lrc<[Symbol]>>,
170-
allow_into_future: Option<Lrc<[Symbol]>>,
171170
}
172171

173172
pub trait Resolver {
@@ -300,7 +299,6 @@ pub fn lower_crate<'a, 'hir>(
300299
in_scope_lifetimes: Vec::new(),
301300
allow_try_trait: Some([sym::try_trait][..].into()),
302301
allow_gen_future: Some([sym::gen_future][..].into()),
303-
allow_into_future: Some([sym::into_future][..].into()),
304302
}
305303
.lower_crate(krate)
306304
}

src/librustc_span/symbol.rs

-2
Original file line numberDiff line numberDiff line change
@@ -379,8 +379,6 @@ symbols! {
379379
infer_static_outlives_requirements,
380380
inline,
381381
intel,
382-
into_future,
383-
IntoFuture,
384382
into_iter,
385383
IntoIterator,
386384
into_result,

src/libstd/future.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,7 @@ use core::task::{Context, Poll};
1010

1111
#[doc(inline)]
1212
#[stable(feature = "futures_api", since = "1.36.0")]
13-
pub use core::future::Future;
14-
15-
#[doc(inline)]
16-
#[unstable(feature = "into_future", issue = "67644")]
17-
pub use core::future::IntoFuture;
13+
pub use core::future::*;
1814

1915
/// Wrap a generator in a future.
2016
///

src/libstd/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,6 @@
269269
#![feature(hashmap_internals)]
270270
#![feature(int_error_internals)]
271271
#![feature(int_error_matching)]
272-
#![feature(into_future)]
273272
#![feature(integer_atomics)]
274273
#![feature(lang_items)]
275274
#![feature(libc)]

src/test/ui/async-await/async-fn-size-moved-locals.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ async fn mixed_sizes() {
112112
fn main() {
113113
assert_eq!(1028, std::mem::size_of_val(&single()));
114114
assert_eq!(1032, std::mem::size_of_val(&single_with_noop()));
115-
assert_eq!(3080, std::mem::size_of_val(&joined()));
116-
assert_eq!(3080, std::mem::size_of_val(&joined_with_noop()));
117-
assert_eq!(6164, std::mem::size_of_val(&mixed_sizes()));
115+
assert_eq!(3084, std::mem::size_of_val(&joined()));
116+
assert_eq!(3084, std::mem::size_of_val(&joined_with_noop()));
117+
assert_eq!(7188, std::mem::size_of_val(&mixed_sizes()));
118118
}

src/test/ui/async-await/await-into-future.rs

-28
This file was deleted.

src/test/ui/async-await/issues/issue-62009-1.stderr

+4-1
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,11 @@ error[E0277]: the trait bound `[closure@$DIR/issue-62009-1.rs:16:5: 16:15]: std:
3232
|
3333
LL | (|_| 2333).await;
3434
| ^^^^^^^^^^^^^^^^ the trait `std::future::Future` is not implemented for `[closure@$DIR/issue-62009-1.rs:16:5: 16:15]`
35+
|
36+
::: $SRC_DIR/libstd/future.rs:LL:COL
3537
|
36-
= note: required by `std::future::IntoFuture::into_future`
38+
LL | F: Future,
39+
| ------ required by this bound in `std::future::poll_with_tls_context`
3740

3841
error: aborting due to 4 previous errors
3942

0 commit comments

Comments
 (0)