Remove the now-unit-struct AllocErr parameter of oom()

This commit is contained in:
Simon Sapin
2018-04-03 16:00:04 +02:00
parent 86753ce1cc
commit 157ff8cd05
12 changed files with 28 additions and 28 deletions

View File

@@ -136,8 +136,8 @@ unsafe fn exchange_malloc(size: usize, align: usize) -> *mut u8 {
align as *mut u8
} else {
let layout = Layout::from_size_align_unchecked(size, align);
Global.alloc(layout).unwrap_or_else(|err| {
Global.oom(err)
Global.alloc(layout).unwrap_or_else(|_| {
Global.oom()
})
}
}
@@ -166,7 +166,7 @@ mod tests {
unsafe {
let layout = Layout::from_size_align(1024, 1).unwrap();
let ptr = Global.alloc_zeroed(layout.clone())
.unwrap_or_else(|e| Global.oom(e));
.unwrap_or_else(|_| Global.oom());
let end = ptr.offset(layout.size() as isize);
let mut i = ptr;

View File

@@ -555,7 +555,7 @@ impl<T: ?Sized> Arc<T> {
let layout = Layout::for_value(&*fake_ptr);
let mem = Global.alloc(layout)
.unwrap_or_else(|e| Global.oom(e));
.unwrap_or_else(|_| Global.oom());
// Initialize the real ArcInner
let inner = set_data_ptr(ptr as *mut T, mem) as *mut ArcInner<T>;

View File

@@ -52,8 +52,8 @@ unsafe impl<T> Alloc for T where T: CoreAlloc {
CoreAlloc::dealloc(self, ptr, layout)
}
fn oom(&mut self, err: AllocErr) -> ! {
CoreAlloc::oom(self, err)
fn oom(&mut self, _: AllocErr) -> ! {
CoreAlloc::oom(self)
}
fn usable_size(&self, layout: &Layout) -> (usize, usize) {

View File

@@ -100,7 +100,7 @@ impl<T, A: Alloc> RawVec<T, A> {
};
match result {
Ok(ptr) => ptr,
Err(err) => a.oom(err),
Err(_) => a.oom(),
}
};
@@ -316,7 +316,7 @@ impl<T, A: Alloc> RawVec<T, A> {
new_layout);
match ptr_res {
Ok(ptr) => (new_cap, Unique::new_unchecked(ptr as *mut T)),
Err(e) => self.a.oom(e),
Err(_) => self.a.oom(),
}
}
None => {
@@ -325,7 +325,7 @@ impl<T, A: Alloc> RawVec<T, A> {
let new_cap = if elem_size > (!0) / 8 { 1 } else { 4 };
match self.a.alloc_array::<T>(new_cap) {
Ok(ptr) => (new_cap, ptr.into()),
Err(e) => self.a.oom(e),
Err(_) => self.a.oom(),
}
}
};
@@ -444,7 +444,7 @@ impl<T, A: Alloc> RawVec<T, A> {
pub fn reserve_exact(&mut self, used_cap: usize, needed_extra_cap: usize) {
match self.try_reserve_exact(used_cap, needed_extra_cap) {
Err(CapacityOverflow) => panic!("capacity overflow"),
Err(AllocErr(e)) => self.a.oom(e),
Err(AllocErr(_)) => self.a.oom(),
Ok(()) => { /* yay */ }
}
}
@@ -554,7 +554,7 @@ impl<T, A: Alloc> RawVec<T, A> {
pub fn reserve(&mut self, used_cap: usize, needed_extra_cap: usize) {
match self.try_reserve(used_cap, needed_extra_cap) {
Err(CapacityOverflow) => panic!("capacity overflow"),
Err(AllocErr(e)) => self.a.oom(e),
Err(AllocErr(_)) => self.a.oom(),
Ok(()) => { /* yay */ }
}
}
@@ -669,7 +669,7 @@ impl<T, A: Alloc> RawVec<T, A> {
old_layout,
new_layout) {
Ok(p) => self.ptr = Unique::new_unchecked(p as *mut T),
Err(err) => self.a.oom(err),
Err(_) => self.a.oom(),
}
}
self.cap = amount;

View File

@@ -668,7 +668,7 @@ impl<T: ?Sized> Rc<T> {
let layout = Layout::for_value(&*fake_ptr);
let mem = Global.alloc(layout)
.unwrap_or_else(|e| Global.oom(e));
.unwrap_or_else(|_| Global.oom());
// Initialize the real RcBox
let inner = set_data_ptr(ptr as *mut T, mem) as *mut RcBox<T>;