@@ -2,6 +2,7 @@ use crate::task::AtomicWaker;
22use futures_core:: future:: Future ;
33use futures_core:: task:: { Context , Poll } ;
44use pin_utils:: unsafe_pinned;
5+ use core:: fmt;
56use core:: pin:: Pin ;
67use core:: sync:: atomic:: { AtomicBool , Ordering } ;
78use alloc:: sync:: Arc ;
@@ -121,16 +122,24 @@ pub fn abortable<Fut>(future: Fut) -> (Abortable<Fut>, AbortHandle)
121122}
122123
123124/// Indicator that the `Abortable` future was aborted.
124- #[ derive( Copy , Clone , Debug , Eq , PartialEq ) ]
125- pub struct Aborted ;
125+ #[ derive( Copy , Clone , Eq , PartialEq ) ]
126+ pub struct Aborted {
127+ _priv : ( ) ,
128+ }
129+
130+ impl fmt:: Debug for Aborted {
131+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
132+ f. debug_tuple ( "Aborted" ) . finish ( )
133+ }
134+ }
126135
127136impl < Fut > Future for Abortable < Fut > where Fut : Future {
128137 type Output = Result < Fut :: Output , Aborted > ;
129138
130139 fn poll ( mut self : Pin < & mut Self > , cx : & mut Context < ' _ > ) -> Poll < Self :: Output > {
131140 // Check if the future has been aborted
132141 if self . inner . cancel . load ( Ordering :: Relaxed ) {
133- return Poll :: Ready ( Err ( Aborted ) )
142+ return Poll :: Ready ( Err ( Aborted { _priv : ( ) } ) )
134143 }
135144
136145 // attempt to complete the future
@@ -146,7 +155,7 @@ impl<Fut> Future for Abortable<Fut> where Fut: Future {
146155 // Checking with `Relaxed` is sufficient because `register` introduces an
147156 // `AcqRel` barrier.
148157 if self . inner . cancel . load ( Ordering :: Relaxed ) {
149- return Poll :: Ready ( Err ( Aborted ) )
158+ return Poll :: Ready ( Err ( Aborted { _priv : ( ) } ) )
150159 }
151160
152161 Poll :: Pending
0 commit comments