Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit c3386db

Browse files
committedAug 1, 2018
Use debug_assert! instead of assert! where possible
1 parent 11f812a commit c3386db

File tree

160 files changed

+441
-437
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

160 files changed

+441
-437
lines changed
 

‎src/libarena/lib.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,8 @@ impl<T> TypedArena<T> {
166166
where
167167
T: Copy,
168168
{
169-
assert!(mem::size_of::<T>() != 0);
170-
assert!(slice.len() != 0);
169+
debug_assert!(mem::size_of::<T>() != 0);
170+
debug_assert!(slice.len() != 0);
171171

172172
let available_capacity_bytes = self.end.get() as usize - self.ptr.get() as usize;
173173
let at_least_bytes = slice.len() * mem::size_of::<T>();
@@ -318,7 +318,7 @@ impl DroplessArena {
318318
fn align(&self, align: usize) {
319319
let final_address = ((self.ptr.get() as usize) + align - 1) & !(align - 1);
320320
self.ptr.set(final_address as *mut u8);
321-
assert!(self.ptr <= self.end);
321+
debug_assert!(self.ptr <= self.end);
322322
}
323323

324324
#[inline(never)]
@@ -357,7 +357,7 @@ impl DroplessArena {
357357
#[inline]
358358
pub fn alloc_raw(&self, bytes: usize, align: usize) -> &mut [u8] {
359359
unsafe {
360-
assert!(bytes != 0);
360+
debug_assert!(bytes != 0);
361361

362362
self.align(align);
363363

@@ -377,7 +377,7 @@ impl DroplessArena {
377377

378378
#[inline]
379379
pub fn alloc<T>(&self, object: T) -> &mut T {
380-
assert!(!mem::needs_drop::<T>());
380+
debug_assert!(!mem::needs_drop::<T>());
381381

382382
let mem = self.alloc_raw(
383383
mem::size_of::<T>(),
@@ -402,9 +402,9 @@ impl DroplessArena {
402402
where
403403
T: Copy,
404404
{
405-
assert!(!mem::needs_drop::<T>());
406-
assert!(mem::size_of::<T>() != 0);
407-
assert!(slice.len() != 0);
405+
debug_assert!(!mem::needs_drop::<T>());
406+
debug_assert!(mem::size_of::<T>() != 0);
407+
debug_assert!(slice.len() != 0);
408408

409409
let mem = self.alloc_raw(
410410
slice.len() * mem::size_of::<T>(),

‎src/libpanic_unwind/emcc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pub fn payload() -> *mut u8 {
3030
}
3131

3232
pub unsafe fn cleanup(ptr: *mut u8) -> Box<dyn Any + Send> {
33-
assert!(!ptr.is_null());
33+
debug_assert!(!ptr.is_null());
3434
let ex = ptr::read(ptr as *mut _);
3535
__cxa_free_exception(ptr as *mut _);
3636
ex

0 commit comments

Comments
 (0)
Please sign in to comment.