@@ -276,29 +276,42 @@ pub mod __private {
276
276
#[ doc( hidden) ]
277
277
#[ allow( dead_code) ]
278
278
pub struct Wrapper < ' a , T : ?Sized > ( PhantomData < & ' a ( ) > , T ) ;
279
-
280
279
// SAFETY: `T` implements UnsafeUnpin.
281
280
unsafe impl < T : ?Sized + UnsafeUnpin > UnsafeUnpin for Wrapper < ' _ , T > { }
282
281
282
+ // Workaround for issue on unstable negative_impls feature that allows unsound overlapping Unpin
283
+ // implementations and rustc bug that leaks unstable negative_impls into stable.
284
+ // See https://github.com/taiki-e/pin-project/issues/340#issuecomment-2432146009 for details.
285
+ #[ doc( hidden) ]
286
+ pub type PinnedFieldsOf < T > =
287
+ <PinnedFieldsOfHelperStruct < T > as PinnedFieldsOfHelperTrait >:: Actual ;
288
+ // We cannot use <Option<T> as IntoIterator>::Item or similar since we should allow ?Sized in T.
289
+ #[ doc( hidden) ]
290
+ pub trait PinnedFieldsOfHelperTrait {
291
+ type Actual : ?Sized ;
292
+ }
293
+ #[ doc( hidden) ]
294
+ pub struct PinnedFieldsOfHelperStruct < T : ?Sized > ( T ) ;
295
+ impl < T : ?Sized > PinnedFieldsOfHelperTrait for PinnedFieldsOfHelperStruct < T > {
296
+ type Actual = T ;
297
+ }
298
+
283
299
// This is an internal helper struct used by `pin-project-internal`.
284
300
//
285
301
// See https://github.com/taiki-e/pin-project/pull/53 for more details.
286
302
#[ doc( hidden) ]
287
303
pub struct AlwaysUnpin < ' a , T > ( PhantomData < & ' a ( ) > , PhantomData < T > ) ;
288
-
289
304
impl < T > Unpin for AlwaysUnpin < ' _ , T > { }
290
305
291
306
// This is an internal helper used to ensure a value is dropped.
292
307
#[ doc( hidden) ]
293
308
pub struct UnsafeDropInPlaceGuard < T : ?Sized > ( * mut T ) ;
294
-
295
309
impl < T : ?Sized > UnsafeDropInPlaceGuard < T > {
296
310
#[ doc( hidden) ]
297
311
pub unsafe fn new ( ptr : * mut T ) -> Self {
298
312
Self ( ptr)
299
313
}
300
314
}
301
-
302
315
impl < T : ?Sized > Drop for UnsafeDropInPlaceGuard < T > {
303
316
fn drop ( & mut self ) {
304
317
// SAFETY: the caller of `UnsafeDropInPlaceGuard::new` must guarantee
@@ -316,14 +329,12 @@ pub mod __private {
316
329
target : * mut T ,
317
330
value : ManuallyDrop < T > ,
318
331
}
319
-
320
332
impl < T > UnsafeOverwriteGuard < T > {
321
333
#[ doc( hidden) ]
322
334
pub unsafe fn new ( target : * mut T , value : T ) -> Self {
323
335
Self { target, value : ManuallyDrop :: new ( value) }
324
336
}
325
337
}
326
-
327
338
impl < T > Drop for UnsafeOverwriteGuard < T > {
328
339
fn drop ( & mut self ) {
329
340
// SAFETY: the caller of `UnsafeOverwriteGuard::new` must guarantee
0 commit comments