Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ license = "MIT"

[dev-dependencies]
criterion = { version = "0.4.0", features = ["html_reports"] }
compiletest_rs = "0.10.0"

[features]
default = ["alloc"]
Expand Down
13 changes: 10 additions & 3 deletions src/with_alloc/alloc_ringbuffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,9 +321,16 @@ impl<T> AllocRingBuffer<T> {
#[must_use]
pub fn new(capacity: usize) -> Self {
assert_ne!(capacity, 0, "Capacity must be greater than 0");
let size = capacity.next_power_of_two();
let layout = alloc::alloc::Layout::array::<T>(size).unwrap();
let buf = unsafe { alloc::alloc::alloc(layout).cast() };
let size = capacity
.checked_next_power_of_two()
.expect("Capacity is too large");
let layout = alloc::alloc::Layout::array::<T>(size).expect("Capacity is too large");
#[cfg(target_pointer_width = "64")]
assert!(layout.size() <= (1usize << 40), "Capacity is too large");
let buf: *mut T = unsafe { alloc::alloc::alloc(layout).cast() };
if buf.is_null() {
alloc::alloc::handle_alloc_error(layout);
}
Self {
buf,
size,
Expand Down
9 changes: 0 additions & 9 deletions tests/compile-fail/test_const_generic_array_zero_length.rs

This file was deleted.

10 changes: 0 additions & 10 deletions tests/compile-fail/test_const_generic_array_zero_length_new.rs

This file was deleted.

23 changes: 0 additions & 23 deletions tests/compiletests.rs

This file was deleted.

Loading