File tree 1 file changed +14
-2
lines changed
1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change 1
1
#![ allow( clippy:: cast_ptr_alignment) ] // clippy is too strict here
2
2
3
- use super :: arc_wake:: { ArcWake , clone_arc_raw, wake_arc_raw , wake_by_ref_arc_raw} ;
3
+ use super :: arc_wake:: { ArcWake , clone_arc_raw, wake_by_ref_arc_raw} ;
4
4
use alloc:: sync:: Arc ;
5
5
use core:: marker:: PhantomData ;
6
6
use core:: ops:: Deref ;
@@ -44,6 +44,18 @@ impl Deref for WakerRef<'_> {
44
44
#[ inline]
45
45
unsafe fn noop ( _data : * const ( ) ) { }
46
46
47
+ unsafe fn wake_unreachable ( _data : * const ( ) ) {
48
+ // With only a reference, calling `wake_arc_raw()` would be unsound,
49
+ // since the `WakerRef` didn't increment the refcount of the `ArcWake`,
50
+ // and `wake_arc_raw` would *decrement* it.
51
+ //
52
+ // This should never be reachable, since `WakerRef` only provides a `Deref`
53
+ // to the inner `Waker`.
54
+ //
55
+ // Still, safer to panic here than to call `wake_arc_raw`.
56
+ unreachable ! ( "WakerRef::wake" ) ;
57
+ }
58
+
47
59
/// Creates a reference to a [`Waker`](::std::task::Waker)
48
60
/// from a local [`ArcWake`].
49
61
///
62
74
// Clones of the resulting `RawWaker` will still be dropped normally.
63
75
let vtable = & RawWakerVTable :: new (
64
76
clone_arc_raw :: < W > ,
65
- wake_arc_raw :: < W > ,
77
+ wake_unreachable ,
66
78
wake_by_ref_arc_raw :: < W > ,
67
79
noop,
68
80
) ;
You can’t perform that action at this time.
0 commit comments