Skip to content

Commit 099af82

Browse files
Auto merge of #145457 - m-ou-se:default-array-zero, r=<try>
Experiment: Add `where T: Default` to `Default for [T; 0]` impl.
2 parents ba412a6 + ae38e4d commit 099af82

File tree

2 files changed

+1
-8
lines changed

2 files changed

+1
-8
lines changed

library/core/src/array/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ macro_rules! array_impl_default {
484484
};
485485
{$n:expr,} => {
486486
#[stable(since = "1.4.0", feature = "array_default")]
487-
impl<T> Default for [T; $n] {
487+
impl<T> Default for [T; $n] where T: Default {
488488
fn default() -> [T; $n] { [] }
489489
}
490490
};

library/coretests/tests/array.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -292,13 +292,6 @@ fn array_default_impl_avoids_leaks_on_panic() {
292292
assert_eq!(COUNTER.load(Relaxed), 0);
293293
}
294294

295-
#[test]
296-
fn empty_array_is_always_default() {
297-
struct DoesNotImplDefault;
298-
299-
let _arr = <[DoesNotImplDefault; 0]>::default();
300-
}
301-
302295
#[test]
303296
fn array_map() {
304297
let a = [1, 2, 3];

0 commit comments

Comments
 (0)