Skip to content

Commit 94bb282

Browse files
Wrap Context.ext in AssertUnwindSafe
1 parent 725b38e commit 94bb282

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

core/src/task/wake.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use crate::mem::transmute;
55
use crate::any::Any;
66
use crate::fmt;
77
use crate::marker::PhantomData;
8+
use crate::panic::AssertUnwindSafe;
89
use crate::ptr;
910

1011
/// A `RawWaker` allows the implementor of a task executor to create a [`Waker`]
@@ -236,7 +237,7 @@ enum ExtData<'a> {
236237
pub struct Context<'a> {
237238
waker: &'a Waker,
238239
local_waker: &'a LocalWaker,
239-
ext: ExtData<'a>,
240+
ext: AssertUnwindSafe<ExtData<'a>>,
240241
// Ensure we future-proof against variance changes by forcing
241242
// the lifetime to be invariant (argument-position lifetimes
242243
// are contravariant while return-position lifetimes are
@@ -279,7 +280,9 @@ impl<'a> Context<'a> {
279280
#[unstable(feature = "context_ext", issue = "123392")]
280281
#[rustc_const_unstable(feature = "const_waker", issue = "102012")]
281282
pub const fn ext(&mut self) -> &mut dyn Any {
282-
match &mut self.ext {
283+
// FIXME: this field makes Context extra-weird about unwind safety
284+
// can we justify AssertUnwindSafe if we stabilize this? do we care?
285+
match &mut *self.ext {
283286
ExtData::Some(data) => *data,
284287
ExtData::None(unit) => unit,
285288
}
@@ -353,7 +356,7 @@ impl<'a> ContextBuilder<'a> {
353356
#[rustc_const_unstable(feature = "const_waker", issue = "102012")]
354357
#[unstable(feature = "context_ext", issue = "123392")]
355358
pub const fn from(cx: &'a mut Context<'_>) -> Self {
356-
let ext = match &mut cx.ext {
359+
let ext = match &mut *cx.ext {
357360
ExtData::Some(ext) => ExtData::Some(*ext),
358361
ExtData::None(()) => ExtData::None(()),
359362
};
@@ -396,7 +399,7 @@ impl<'a> ContextBuilder<'a> {
396399
#[rustc_const_unstable(feature = "const_waker", issue = "102012")]
397400
pub const fn build(self) -> Context<'a> {
398401
let ContextBuilder { waker, local_waker, ext, _marker, _marker2 } = self;
399-
Context { waker, local_waker, ext, _marker, _marker2 }
402+
Context { waker, local_waker, ext: AssertUnwindSafe(ext), _marker, _marker2 }
400403
}
401404
}
402405

0 commit comments

Comments
 (0)