Skip to content

Commit 36b18a1

Browse files
committed
Rename CollectionAllocError to TryReserveError
1 parent 9dd5c19 commit 36b18a1

File tree

11 files changed

+45
-45
lines changed

11 files changed

+45
-45
lines changed

src/liballoc/collections/mod.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ use crate::alloc::{AllocErr, LayoutErr};
4646
/// Augments `AllocErr` with a CapacityOverflow variant.
4747
#[derive(Clone, PartialEq, Eq, Debug)]
4848
#[unstable(feature = "try_reserve", reason = "new API", issue="48043")]
49-
pub enum CollectionAllocErr {
49+
pub enum TryReserveError {
5050
/// Error due to the computed capacity exceeding the collection's maximum
5151
/// (usually `isize::MAX` bytes).
5252
CapacityOverflow,
@@ -55,18 +55,18 @@ pub enum CollectionAllocErr {
5555
}
5656

5757
#[unstable(feature = "try_reserve", reason = "new API", issue="48043")]
58-
impl From<AllocErr> for CollectionAllocErr {
58+
impl From<AllocErr> for TryReserveError {
5959
#[inline]
6060
fn from(AllocErr: AllocErr) -> Self {
61-
CollectionAllocErr::AllocErr
61+
TryReserveError::AllocErr
6262
}
6363
}
6464

6565
#[unstable(feature = "try_reserve", reason = "new API", issue="48043")]
66-
impl From<LayoutErr> for CollectionAllocErr {
66+
impl From<LayoutErr> for TryReserveError {
6767
#[inline]
6868
fn from(_: LayoutErr) -> Self {
69-
CollectionAllocErr::CapacityOverflow
69+
TryReserveError::CapacityOverflow
7070
}
7171
}
7272

src/liballoc/collections/vec_deque.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use core::ptr::{self, NonNull};
1818
use core::slice;
1919
use core::hash::{Hash, Hasher};
2020

21-
use crate::collections::CollectionAllocErr;
21+
use crate::collections::TryReserveError;
2222
use crate::raw_vec::RawVec;
2323
use crate::vec::Vec;
2424

@@ -576,10 +576,10 @@ impl<T> VecDeque<T> {
576576
///
577577
/// ```
578578
/// #![feature(try_reserve)]
579-
/// use std::collections::CollectionAllocErr;
579+
/// use std::collections::TryReserveError;
580580
/// use std::collections::VecDeque;
581581
///
582-
/// fn process_data(data: &[u32]) -> Result<VecDeque<u32>, CollectionAllocErr> {
582+
/// fn process_data(data: &[u32]) -> Result<VecDeque<u32>, TryReserveError> {
583583
/// let mut output = VecDeque::new();
584584
///
585585
/// // Pre-reserve the memory, exiting if we can't
@@ -595,7 +595,7 @@ impl<T> VecDeque<T> {
595595
/// # process_data(&[1, 2, 3]).expect("why is the test harness OOMing on 12 bytes?");
596596
/// ```
597597
#[unstable(feature = "try_reserve", reason = "new API", issue="48043")]
598-
pub fn try_reserve_exact(&mut self, additional: usize) -> Result<(), CollectionAllocErr> {
598+
pub fn try_reserve_exact(&mut self, additional: usize) -> Result<(), TryReserveError> {
599599
self.try_reserve(additional)
600600
}
601601

@@ -614,10 +614,10 @@ impl<T> VecDeque<T> {
614614
///
615615
/// ```
616616
/// #![feature(try_reserve)]
617-
/// use std::collections::CollectionAllocErr;
617+
/// use std::collections::TryReserveError;
618618
/// use std::collections::VecDeque;
619619
///
620-
/// fn process_data(data: &[u32]) -> Result<VecDeque<u32>, CollectionAllocErr> {
620+
/// fn process_data(data: &[u32]) -> Result<VecDeque<u32>, TryReserveError> {
621621
/// let mut output = VecDeque::new();
622622
///
623623
/// // Pre-reserve the memory, exiting if we can't
@@ -633,12 +633,12 @@ impl<T> VecDeque<T> {
633633
/// # process_data(&[1, 2, 3]).expect("why is the test harness OOMing on 12 bytes?");
634634
/// ```
635635
#[unstable(feature = "try_reserve", reason = "new API", issue="48043")]
636-
pub fn try_reserve(&mut self, additional: usize) -> Result<(), CollectionAllocErr> {
636+
pub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError> {
637637
let old_cap = self.cap();
638638
let used_cap = self.len() + 1;
639639
let new_cap = used_cap.checked_add(additional)
640640
.and_then(|needed_cap| needed_cap.checked_next_power_of_two())
641-
.ok_or(CollectionAllocErr::CapacityOverflow)?;
641+
.ok_or(TryReserveError::CapacityOverflow)?;
642642

643643
if new_cap > old_cap {
644644
self.buf.try_reserve_exact(used_cap, new_cap - used_cap)?;

src/liballoc/raw_vec.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use core::ptr::{self, NonNull, Unique};
88
use core::slice;
99

1010
use crate::alloc::{Alloc, Layout, Global, handle_alloc_error};
11-
use crate::collections::CollectionAllocErr::{self, *};
11+
use crate::collections::TryReserveError::{self, *};
1212
use crate::boxed::Box;
1313

1414
#[cfg(test)]
@@ -385,7 +385,7 @@ impl<T, A: Alloc> RawVec<T, A> {
385385

386386
/// The same as `reserve_exact`, but returns on errors instead of panicking or aborting.
387387
pub fn try_reserve_exact(&mut self, used_capacity: usize, needed_extra_capacity: usize)
388-
-> Result<(), CollectionAllocErr> {
388+
-> Result<(), TryReserveError> {
389389

390390
self.reserve_internal(used_capacity, needed_extra_capacity, Fallible, Exact)
391391
}
@@ -422,7 +422,7 @@ impl<T, A: Alloc> RawVec<T, A> {
422422
/// needed_extra_capacity` elements. This logic is used in amortized reserve methods.
423423
/// Returns `(new_capacity, new_alloc_size)`.
424424
fn amortized_new_size(&self, used_capacity: usize, needed_extra_capacity: usize)
425-
-> Result<usize, CollectionAllocErr> {
425+
-> Result<usize, TryReserveError> {
426426

427427
// Nothing we can really do about these checks :(
428428
let required_cap = used_capacity.checked_add(needed_extra_capacity)
@@ -435,7 +435,7 @@ impl<T, A: Alloc> RawVec<T, A> {
435435

436436
/// The same as `reserve`, but returns on errors instead of panicking or aborting.
437437
pub fn try_reserve(&mut self, used_capacity: usize, needed_extra_capacity: usize)
438-
-> Result<(), CollectionAllocErr> {
438+
-> Result<(), TryReserveError> {
439439
self.reserve_internal(used_capacity, needed_extra_capacity, Fallible, Amortized)
440440
}
441441

@@ -640,7 +640,7 @@ impl<T, A: Alloc> RawVec<T, A> {
640640
needed_extra_capacity: usize,
641641
fallibility: Fallibility,
642642
strategy: ReserveStrategy,
643-
) -> Result<(), CollectionAllocErr> {
643+
) -> Result<(), TryReserveError> {
644644
unsafe {
645645
use crate::alloc::AllocErr;
646646

@@ -737,7 +737,7 @@ unsafe impl<#[may_dangle] T, A: Alloc> Drop for RawVec<T, A> {
737737
// all 4GB in user-space. e.g., PAE or x32
738738

739739
#[inline]
740-
fn alloc_guard(alloc_size: usize) -> Result<(), CollectionAllocErr> {
740+
fn alloc_guard(alloc_size: usize) -> Result<(), TryReserveError> {
741741
if mem::size_of::<usize>() < 8 && alloc_size > core::isize::MAX as usize {
742742
Err(CapacityOverflow)
743743
} else {

src/liballoc/string.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ use core::ptr;
5656
use core::str::{pattern::Pattern, lossy};
5757

5858
use crate::borrow::{Cow, ToOwned};
59-
use crate::collections::CollectionAllocErr;
59+
use crate::collections::TryReserveError;
6060
use crate::boxed::Box;
6161
use crate::str::{self, from_boxed_utf8_unchecked, FromStr, Utf8Error, Chars};
6262
use crate::vec::Vec;
@@ -937,9 +937,9 @@ impl String {
937937
///
938938
/// ```
939939
/// #![feature(try_reserve)]
940-
/// use std::collections::CollectionAllocErr;
940+
/// use std::collections::TryReserveError;
941941
///
942-
/// fn process_data(data: &str) -> Result<String, CollectionAllocErr> {
942+
/// fn process_data(data: &str) -> Result<String, TryReserveError> {
943943
/// let mut output = String::new();
944944
///
945945
/// // Pre-reserve the memory, exiting if we can't
@@ -953,7 +953,7 @@ impl String {
953953
/// # process_data("rust").expect("why is the test harness OOMing on 4 bytes?");
954954
/// ```
955955
#[unstable(feature = "try_reserve", reason = "new API", issue="48043")]
956-
pub fn try_reserve(&mut self, additional: usize) -> Result<(), CollectionAllocErr> {
956+
pub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError> {
957957
self.vec.try_reserve(additional)
958958
}
959959

@@ -975,9 +975,9 @@ impl String {
975975
///
976976
/// ```
977977
/// #![feature(try_reserve)]
978-
/// use std::collections::CollectionAllocErr;
978+
/// use std::collections::TryReserveError;
979979
///
980-
/// fn process_data(data: &str) -> Result<String, CollectionAllocErr> {
980+
/// fn process_data(data: &str) -> Result<String, TryReserveError> {
981981
/// let mut output = String::new();
982982
///
983983
/// // Pre-reserve the memory, exiting if we can't
@@ -991,7 +991,7 @@ impl String {
991991
/// # process_data("rust").expect("why is the test harness OOMing on 4 bytes?");
992992
/// ```
993993
#[unstable(feature = "try_reserve", reason = "new API", issue="48043")]
994-
pub fn try_reserve_exact(&mut self, additional: usize) -> Result<(), CollectionAllocErr> {
994+
pub fn try_reserve_exact(&mut self, additional: usize) -> Result<(), TryReserveError> {
995995
self.vec.try_reserve_exact(additional)
996996
}
997997

src/liballoc/tests/string.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use std::borrow::Cow;
2-
use std::collections::CollectionAllocErr::*;
2+
use std::collections::TryReserveError::*;
33
use std::mem::size_of;
44
use std::{usize, isize};
55

src/liballoc/tests/vec.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::borrow::Cow;
22
use std::mem::size_of;
33
use std::{usize, isize};
44
use std::vec::{Drain, IntoIter};
5-
use std::collections::CollectionAllocErr::*;
5+
use std::collections::TryReserveError::*;
66

77
struct DropCounter<'a> {
88
count: &'a mut u32,

src/liballoc/tests/vec_deque.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::fmt::Debug;
22
use std::collections::{VecDeque, vec_deque::Drain};
3-
use std::collections::CollectionAllocErr::*;
3+
use std::collections::TryReserveError::*;
44
use std::mem::size_of;
55
use std::{usize, isize};
66

src/liballoc/vec.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ use core::ptr::{self, NonNull};
7070
use core::slice::{self, SliceIndex};
7171

7272
use crate::borrow::{ToOwned, Cow};
73-
use crate::collections::CollectionAllocErr;
73+
use crate::collections::TryReserveError;
7474
use crate::boxed::Box;
7575
use crate::raw_vec::RawVec;
7676

@@ -498,9 +498,9 @@ impl<T> Vec<T> {
498498
///
499499
/// ```
500500
/// #![feature(try_reserve)]
501-
/// use std::collections::CollectionAllocErr;
501+
/// use std::collections::TryReserveError;
502502
///
503-
/// fn process_data(data: &[u32]) -> Result<Vec<u32>, CollectionAllocErr> {
503+
/// fn process_data(data: &[u32]) -> Result<Vec<u32>, TryReserveError> {
504504
/// let mut output = Vec::new();
505505
///
506506
/// // Pre-reserve the memory, exiting if we can't
@@ -516,7 +516,7 @@ impl<T> Vec<T> {
516516
/// # process_data(&[1, 2, 3]).expect("why is the test harness OOMing on 12 bytes?");
517517
/// ```
518518
#[unstable(feature = "try_reserve", reason = "new API", issue="48043")]
519-
pub fn try_reserve(&mut self, additional: usize) -> Result<(), CollectionAllocErr> {
519+
pub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError> {
520520
self.buf.try_reserve(self.len, additional)
521521
}
522522

@@ -538,9 +538,9 @@ impl<T> Vec<T> {
538538
///
539539
/// ```
540540
/// #![feature(try_reserve)]
541-
/// use std::collections::CollectionAllocErr;
541+
/// use std::collections::TryReserveError;
542542
///
543-
/// fn process_data(data: &[u32]) -> Result<Vec<u32>, CollectionAllocErr> {
543+
/// fn process_data(data: &[u32]) -> Result<Vec<u32>, TryReserveError> {
544544
/// let mut output = Vec::new();
545545
///
546546
/// // Pre-reserve the memory, exiting if we can't
@@ -556,7 +556,7 @@ impl<T> Vec<T> {
556556
/// # process_data(&[1, 2, 3]).expect("why is the test harness OOMing on 12 bytes?");
557557
/// ```
558558
#[unstable(feature = "try_reserve", reason = "new API", issue="48043")]
559-
pub fn try_reserve_exact(&mut self, additional: usize) -> Result<(), CollectionAllocErr> {
559+
pub fn try_reserve_exact(&mut self, additional: usize) -> Result<(), TryReserveError> {
560560
self.buf.try_reserve_exact(self.len, additional)
561561
}
562562

src/libstd/collections/hash/map.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use hashbrown::hash_map as base;
66

77
use crate::borrow::Borrow;
88
use crate::cell::Cell;
9-
use crate::collections::CollectionAllocErr;
9+
use crate::collections::TryReserveError;
1010
use crate::fmt::{self, Debug};
1111
#[allow(deprecated)]
1212
use crate::hash::{BuildHasher, Hash, Hasher, SipHasher13};
@@ -588,7 +588,7 @@ where
588588
/// ```
589589
#[inline]
590590
#[unstable(feature = "try_reserve", reason = "new API", issue = "48043")]
591-
pub fn try_reserve(&mut self, additional: usize) -> Result<(), CollectionAllocErr> {
591+
pub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError> {
592592
self.base
593593
.try_reserve(additional)
594594
.map_err(map_collection_alloc_err)
@@ -2542,10 +2542,10 @@ fn map_entry<'a, K: 'a, V: 'a>(raw: base::RustcEntry<'a, K, V>) -> Entry<'a, K,
25422542
}
25432543

25442544
#[inline]
2545-
fn map_collection_alloc_err(err: hashbrown::CollectionAllocErr) -> CollectionAllocErr {
2545+
fn map_collection_alloc_err(err: hashbrown::CollectionAllocErr) -> TryReserveError {
25462546
match err {
2547-
hashbrown::CollectionAllocErr::CapacityOverflow => CollectionAllocErr::CapacityOverflow,
2548-
hashbrown::CollectionAllocErr::AllocErr => CollectionAllocErr::AllocErr,
2547+
hashbrown::CollectionAllocErr::CapacityOverflow => TryReserveError::CapacityOverflow,
2548+
hashbrown::CollectionAllocErr::AllocErr => TryReserveError::AllocErr,
25492549
}
25502550
}
25512551

@@ -2605,7 +2605,7 @@ mod test_map {
26052605
use super::RandomState;
26062606
use crate::cell::RefCell;
26072607
use rand::{thread_rng, Rng};
2608-
use realstd::collections::CollectionAllocErr::*;
2608+
use realstd::collections::TryReserveError::*;
26092609
use realstd::usize;
26102610

26112611
// https://github.com/rust-lang/rust/issues/62301

src/libstd/collections/hash/set.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::borrow::Borrow;
2-
use crate::collections::CollectionAllocErr;
2+
use crate::collections::TryReserveError;
33
use crate::fmt;
44
use crate::hash::{Hash, BuildHasher};
55
use crate::iter::{Chain, FromIterator, FusedIterator};
@@ -383,7 +383,7 @@ impl<T, S> HashSet<T, S>
383383
/// ```
384384
#[inline]
385385
#[unstable(feature = "try_reserve", reason = "new API", issue="48043")]
386-
pub fn try_reserve(&mut self, additional: usize) -> Result<(), CollectionAllocErr> {
386+
pub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError> {
387387
self.map.try_reserve(additional)
388388
}
389389

src/libstd/collections/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ pub use self::hash_map::HashMap;
427427
pub use self::hash_set::HashSet;
428428

429429
#[unstable(feature = "try_reserve", reason = "new API", issue="48043")]
430-
pub use alloc_crate::collections::CollectionAllocErr;
430+
pub use alloc_crate::collections::TryReserveError;
431431

432432
mod hash;
433433

0 commit comments

Comments
 (0)