Skip to content

Commit 88862e4

Browse files
author
Jorge Aparicio
committed
panic! -> abort
closes #79
1 parent e34a605 commit 88862e4

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/int/udiv.rs

+11-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use core::mem;
1+
use core::{intrinsics, mem};
22
use int::{Int, LargeInt};
33

44
/// Returns `n / d`
@@ -7,7 +7,11 @@ use int::{Int, LargeInt};
77
pub extern "C" fn __udivsi3(n: u32, d: u32) -> u32 {
88
// Special cases
99
if d == 0 {
10-
panic!("Division by zero");
10+
// NOTE This should be unreachable in safe Rust because the program will panic before
11+
// this intrinsic is called
12+
unsafe {
13+
intrinsics::abort()
14+
}
1115
}
1216

1317
if n == 0 {
@@ -129,7 +133,11 @@ pub extern "C" fn __udivmoddi4(n: u64, d: u64, rem: Option<&mut u64>) -> u64 {
129133
// K X
130134
// ---
131135
// 0 0
132-
panic!("Division by zero");
136+
// NOTE This should be unreachable in safe Rust because the program will panic before
137+
// this intrinsic is called
138+
unsafe {
139+
intrinsics::abort()
140+
}
133141
}
134142

135143
if n.low() == 0 {

0 commit comments

Comments
 (0)