Skip to content
This repository was archived by the owner on Nov 27, 2020. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 39869d7

Browse files
committedNov 30, 2019
Use Panic for associated type rather than ! for clarity
1 parent ade4b1e commit 39869d7

File tree

8 files changed

+97
-90
lines changed

8 files changed

+97
-90
lines changed
 

‎src/alloc/abort.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ use core::ptr::NonNull;
2424
#[derive(Copy, Clone, Debug, Default)]
2525
pub struct AbortAlloc<Alloc>(pub Alloc);
2626

27+
/// A synonym used to indicate the impossible case will be a panic instead.
28+
///
29+
/// `!` in rust really does mean "never" / "impossible", but nothing in the type
30+
/// system tracks panicking.
31+
pub type Panic = !;
32+
2733
impl<A: BuildAllocRef> BuildAllocRef for AbortAlloc<A> {
2834
type Ref = AbortAlloc<A::Ref>;
2935

@@ -49,7 +55,7 @@ impl<A: DeallocRef> DeallocRef for AbortAlloc<A> {
4955
}
5056

5157
impl<A: AllocRef> AllocRef for AbortAlloc<A> {
52-
type Error = !;
58+
type Error = Panic;
5359

5460
fn alloc(&mut self, layout: NonZeroLayout) -> Result<NonNull<u8>, Self::Error> {
5561
self.0

‎src/alloc/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ mod abort;
22
mod layout;
33

44
pub use self::{
5-
abort::AbortAlloc,
5+
abort::{AbortAlloc, Panic},
66
layout::{LayoutErr, NonZeroLayout},
77
};
88
pub use core::alloc::GlobalAlloc;

‎src/boxed.rs

+18-18
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
//! [`NonZeroLayout::for_value(&*value)`]: crate::alloc::NonZeroLayout::for_value
8080
8181
use crate::{
82-
alloc::{AbortAlloc, AllocRef, BuildAllocRef, DeallocRef, Global, NonZeroLayout},
82+
alloc::{AbortAlloc, AllocRef, BuildAllocRef, DeallocRef, Global, NonZeroLayout, Panic},
8383
clone::CloneIn,
8484
collections::CollectionAllocErr,
8585
raw_vec::RawVec,
@@ -188,7 +188,7 @@ impl<T, A: AllocRef> Box<T, A> {
188188
#[inline(always)]
189189
pub fn new_in(x: T, a: A) -> Self
190190
where
191-
A: AllocRef<Error = !>,
191+
A: AllocRef<Error = Panic>,
192192
{
193193
let Ok(b) = Self::try_new_in(x, a);
194194
b
@@ -245,7 +245,7 @@ impl<T, A: AllocRef> Box<T, A> {
245245
#[inline(always)]
246246
pub fn new_uninit_in(a: A) -> Box<mem::MaybeUninit<T>, A>
247247
where
248-
A: AllocRef<Error = !>,
248+
A: AllocRef<Error = Panic>,
249249
{
250250
let Ok(b) = Self::try_new_uninit_in(a);
251251
b
@@ -286,7 +286,7 @@ impl<T, A: AllocRef> Box<T, A> {
286286
#[inline(always)]
287287
pub fn pin_in(x: T, a: A) -> Pin<Self>
288288
where
289-
A: AllocRef<Error = !>,
289+
A: AllocRef<Error = Panic>,
290290
{
291291
let Ok(b) = Self::try_pin_in(x, a);
292292
b
@@ -331,7 +331,7 @@ impl<T> Box<[T]> {
331331
}
332332

333333
#[allow(clippy::use_self)]
334-
impl<T, A: AllocRef<Error = !>> Box<[T], A> {
334+
impl<T, A: AllocRef<Error = Panic>> Box<[T], A> {
335335
/// Construct a new boxed slice with uninitialized contents with the spoecified allocator.
336336
///
337337
/// # Example
@@ -775,7 +775,7 @@ unsafe impl<#[may_dangle] T: ?Sized, A: DeallocRef> Drop for Box<T, A> {
775775
impl<T, A> Default for Box<T, A>
776776
where
777777
T: Default,
778-
A: Default + AllocRef<Error = !>,
778+
A: Default + AllocRef<Error = Panic>,
779779
{
780780
#[must_use]
781781
fn default() -> Self {
@@ -784,9 +784,9 @@ where
784784
}
785785

786786
#[allow(clippy::use_self)]
787-
impl<T, A: AllocRef<Error = !>> Default for Box<[T], A>
787+
impl<T, A: AllocRef<Error = Panic>> Default for Box<[T], A>
788788
where
789-
A: Default + AllocRef<Error = !>,
789+
A: Default + AllocRef<Error = Panic>,
790790
{
791791
#[must_use]
792792
fn default() -> Self {
@@ -801,19 +801,19 @@ unsafe fn from_boxed_utf8_unchecked<A: DeallocRef>(v: Box<[u8], A>) -> Box<str,
801801
}
802802

803803
#[allow(clippy::use_self)]
804-
impl<A: AllocRef<Error = !>> Default for Box<str, A>
804+
impl<A: AllocRef<Error = Panic>> Default for Box<str, A>
805805
where
806-
A: Default + AllocRef<Error = !>,
806+
A: Default + AllocRef<Error = Panic>,
807807
{
808808
#[must_use]
809809
fn default() -> Self {
810810
unsafe { from_boxed_utf8_unchecked(Box::default()) }
811811
}
812812
}
813813

814-
impl<T: Clone, A: AllocRef<Error = !>> Clone for Box<T, A>
814+
impl<T: Clone, A: AllocRef<Error = Panic>> Clone for Box<T, A>
815815
where
816-
A: AllocRef<Error = !>,
816+
A: AllocRef<Error = Panic>,
817817
A::BuildAlloc: Clone,
818818
{
819819
/// Returns a new box with a `clone()` of this box's contents.
@@ -876,7 +876,7 @@ impl<T: Clone, A: AllocRef, B: AllocRef> CloneIn<B> for Box<T, A> {
876876

877877
fn clone_in(&self, a: B) -> Self::Cloned
878878
where
879-
B: AllocRef<Error = !>,
879+
B: AllocRef<Error = Panic>,
880880
{
881881
Box::new_in(self.as_ref().clone(), a)
882882
}
@@ -978,9 +978,9 @@ impl<T: ?Sized + Hasher, A: DeallocRef> Hasher for Box<T, A> {
978978
}
979979
}
980980

981-
impl<T, A: AllocRef<Error = !>> From<T> for Box<T, A>
981+
impl<T, A: AllocRef<Error = Panic>> From<T> for Box<T, A>
982982
where
983-
A: Default + AllocRef<Error = !>,
983+
A: Default + AllocRef<Error = Panic>,
984984
{
985985
/// Converts a generic type `T` into a `Box<T>`
986986
///
@@ -1014,7 +1014,7 @@ impl<T: ?Sized, A: DeallocRef> From<Box<T, A>> for Pin<Box<T, A>> {
10141014
#[allow(clippy::use_self)]
10151015
impl<T: Copy, A> From<&[T]> for Box<[T], A>
10161016
where
1017-
A: Default + AllocRef<Error = !>,
1017+
A: Default + AllocRef<Error = Panic>,
10181018
{
10191019
/// Converts a `&[T]` into a `Box<[T], B>`
10201020
///
@@ -1043,7 +1043,7 @@ where
10431043
#[allow(clippy::use_self)]
10441044
impl<A> From<&str> for Box<str, A>
10451045
where
1046-
A: Default + AllocRef<Error = !>,
1046+
A: Default + AllocRef<Error = Panic>,
10471047
{
10481048
/// Converts a `&str` into a `Box<str>`
10491049
///
@@ -1306,7 +1306,7 @@ impl_dispatch_from_dyn!(AbortAlloc<std::alloc::System>);
13061306
#[allow(clippy::items_after_statements)]
13071307
impl<T: Clone, A: Clone> Clone for Box<[T], A>
13081308
where
1309-
A: AllocRef<Error = !>,
1309+
A: AllocRef<Error = Panic>,
13101310
A::BuildAlloc: Clone,
13111311
{
13121312
fn clone(&self) -> Self {

‎src/clone.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
use crate::alloc::AllocRef;
1+
use crate::alloc::{AllocRef, Panic};
22

33
pub trait CloneIn<A: AllocRef>: Sized {
44
type Cloned;
55

66
fn clone_in(&self, a: A) -> Self::Cloned
77
where
8-
A: AllocRef<Error = !>;
8+
A: AllocRef<Error = Panic>;
99

1010
fn try_clone_in(&self, a: A) -> Result<Self::Cloned, A::Error>;
1111
}

‎src/iter.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::{alloc::AllocRef, collections::CollectionAllocErr};
1+
use crate::{alloc::{AllocRef, Panic}, collections::CollectionAllocErr};
22

33
/// Extend a collection "fallibly" with the contents of an iterator.
44
pub trait TryExtend<A> {
@@ -27,7 +27,7 @@ pub trait TryExtend<A> {
2727
pub trait FromIteratorIn<T, A: AllocRef> {
2828
fn from_iter_in<I: IntoIterator<Item = T>>(iter: I, allocator: A) -> Self
2929
where
30-
A: AllocRef<Error = !>;
30+
A: AllocRef<Error = Panic>;
3131

3232
fn try_from_iter_in<I: IntoIterator<Item = T>>(
3333
iter: I,
@@ -42,7 +42,7 @@ pub trait IteratorExt: Iterator + Sized {
4242
#[must_use = "if you really need to exhaust the iterator, consider `.for_each(drop)` instead"]
4343
fn collect_in<T: FromIteratorIn<Self::Item, A>, A: AllocRef>(self, allocator: A) -> T
4444
where
45-
A: AllocRef<Error = !>,
45+
A: AllocRef<Error = Panic>,
4646
{
4747
FromIteratorIn::from_iter_in(self, allocator)
4848
}

‎src/raw_vec.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use crate::{
88
Global,
99
NonZeroLayout,
1010
ReallocRef,
11+
Panic,
1112
},
1213
boxed::Box,
1314
collections::CollectionAllocErr,
@@ -162,7 +163,7 @@ impl<T, A: DeallocRef> RawVec<T, A> {
162163
/// * on 32-bit platforms if the requested capacity exceeds `isize::MAX` bytes.
163164
pub fn with_capacity_in(capacity: usize, a: A) -> Self
164165
where
165-
A: AllocRef<Error = !>,
166+
A: AllocRef<Error = Panic>,
166167
{
167168
match Self::try_with_capacity_in(capacity, a) {
168169
Ok(vec) => vec,
@@ -198,7 +199,7 @@ impl<T, A: DeallocRef> RawVec<T, A> {
198199
/// * on 32-bit platforms if the requested capacity exceeds `isize::MAX` bytes.
199200
pub fn with_capacity_zeroed_in(capacity: usize, a: A) -> Self
200201
where
201-
A: AllocRef<Error = !>,
202+
A: AllocRef<Error = Panic>,
202203
{
203204
match Self::try_with_capacity_zeroed_in(capacity, a) {
204205
Ok(vec) => vec,
@@ -419,7 +420,7 @@ impl<T, A: DeallocRef> RawVec<T, A> {
419420
/// ```
420421
pub fn double(&mut self)
421422
where
422-
A: ReallocRef<Error = !>,
423+
A: ReallocRef<Error = Panic>,
423424
{
424425
match self.try_double() {
425426
Ok(_) => (),
@@ -590,7 +591,7 @@ impl<T, A: DeallocRef> RawVec<T, A> {
590591
/// ```
591592
pub fn reserve(&mut self, used_capacity: usize, needed_extra_capacity: usize)
592593
where
593-
A: ReallocRef<Error = !>,
594+
A: ReallocRef<Error = Panic>,
594595
{
595596
match self.try_reserve(used_capacity, needed_extra_capacity) {
596597
Ok(vec) => vec,
@@ -634,7 +635,7 @@ impl<T, A: DeallocRef> RawVec<T, A> {
634635
/// * on 32-bit platforms if the requested capacity exceeds `isize::MAX` bytes.
635636
pub fn reserve_exact(&mut self, used_capacity: usize, needed_extra_capacity: usize)
636637
where
637-
A: ReallocRef<Error = !>,
638+
A: ReallocRef<Error = Panic>,
638639
{
639640
match self.try_reserve_exact(used_capacity, needed_extra_capacity) {
640641
Ok(_) => (),
@@ -736,7 +737,7 @@ impl<T, A: DeallocRef> RawVec<T, A> {
736737
/// Panics if the given amount is *larger* than the current capacity.
737738
pub fn shrink_to_fit(&mut self, amount: usize)
738739
where
739-
A: ReallocRef<Error = !>,
740+
A: ReallocRef<Error = Panic>,
740741
{
741742
match self.try_shrink_to_fit(amount) {
742743
Ok(_) => (),

‎src/string.rs

+27-27
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
//! ```
5353
5454
use crate::{
55-
alloc::{AbortAlloc, AllocRef, DeallocRef, Global, ReallocRef},
55+
alloc::{AbortAlloc, AllocRef, DeallocRef, Global, ReallocRef, Panic},
5656
boxed::Box,
5757
collections::CollectionAllocErr,
5858
iter::TryExtend,
@@ -580,7 +580,7 @@ impl<A: DeallocRef> String<A> {
580580
#[inline]
581581
pub fn with_capacity_in(capacity: usize, a: A) -> Self
582582
where
583-
A: AllocRef<Error = !>,
583+
A: AllocRef<Error = Panic>,
584584
{
585585
match Self::try_with_capacity_in(capacity, a) {
586586
Ok(vec) => vec,
@@ -608,7 +608,7 @@ impl<A: DeallocRef> String<A> {
608608
#[inline]
609609
pub fn from_str_in(s: &str, a: A) -> Self
610610
where
611-
A: ReallocRef<Error = !>,
611+
A: ReallocRef<Error = Panic>,
612612
{
613613
let mut v = Self::with_capacity_in(s.len(), a);
614614
v.push_str(s);
@@ -708,7 +708,7 @@ impl<A: DeallocRef> String<A> {
708708
/// Panics if allocation fails.
709709
pub fn from_utf8_lossy_in(v: &[u8], a: A) -> Self
710710
where
711-
A: ReallocRef<Error = !>,
711+
A: ReallocRef<Error = Panic>,
712712
{
713713
match Self::try_from_utf8_lossy_in(v, a) {
714714
Ok(s) => s,
@@ -757,7 +757,7 @@ impl<A: DeallocRef> String<A> {
757757
/// Like `from_utf16` but parameterized over the choice of allocator for the returned `String`.
758758
pub fn from_utf16_in(v: &[u16], a: A) -> Result<Self, FromUtf16Error>
759759
where
760-
A: ReallocRef<Error = !>,
760+
A: ReallocRef<Error = Panic>,
761761
{
762762
// This isn't done via collect::<Result<_, _>>() for performance reasons.
763763
// FIXME: the function can be simplified again when #48994 is closed.
@@ -932,7 +932,7 @@ impl<A: DeallocRef> String<A> {
932932
#[inline]
933933
pub fn push_str(&mut self, string: &str)
934934
where
935-
A: ReallocRef<Error = !>,
935+
A: ReallocRef<Error = Panic>,
936936
{
937937
self.vec.extend_from_slice(string.as_bytes())
938938
}
@@ -1016,7 +1016,7 @@ impl<A: DeallocRef> String<A> {
10161016
#[inline]
10171017
pub fn reserve(&mut self, additional: usize)
10181018
where
1019-
A: ReallocRef<Error = !>,
1019+
A: ReallocRef<Error = Panic>,
10201020
{
10211021
self.vec.reserve(additional)
10221022
}
@@ -1069,7 +1069,7 @@ impl<A: DeallocRef> String<A> {
10691069
#[inline]
10701070
pub fn reserve_exact(&mut self, additional: usize)
10711071
where
1072-
A: ReallocRef<Error = !>,
1072+
A: ReallocRef<Error = Panic>,
10731073
{
10741074
self.vec.reserve_exact(additional)
10751075
}
@@ -1180,7 +1180,7 @@ impl<A: DeallocRef> String<A> {
11801180
#[inline]
11811181
pub fn shrink_to_fit(&mut self)
11821182
where
1183-
A: ReallocRef<Error = !>,
1183+
A: ReallocRef<Error = Panic>,
11841184
{
11851185
self.vec.shrink_to_fit()
11861186
}
@@ -1224,7 +1224,7 @@ impl<A: DeallocRef> String<A> {
12241224
#[inline]
12251225
pub fn shrink_to(&mut self, min_capacity: usize)
12261226
where
1227-
A: ReallocRef<Error = !>,
1227+
A: ReallocRef<Error = Panic>,
12281228
{
12291229
self.vec.shrink_to(min_capacity)
12301230
}
@@ -1263,7 +1263,7 @@ impl<A: DeallocRef> String<A> {
12631263
#[inline]
12641264
pub fn push(&mut self, ch: char)
12651265
where
1266-
A: ReallocRef<Error = !>,
1266+
A: ReallocRef<Error = Panic>,
12671267
{
12681268
match self.try_push(ch) {
12691269
Ok(s) => s,
@@ -1516,7 +1516,7 @@ impl<A: DeallocRef> String<A> {
15161516
#[inline]
15171517
pub fn insert(&mut self, idx: usize, ch: char)
15181518
where
1519-
A: ReallocRef<Error = !>,
1519+
A: ReallocRef<Error = Panic>,
15201520
{
15211521
match self.try_insert(idx, ch) {
15221522
Ok(s) => s,
@@ -1592,7 +1592,7 @@ impl<A: DeallocRef> String<A> {
15921592
#[inline]
15931593
pub fn insert_str(&mut self, idx: usize, string: &str)
15941594
where
1595-
A: ReallocRef<Error = !>,
1595+
A: ReallocRef<Error = Panic>,
15961596
{
15971597
match self.try_insert_str(idx, string) {
15981598
Ok(s) => s,
@@ -1606,7 +1606,7 @@ impl<A: DeallocRef> String<A> {
16061606
#[inline]
16071607
pub fn try_insert_str(&mut self, idx: usize, string: &str) -> Result<(), CollectionAllocErr<A>>
16081608
where
1609-
A: ReallocRef<Error = !>,
1609+
A: ReallocRef<Error = Panic>,
16101610
{
16111611
assert!(self.is_char_boundary(idx));
16121612

@@ -1716,7 +1716,7 @@ impl<A: DeallocRef> String<A> {
17161716
#[inline]
17171717
pub fn split_off(&mut self, at: usize) -> Self
17181718
where
1719-
A: AllocRef<Error = !>,
1719+
A: AllocRef<Error = Panic>,
17201720
{
17211721
match self.try_split_off(at) {
17221722
Ok(s) => s,
@@ -1856,7 +1856,7 @@ impl<A: DeallocRef> String<A> {
18561856
pub fn replace_range<R>(&mut self, range: R, replace_with: &str)
18571857
where
18581858
R: RangeBounds<usize>,
1859-
A: ReallocRef<Error = !>,
1859+
A: ReallocRef<Error = Panic>,
18601860
{
18611861
// Memory safety
18621862
//
@@ -1901,7 +1901,7 @@ impl<A: DeallocRef> String<A> {
19011901
#[inline]
19021902
pub fn into_boxed_str(self) -> Box<str, A>
19031903
where
1904-
A: ReallocRef<Error = !>,
1904+
A: ReallocRef<Error = Panic>,
19051905
{
19061906
let slice = self.vec.into_boxed_slice();
19071907
unsafe { from_boxed_utf8_unchecked(slice) }
@@ -2007,7 +2007,7 @@ impl fmt::Display for FromUtf16Error {
20072007
}
20082008
}
20092009

2010-
impl<A: AllocRef<Error = !>> Clone for String<A>
2010+
impl<A: AllocRef<Error = Panic>> Clone for String<A>
20112011
where
20122012
A: AllocRef,
20132013
A::BuildAlloc: Clone,
@@ -2033,7 +2033,7 @@ impl<A: AllocRef, B: AllocRef> CloneIn<B> for String<A> {
20332033
#[must_use = "Cloning is expected to be expensive"]
20342034
fn clone_in(&self, a: B) -> Self::Cloned
20352035
where
2036-
B: AllocRef<Error = !>,
2036+
B: AllocRef<Error = Panic>,
20372037
{
20382038
String {
20392039
vec: self.vec.clone_in(a),
@@ -2110,7 +2110,7 @@ impl<'a> FromIterator<Cow<'a, str>> for String {
21102110

21112111
impl<A> Extend<char> for String<A>
21122112
where
2113-
A: ReallocRef<Error = !>,
2113+
A: ReallocRef<Error = Panic>,
21142114
{
21152115
fn extend<I: IntoIterator<Item = char>>(&mut self, iter: I) {
21162116
let iterator = iter.into_iter();
@@ -2134,7 +2134,7 @@ impl<A: ReallocRef> TryExtend<char> for String<A> {
21342134

21352135
impl<'a, A> Extend<&'a char> for String<A>
21362136
where
2137-
A: ReallocRef<Error = !>,
2137+
A: ReallocRef<Error = Panic>,
21382138
{
21392139
fn extend<I: IntoIterator<Item = &'a char>>(&mut self, iter: I) {
21402140
self.extend(iter.into_iter().cloned());
@@ -2151,7 +2151,7 @@ impl<'a, A: ReallocRef> TryExtend<&'a char> for String<A> {
21512151

21522152
impl<'a, A> Extend<&'a str> for String<A>
21532153
where
2154-
A: ReallocRef<Error = !>,
2154+
A: ReallocRef<Error = Panic>,
21552155
{
21562156
fn extend<I: IntoIterator<Item = &'a str>>(&mut self, iter: I) {
21572157
iter.into_iter().for_each(move |s| self.push_str(s));
@@ -2168,7 +2168,7 @@ impl<'a, A: ReallocRef> TryExtend<&'a str> for String<A> {
21682168

21692169
impl<A, B> Extend<String<B>> for String<A>
21702170
where
2171-
A: ReallocRef<Error = !>,
2171+
A: ReallocRef<Error = Panic>,
21722172
B: DeallocRef,
21732173
{
21742174
fn extend<I: IntoIterator<Item = String<B>>>(&mut self, iter: I) {
@@ -2188,7 +2188,7 @@ impl<A: ReallocRef, B: DeallocRef> TryExtend<String<B>> for String<A> {
21882188
#[cfg(feature = "std")]
21892189
impl<'a, A> Extend<Cow<'a, str>> for String<A>
21902190
where
2191-
A: ReallocRef<Error = !>,
2191+
A: ReallocRef<Error = Panic>,
21922192
{
21932193
fn extend<I: IntoIterator<Item = Cow<'a, str>>>(&mut self, iter: I) {
21942194
iter.into_iter().for_each(move |s| self.push_str(&s));
@@ -2324,7 +2324,7 @@ impl<A: DeallocRef> hash::Hash for String<A> {
23242324
/// ```
23252325
impl<A> Add<&str> for String<A>
23262326
where
2327-
A: ReallocRef<Error = !>,
2327+
A: ReallocRef<Error = Panic>,
23282328
{
23292329
type Output = Self;
23302330

@@ -2340,7 +2340,7 @@ where
23402340
/// This has the same behavior as the [`push_str`][`String::push_str`] method.
23412341
impl<A> AddAssign<&str> for String<A>
23422342
where
2343-
A: ReallocRef<Error = !>,
2343+
A: ReallocRef<Error = Panic>,
23442344
{
23452345
#[inline]
23462346
fn add_assign(&mut self, other: &str) {
@@ -2516,7 +2516,7 @@ impl From<Box<str>> for String {
25162516

25172517
impl<A> From<String<A>> for Box<str, A>
25182518
where
2519-
A: ReallocRef<Error = !>,
2519+
A: ReallocRef<Error = Panic>,
25202520
{
25212521
/// Converts the given `String` to a boxed `str` slice that is owned.
25222522
///

‎src/vec.rs

+32-32
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
//! [`vec!`]: ../macro.vec.html
7070
7171
use crate::{
72-
alloc::{AbortAlloc, AllocRef, BuildAllocRef, DeallocRef, Global, ReallocRef},
72+
alloc::{AbortAlloc, AllocRef, BuildAllocRef, DeallocRef, Global, ReallocRef, Panic},
7373
boxed::Box,
7474
clone::CloneIn,
7575
collections::CollectionAllocErr,
@@ -490,7 +490,7 @@ impl<T, A: DeallocRef> Vec<T, A> {
490490
#[inline]
491491
pub fn with_capacity_in(capacity: usize, a: A) -> Self
492492
where
493-
A: AllocRef<Error = !>,
493+
A: AllocRef<Error = Panic>,
494494
{
495495
Self {
496496
buf: RawVec::with_capacity_in(capacity, a),
@@ -612,7 +612,7 @@ impl<T, A: DeallocRef> Vec<T, A> {
612612
/// Panics if the reallocation fails.
613613
pub fn reserve(&mut self, additional: usize)
614614
where
615-
A: ReallocRef<Error = !>,
615+
A: ReallocRef<Error = Panic>,
616616
{
617617
self.buf.reserve(self.len, additional);
618618
}
@@ -645,7 +645,7 @@ impl<T, A: DeallocRef> Vec<T, A> {
645645
/// Panics if the reallocation fails.
646646
pub fn reserve_exact(&mut self, additional: usize)
647647
where
648-
A: ReallocRef<Error = !>,
648+
A: ReallocRef<Error = Panic>,
649649
{
650650
self.buf.reserve_exact(self.len, additional);
651651
}
@@ -759,7 +759,7 @@ impl<T, A: DeallocRef> Vec<T, A> {
759759
/// Panics if the reallocation fails.
760760
pub fn shrink_to_fit(&mut self)
761761
where
762-
A: ReallocRef<Error = !>,
762+
A: ReallocRef<Error = Panic>,
763763
{
764764
if self.capacity() != self.len {
765765
self.buf.shrink_to_fit(self.len);
@@ -805,7 +805,7 @@ impl<T, A: DeallocRef> Vec<T, A> {
805805
/// * Panics if the reallocation fails.
806806
pub fn shrink_to(&mut self, min_capacity: usize)
807807
where
808-
A: ReallocRef<Error = !>,
808+
A: ReallocRef<Error = Panic>,
809809
{
810810
self.buf.shrink_to_fit(cmp::max(self.len, min_capacity));
811811
}
@@ -852,7 +852,7 @@ impl<T, A: DeallocRef> Vec<T, A> {
852852
/// Panics if the reallocation fails.
853853
pub fn into_boxed_slice(self) -> Box<[T], A>
854854
where
855-
A: ReallocRef<Error = !>,
855+
A: ReallocRef<Error = Panic>,
856856
{
857857
match self.try_into_boxed_slice() {
858858
Ok(vec) => vec,
@@ -1197,7 +1197,7 @@ impl<T, A: DeallocRef> Vec<T, A> {
11971197
/// ```
11981198
pub fn insert(&mut self, index: usize, element: T)
11991199
where
1200-
A: ReallocRef<Error = !>,
1200+
A: ReallocRef<Error = Panic>,
12011201
{
12021202
match self.try_insert(index, element) {
12031203
Ok(vec) => vec,
@@ -1304,7 +1304,7 @@ impl<T, A: DeallocRef> Vec<T, A> {
13041304
pub fn retain<F>(&mut self, mut f: F)
13051305
where
13061306
F: FnMut(&T) -> bool,
1307-
A: ReallocRef<Error = !>,
1307+
A: ReallocRef<Error = Panic>,
13081308
{
13091309
self.drain_filter(|x| !f(x));
13101310
}
@@ -1387,7 +1387,7 @@ impl<T, A: DeallocRef> Vec<T, A> {
13871387
#[inline]
13881388
pub fn push(&mut self, value: T)
13891389
where
1390-
A: ReallocRef<Error = !>,
1390+
A: ReallocRef<Error = Panic>,
13911391
{
13921392
match self.try_push(value) {
13931393
Ok(vec) => vec,
@@ -1473,7 +1473,7 @@ impl<T, A: DeallocRef> Vec<T, A> {
14731473
#[inline]
14741474
pub fn append(&mut self, other: &mut Self)
14751475
where
1476-
A: ReallocRef<Error = !>,
1476+
A: ReallocRef<Error = Panic>,
14771477
{
14781478
match self.try_append(other) {
14791479
Ok(vec) => vec,
@@ -1659,7 +1659,7 @@ impl<T, A: DeallocRef> Vec<T, A> {
16591659
#[inline]
16601660
pub fn split_off(&mut self, at: usize) -> Self
16611661
where
1662-
A: AllocRef<Error = !>,
1662+
A: AllocRef<Error = Panic>,
16631663
{
16641664
match self.try_split_off(at) {
16651665
Ok(vec) => vec,
@@ -1730,7 +1730,7 @@ impl<T, A: DeallocRef> Vec<T, A> {
17301730
pub fn resize_with<F>(&mut self, new_len: usize, f: F)
17311731
where
17321732
F: FnMut() -> T,
1733-
A: ReallocRef<Error = !>,
1733+
A: ReallocRef<Error = Panic>,
17341734
{
17351735
match self.try_resize_with(new_len, f) {
17361736
Ok(vec) => vec,
@@ -1785,7 +1785,7 @@ impl<T, A: DeallocRef> Vec<T, A> {
17851785
pub fn leak<'a>(vec: Self) -> &'a mut [T]
17861786
where
17871787
T: 'a, // Technically not needed, but kept to be explicit.
1788-
A: ReallocRef<Error = !>,
1788+
A: ReallocRef<Error = Panic>,
17891789
{
17901790
Box::leak(vec.into_boxed_slice())
17911791
}
@@ -1834,7 +1834,7 @@ impl<T: Clone, A: ReallocRef> Vec<T, A> {
18341834
/// Panics if the reallocation fails.
18351835
pub fn resize(&mut self, new_len: usize, value: T)
18361836
where
1837-
A: ReallocRef<Error = !>,
1837+
A: ReallocRef<Error = Panic>,
18381838
{
18391839
match self.try_resize(new_len, value) {
18401840
Ok(_) => (),
@@ -1882,7 +1882,7 @@ impl<T: Clone, A: ReallocRef> Vec<T, A> {
18821882
/// Panics if the reallocation fails.
18831883
pub fn extend_from_slice(&mut self, other: &[T])
18841884
where
1885-
A: ReallocRef<Error = !>,
1885+
A: ReallocRef<Error = Panic>,
18861886
{
18871887
self.spec_extend(other.iter().cloned())
18881888
}
@@ -2051,7 +2051,7 @@ pub fn from_elem<T: Clone>(elem: T, n: usize) -> Vec<T> {
20512051
#[doc(hidden)]
20522052
pub fn from_elem_in<T: Clone, A>(elem: T, n: usize, a: A) -> Vec<T, A>
20532053
where
2054-
A: ReallocRef<Error = !>,
2054+
A: ReallocRef<Error = Panic>,
20552055
{
20562056
match try_from_elem_in(elem, n, a) {
20572057
Ok(vec) => vec,
@@ -2199,7 +2199,7 @@ unsafe impl<T: ?Sized> IsZero for Option<Box<T>> {
21992199
// Common trait implementations for Vec
22002200
////////////////////////////////////////////////////////////////////////////////
22012201

2202-
impl<T: Clone, A: AllocRef<Error = !>> Clone for Vec<T, A>
2202+
impl<T: Clone, A: AllocRef<Error = Panic>> Clone for Vec<T, A>
22032203
where
22042204
A: AllocRef,
22052205
A::BuildAlloc: Clone,
@@ -2224,7 +2224,7 @@ impl<T: Clone, A: AllocRef, B: AllocRef> CloneIn<B> for Vec<T, A> {
22242224

22252225
fn clone_in(&self, a: B) -> Self::Cloned
22262226
where
2227-
B: AllocRef<Error = !>,
2227+
B: AllocRef<Error = Panic>,
22282228
{
22292229
let Ok(v) = self.try_clone_in(a);
22302230
v
@@ -2300,7 +2300,7 @@ impl<T, A: ReallocRef> FromIteratorIn<T, A> for Vec<T, A> {
23002300
#[must_use]
23012301
fn from_iter_in<I: IntoIterator<Item = T>>(iter: I, a: A) -> Self
23022302
where
2303-
A: AllocRef<Error = !>,
2303+
A: AllocRef<Error = Panic>,
23042304
{
23052305
<Self as SpecExtend<T, I::IntoIter, A>>::from_iter_in(iter.into_iter(), a)
23062306
}
@@ -2376,7 +2376,7 @@ impl<'a, T, A: DeallocRef> IntoIterator for &'a mut Vec<T, A> {
23762376

23772377
impl<T, A> Extend<T> for Vec<T, A>
23782378
where
2379-
A: ReallocRef<Error = !>,
2379+
A: ReallocRef<Error = Panic>,
23802380
{
23812381
#[inline]
23822382
fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I) {
@@ -2397,7 +2397,7 @@ trait SpecExtend<T, I, A: AllocRef>: Sized {
23972397
#[inline]
23982398
fn from_iter_in(iter: I, a: A) -> Self
23992399
where
2400-
A: AllocRef<Error = !>,
2400+
A: AllocRef<Error = Panic>,
24012401
{
24022402
match Self::try_from_iter_in(iter, a) {
24032403
Ok(v) => v,
@@ -2412,7 +2412,7 @@ trait SpecExtend<T, I, A: AllocRef>: Sized {
24122412
#[inline]
24132413
fn spec_extend(&mut self, iter: I)
24142414
where
2415-
A: AllocRef<Error = !>,
2415+
A: AllocRef<Error = Panic>,
24162416
{
24172417
match self.try_spec_extend(iter) {
24182418
Ok(_) => (),
@@ -2625,7 +2625,7 @@ impl<T, A: DeallocRef> Vec<T, A> {
26252625
#[inline]
26262626
pub fn splice<R, I>(&mut self, range: R, replace_with: I) -> Splice<'_, I::IntoIter, A>
26272627
where
2628-
A: ReallocRef<Error = !>,
2628+
A: ReallocRef<Error = Panic>,
26292629
R: RangeBounds<usize>,
26302630
I: IntoIterator<Item = T>,
26312631
{
@@ -2684,7 +2684,7 @@ impl<T, A: DeallocRef> Vec<T, A> {
26842684
/// ```
26852685
pub fn drain_filter<F>(&mut self, filter: F) -> DrainFilter<'_, T, F, A>
26862686
where
2687-
A: ReallocRef<Error = !>,
2687+
A: ReallocRef<Error = Panic>,
26882688
F: FnMut(&mut T) -> bool,
26892689
{
26902690
let old_len = self.len();
@@ -2713,7 +2713,7 @@ impl<T, A: DeallocRef> Vec<T, A> {
27132713
/// [`copy_from_slice`]: ../../std/primitive.slice.html#method.copy_from_slice
27142714
impl<'a, T: 'a + Copy, A> Extend<&'a T> for Vec<T, A>
27152715
where
2716-
A: ReallocRef<Error = !>,
2716+
A: ReallocRef<Error = Panic>,
27172717
{
27182718
fn extend<I: IntoIterator<Item = &'a T>>(&mut self, iter: I) {
27192719
self.extend(iter.into_iter().cloned())
@@ -3172,15 +3172,15 @@ impl<T, A: DeallocRef> FusedIterator for Drain<'_, T, A> {}
31723172
#[derive(Debug)]
31733173
pub struct Splice<'a, I: Iterator + 'a, A = AbortAlloc<Global>>
31743174
where
3175-
A: ReallocRef<Error = !>, // Because Drop can allocate
3175+
A: ReallocRef<Error = Panic>, // Because Drop can allocate
31763176
{
31773177
drain: Drain<'a, I::Item, A>,
31783178
replace_with: I,
31793179
}
31803180

31813181
impl<I: Iterator, A> Iterator for Splice<'_, I, A>
31823182
where
3183-
A: ReallocRef<Error = !>,
3183+
A: ReallocRef<Error = Panic>,
31843184
{
31853185
type Item = I::Item;
31863186

@@ -3195,18 +3195,18 @@ where
31953195

31963196
impl<I: Iterator, A> DoubleEndedIterator for Splice<'_, I, A>
31973197
where
3198-
A: ReallocRef<Error = !>,
3198+
A: ReallocRef<Error = Panic>,
31993199
{
32003200
fn next_back(&mut self) -> Option<Self::Item> {
32013201
self.drain.next_back()
32023202
}
32033203
}
32043204

3205-
impl<I: Iterator, A> ExactSizeIterator for Splice<'_, I, A> where A: ReallocRef<Error = !> {}
3205+
impl<I: Iterator, A> ExactSizeIterator for Splice<'_, I, A> where A: ReallocRef<Error = Panic> {}
32063206

32073207
impl<I: Iterator, A> Drop for Splice<'_, I, A>
32083208
where
3209-
A: ReallocRef<Error = !>,
3209+
A: ReallocRef<Error = Panic>,
32103210
{
32113211
fn drop(&mut self) {
32123212
self.drain.by_ref().for_each(drop);
@@ -3252,7 +3252,7 @@ where
32523252
/// Private helper methods for `Splice::drop`
32533253
impl<T, A: DeallocRef> Drain<'_, T, A>
32543254
where
3255-
A: ReallocRef<Error = !>,
3255+
A: ReallocRef<Error = Panic>,
32563256
{
32573257
/// The range from `self.vec.len` to `self.tail_start` contains elements
32583258
/// that have been moved out.

0 commit comments

Comments
 (0)
This repository has been archived.