Skip to content

Commit 43ed205

Browse files
authored
Rollup merge of #105250 - Swatinem:async-rm-resumety, r=oli-obk
Replace usage of `ResumeTy` in async lowering with `Context` Replaces using `ResumeTy` / `get_context` in favor of using `&'static mut Context<'_>`. Usage of the `'static` lifetime here is technically "cheating", and replaces the raw pointer in `ResumeTy` and the `get_context` fn that pulls the correct lifetimes out of thin air. fixes rust-lang/rust#104828 and rust-lang/rust#104321 (comment) r? `@oli-obk`
2 parents 1c6d709 + 26b342b commit 43ed205

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

core/src/future/mod.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ pub use poll_fn::{poll_fn, PollFn};
4444
/// non-Send/Sync as well, and we don't want that.
4545
///
4646
/// It also simplifies the HIR lowering of `.await`.
47-
#[cfg_attr(not(bootstrap), lang = "ResumeTy")]
47+
// FIXME(swatinem): This type can be removed when bumping the bootstrap compiler
4848
#[doc(hidden)]
4949
#[unstable(feature = "gen_future", issue = "50547")]
5050
#[derive(Debug, Copy, Clone)]
@@ -61,6 +61,7 @@ unsafe impl Sync for ResumeTy {}
6161
/// This function returns a `GenFuture` underneath, but hides it in `impl Trait` to give
6262
/// better error messages (`impl Future` rather than `GenFuture<[closure.....]>`).
6363
// This is `const` to avoid extra errors after we recover from `const async fn`
64+
// FIXME(swatinem): This fn can be removed when bumping the bootstrap compiler
6465
#[cfg_attr(bootstrap, lang = "from_generator")]
6566
#[doc(hidden)]
6667
#[unstable(feature = "gen_future", issue = "50547")]
@@ -102,7 +103,8 @@ where
102103
GenFuture(gen)
103104
}
104105

105-
#[lang = "get_context"]
106+
// FIXME(swatinem): This fn can be removed when bumping the bootstrap compiler
107+
#[cfg_attr(bootstrap, lang = "get_context")]
106108
#[doc(hidden)]
107109
#[unstable(feature = "gen_future", issue = "50547")]
108110
#[must_use]
@@ -113,6 +115,10 @@ pub unsafe fn get_context<'a, 'b>(cx: ResumeTy) -> &'a mut Context<'b> {
113115
unsafe { &mut *cx.0.as_ptr().cast() }
114116
}
115117

118+
// FIXME(swatinem): This fn is currently needed to work around shortcomings
119+
// in type and lifetime inference.
120+
// See the comment at the bottom of `LoweringContext::make_async_expr` and
121+
// <https://github.com/rust-lang/rust/issues/104826>.
116122
#[cfg_attr(not(bootstrap), lang = "identity_future")]
117123
#[doc(hidden)]
118124
#[unstable(feature = "gen_future", issue = "50547")]

core/src/task/wake.rs

+1
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ impl RawWakerVTable {
174174
/// Currently, `Context` only serves to provide access to a [`&Waker`](Waker)
175175
/// which can be used to wake the current task.
176176
#[stable(feature = "futures_api", since = "1.36.0")]
177+
#[cfg_attr(not(bootstrap), lang = "Context")]
177178
pub struct Context<'a> {
178179
waker: &'a Waker,
179180
// Ensure we future-proof against variance changes by forcing

0 commit comments

Comments
 (0)