Skip to content

Commit fe6c596

Browse files
committed
fix nightly
1 parent f30a0d7 commit fe6c596

File tree

2 files changed

+21
-21
lines changed

2 files changed

+21
-21
lines changed

src/lib.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ use vint::VintArrayIterator;
4343
// use self::Entry::*;
4444
use self::VacantEntryState::*;
4545
use std::cmp::max;
46-
use std::collections::CollectionAllocErr;
46+
use std::collections::TryReserveError;
4747
use std::fmt::{self, Debug};
4848
#[allow(deprecated)]
4949
use std::hash::BuildHasher;
@@ -74,7 +74,7 @@ impl DefaultResizePolicy {
7474
/// provide that capacity, accounting for maximum loading. The raw capacity
7575
/// is always zero or a power of two.
7676
#[inline]
77-
fn try_raw_capacity(&self, len: usize) -> Result<usize, CollectionAllocErr> {
77+
fn try_raw_capacity(&self, len: usize) -> Result<usize, TryReserveError> {
7878
if len == 0 {
7979
Ok(0)
8080
} else {
@@ -85,7 +85,7 @@ impl DefaultResizePolicy {
8585
.checked_mul(11)
8686
.map(|l| l / 10)
8787
.and_then(|l| l.checked_next_power_of_two())
88-
.ok_or(CollectionAllocErr::CapacityOverflow)?;
88+
.ok_or(TryReserveError::CapacityOverflow)?;
8989

9090
raw_cap = max(MIN_NONZERO_RAW_CAPACITY, raw_cap);
9191
Ok(raw_cap)
@@ -755,8 +755,8 @@ where
755755
/// ```
756756
pub fn reserve(&mut self, additional: usize) {
757757
match self.reserve_internal(additional, Infallible) {
758-
Err(CollectionAllocErr::CapacityOverflow) => panic!("capacity overflow"),
759-
Err(CollectionAllocErr::AllocErr) => unreachable!(),
758+
Err(TryReserveError::CapacityOverflow) => panic!("capacity overflow"),
759+
Err(TryReserveError::AllocError{..}) => unreachable!(),
760760
Ok(()) => { /* yay */ }
761761
}
762762
}
@@ -778,21 +778,21 @@ where
778778
/// let mut map: HashMap<&str, isize> = HashMap::new();
779779
/// map.try_reserve(10).expect("why is the test harness OOMing on 10 bytes?");
780780
/// ```
781-
pub fn try_reserve(&mut self, additional: usize) -> Result<(), CollectionAllocErr> {
781+
pub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError> {
782782
self.reserve_internal(additional, Fallible)
783783
}
784784

785785
fn reserve_internal(
786786
&mut self,
787787
additional: usize,
788788
fallibility: Fallibility,
789-
) -> Result<(), CollectionAllocErr> {
789+
) -> Result<(), TryReserveError> {
790790
let remaining = self.capacity() - self.len(); // this can't overflow
791791
if remaining < additional {
792792
let min_cap = self
793793
.len()
794794
.checked_add(additional)
795-
.ok_or(CollectionAllocErr::CapacityOverflow)?;
795+
.ok_or(TryReserveError::CapacityOverflow)?;
796796
let raw_cap = self.resize_policy.try_raw_capacity(min_cap)?;
797797
self.try_resize(raw_cap, fallibility)?;
798798
} else if self.table.tag() && remaining <= self.len() {
@@ -815,7 +815,7 @@ where
815815
&mut self,
816816
new_raw_cap: usize,
817817
fallibility: Fallibility,
818-
) -> Result<(), CollectionAllocErr> {
818+
) -> Result<(), TryReserveError> {
819819
assert!(self.table.size() <= new_raw_cap);
820820
assert!(new_raw_cap.is_power_of_two() || new_raw_cap == 0);
821821

@@ -1505,7 +1505,7 @@ where
15051505
if disp >= DISPLACEMENT_THRESHOLD {
15061506
bucket.table_mut().set_tag(true);
15071507
}
1508-
let mut text_position =
1508+
let text_position =
15091509
add_and_get_text_position(key, &mut bucket.table_mut().raw_text_data);
15101510
bucket.put(hash, text_position, value)
15111511
}
@@ -2379,7 +2379,7 @@ mod test_map {
23792379
// if let Err(CapacityOverflow) = empty_bytes.try_reserve(max_no_ovf) {
23802380
// } else { panic!("isize::MAX + 1 should trigger a CapacityOverflow!") }
23812381
// } else {
2382-
// if let Err(AllocErr) = empty_bytes.try_reserve(max_no_ovf) {
2382+
// if let Err(AllocError) = empty_bytes.try_reserve(max_no_ovf) {
23832383
// } else { panic!("isize::MAX + 1 should trigger an OOM!") }
23842384
// }
23852385
// }

src/table.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
use self::BucketState::*;
1212
use std::alloc::{handle_alloc_error, Alloc, Global, Layout, LayoutErr};
13-
use std::collections::CollectionAllocErr;
13+
use std::collections::TryReserveError;
1414
use std::marker;
1515
use std::mem::{needs_drop, size_of};
1616
use std::ops::{Deref, DerefMut};
@@ -599,7 +599,7 @@ impl<V> RawTable<V> {
599599
unsafe fn new_uninitialized_internal(
600600
capacity: usize,
601601
fallibility: Fallibility,
602-
) -> Result<RawTable<V>, CollectionAllocErr> {
602+
) -> Result<RawTable<V>, TryReserveError> {
603603
if capacity == 0 {
604604
return Ok(RawTable {
605605
size: 0,
@@ -618,7 +618,7 @@ impl<V> RawTable<V> {
618618
let buffer = Global.alloc(layout).map_err(|e| match fallibility {
619619
Infallible => handle_alloc_error(layout),
620620
Fallible => e,
621-
})?;
621+
}).unwrap(); // TODO fix conversion
622622

623623
Ok(RawTable {
624624
capacity_mask: capacity.wrapping_sub(1),
@@ -633,8 +633,8 @@ impl<V> RawTable<V> {
633633
/// at the very least, set every hash to EMPTY_BUCKET.
634634
unsafe fn new_uninitialized(capacity: usize) -> RawTable<V> {
635635
match Self::new_uninitialized_internal(capacity, Infallible) {
636-
Err(CollectionAllocErr::CapacityOverflow) => panic!("capacity overflow"),
637-
Err(CollectionAllocErr::AllocErr) => unreachable!(),
636+
Err(TryReserveError::CapacityOverflow) => panic!("capacity overflow"),
637+
Err(TryReserveError::AllocError{..}) => unreachable!(),
638638
Ok(table) => table,
639639
}
640640
}
@@ -655,7 +655,7 @@ impl<V> RawTable<V> {
655655
fn new_internal(
656656
capacity: usize,
657657
fallibility: Fallibility,
658-
) -> Result<RawTable<V>, CollectionAllocErr> {
658+
) -> Result<RawTable<V>, TryReserveError> {
659659
unsafe {
660660
let ret = RawTable::new_uninitialized_internal(capacity, fallibility)?;
661661
ptr::write_bytes(ret.hashes.ptr(), 0, capacity);
@@ -664,17 +664,17 @@ impl<V> RawTable<V> {
664664
}
665665

666666
/// Tries to create a new raw table from a given capacity. If it cannot allocate,
667-
/// it returns with AllocErr.
668-
pub fn try_new(capacity: usize) -> Result<RawTable<V>, CollectionAllocErr> {
667+
/// it returns with AllocError.
668+
pub fn try_new(capacity: usize) -> Result<RawTable<V>, TryReserveError> {
669669
Self::new_internal(capacity, Fallible)
670670
}
671671

672672
/// Creates a new raw table from a given capacity. All buckets are
673673
/// initially empty.
674674
pub fn new(capacity: usize) -> RawTable<V> {
675675
match Self::new_internal(capacity, Infallible) {
676-
Err(CollectionAllocErr::CapacityOverflow) => panic!("capacity overflow"),
677-
Err(CollectionAllocErr::AllocErr) => unreachable!(),
676+
Err(TryReserveError::CapacityOverflow) => panic!("capacity overflow"),
677+
Err(TryReserveError::AllocError{..}) => unreachable!(),
678678
Ok(table) => table,
679679
}
680680
}

0 commit comments

Comments
 (0)