@@ -5,6 +5,7 @@ use crate::mem::transmute;
5
5
use crate :: any:: Any ;
6
6
use crate :: fmt;
7
7
use crate :: marker:: PhantomData ;
8
+ use crate :: panic:: AssertUnwindSafe ;
8
9
use crate :: ptr;
9
10
10
11
/// A `RawWaker` allows the implementor of a task executor to create a [`Waker`]
@@ -236,7 +237,7 @@ enum ExtData<'a> {
236
237
pub struct Context < ' a > {
237
238
waker : & ' a Waker ,
238
239
local_waker : & ' a LocalWaker ,
239
- ext : ExtData < ' a > ,
240
+ ext : AssertUnwindSafe < ExtData < ' a > > ,
240
241
// Ensure we future-proof against variance changes by forcing
241
242
// the lifetime to be invariant (argument-position lifetimes
242
243
// are contravariant while return-position lifetimes are
@@ -279,7 +280,9 @@ impl<'a> Context<'a> {
279
280
#[ unstable( feature = "context_ext" , issue = "123392" ) ]
280
281
#[ rustc_const_unstable( feature = "const_waker" , issue = "102012" ) ]
281
282
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 {
283
286
ExtData :: Some ( data) => * data,
284
287
ExtData :: None ( unit) => unit,
285
288
}
@@ -353,7 +356,7 @@ impl<'a> ContextBuilder<'a> {
353
356
#[ rustc_const_unstable( feature = "const_waker" , issue = "102012" ) ]
354
357
#[ unstable( feature = "context_ext" , issue = "123392" ) ]
355
358
pub const fn from ( cx : & ' a mut Context < ' _ > ) -> Self {
356
- let ext = match & mut cx. ext {
359
+ let ext = match & mut * cx. ext {
357
360
ExtData :: Some ( ext) => ExtData :: Some ( * ext) ,
358
361
ExtData :: None ( ( ) ) => ExtData :: None ( ( ) ) ,
359
362
} ;
@@ -396,7 +399,7 @@ impl<'a> ContextBuilder<'a> {
396
399
#[ rustc_const_unstable( feature = "const_waker" , issue = "102012" ) ]
397
400
pub const fn build ( self ) -> Context < ' a > {
398
401
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 }
400
403
}
401
404
}
402
405
0 commit comments