@@ -391,36 +391,25 @@ mod array_defaults {
391
391
392
392
#[ cfg( not( bootstrap) ) ]
393
393
mod array_defaults {
394
- // We use auto traits to get overlapping impls without relying on nightly features.
395
- //
396
- // As the auto impl for `SendToDefault` is only considered if the manual impl does not apply,
397
- // we have to use the generic impl for `T: Default` as the impl for the `N = 0` case would
398
- // influence type inference in undesirable ways.
399
- //
400
- // While we are now able to implement `Default` exactly for the array types we want,
401
- // we're still not able to actually write the body of the `Default` function without
402
- // some further hacks.
403
- //
404
- // The idea here is that `array_default_hack` is resolved to itself only if `N = 0`
405
- // and is otherwise replaced with `T::default()`.
406
- //
407
- // This would cause issues if `T` doesn't actually implement default but as this function
408
- // is private and only used in the default impl itself this can not happen.
409
-
410
- struct ZeroToSend < T , const N : usize > ( * mut ( ) , T ) ;
411
- unsafe impl < T > Send for ZeroToSend < T , 0 > { }
412
-
413
- /// This struct implements `Send` either because of the manual impl for `N` is `0` or
414
- /// because all its fields implement `Send`, which is the case if `T` implements `Default`.
394
+ #[ marker]
415
395
#[ unstable(
416
396
feature = "array_default_impl" ,
417
397
issue = "none" ,
418
398
reason = "internal implementation detail for `[T; N]: Default`"
419
399
) ]
420
- #[ allow( missing_debug_implementations) ]
421
- pub struct SendToDefault < T , const N : usize > ( ZeroToSend < T , N > ) ;
422
- #[ unstable( feature = "array_default_impl" , issue = "none" ) ]
423
- unsafe impl < T : Default , const N : usize > Send for SendToDefault < T , N > { }
400
+ pub trait ArrayDefault { }
401
+ #[ unstable(
402
+ feature = "array_default_impl" ,
403
+ issue = "none" ,
404
+ reason = "internal implementation detail for `[T; N]: Default`"
405
+ ) ]
406
+ impl < T : Default , const N : usize > ArrayDefault for [ T ; N ] { }
407
+ #[ unstable(
408
+ feature = "array_default_impl" ,
409
+ issue = "none" ,
410
+ reason = "internal implementation detail for `[T; N]: Default`"
411
+ ) ]
412
+ impl < T > ArrayDefault for [ T ; 0 ] { }
424
413
425
414
// This function must not get called for `N != 0` if `T` does not implement `Default`.
426
415
#[ lang = "array_default_hack" ]
@@ -431,7 +420,7 @@ mod array_defaults {
431
420
#[ stable( since = "1.4.0" , feature = "array_default" ) ]
432
421
impl < T , const N : usize > Default for [ T ; N ]
433
422
where
434
- SendToDefault < T , N > : Send ,
423
+ [ T ; N ] : ArrayDefault ,
435
424
{
436
425
fn default ( ) -> [ T ; N ] {
437
426
// SAFETY: The only case where `T` does not implement `Default` is
0 commit comments