Skip to content

Commit

Permalink
Rollup merge of #59451 - TimDiekmann:patch-1, r=sfackler
Browse files Browse the repository at this point in the history
Add `Default` to `std::alloc::System`

`System` is a unit struct, thus, it can be constructed without any additional information. Therefore `Default` is a noop. However, in generic code, a `T: Default` may happen as in

```rust
#[derive(Default)]
struct Foo<A> {
    allocator: A
}
```

Does this need a feature gate?
Should I also add `PartialEq/Eq/PartialOrd/Ord/Hash`?
  • Loading branch information
Centril authored Mar 27, 2019
2 parents a4b4253 + 8733b2a commit d04b1ec
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/libstd/alloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ pub use alloc_crate::alloc::*;
/// program opts in to using jemalloc as the global allocator, `System` will
/// still allocate memory using `malloc` and `HeapAlloc`.
#[stable(feature = "alloc_system_type", since = "1.28.0")]
#[derive(Debug, Copy, Clone)]
#[derive(Debug, Default, Copy, Clone)]
pub struct System;

// The Alloc impl just forwards to the GlobalAlloc impl, which is in `std::sys::*::alloc`.
Expand Down

0 comments on commit d04b1ec

Please sign in to comment.