Skip to content

Commit df0523a

Browse files
committed
Use libc::abort instead of intrinsics::abort
Despite using the `#![feature()]` attribute rustc still warns about it being unstable. Changing it to `libc::abort` gets rid of the annoying message.
1 parent 924ba38 commit df0523a

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

no_std_test/src/main.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
//!
2929
3030
#![feature(start)]
31-
#![feature(core_intrinsics)]
3231
#![feature(alloc_error_handler)]
3332
#![no_std]
3433
extern crate libc;
@@ -48,7 +47,6 @@ extern crate wee_alloc;
4847
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;
4948

5049
use core::fmt::{self, Write};
51-
use core::intrinsics;
5250
use core::panic::PanicInfo;
5351

5452
use secp256k1::ecdh::{self, SharedSecret};
@@ -61,6 +59,10 @@ use serde_cbor::de;
6159
use serde_cbor::ser::SliceWrite;
6260
use serde_cbor::Serializer;
6361

62+
fn abort() -> ! {
63+
unsafe { libc::abort() }
64+
}
65+
6466
struct FakeRng;
6567
impl RngCore for FakeRng {
6668
fn next_u32(&mut self) -> u32 {
@@ -157,7 +159,7 @@ impl Write for Print {
157159
if curr + s.len() > MAX_PRINT {
158160
unsafe {
159161
libc::printf("overflow\n\0".as_ptr() as _);
160-
intrinsics::abort();
162+
abort();
161163
}
162164
}
163165
self.loc += s.len();
@@ -173,11 +175,11 @@ fn panic(info: &PanicInfo) -> ! {
173175
let mut buf = Print::new();
174176
write!(&mut buf, "{}", msg).unwrap();
175177
buf.print();
176-
intrinsics::abort()
178+
abort()
177179
}
178180

179181
#[alloc_error_handler]
180182
fn alloc_error(_layout: Layout) -> ! {
181183
unsafe { libc::printf("alloc shi1\n\0".as_ptr() as _) };
182-
intrinsics::abort()
184+
abort()
183185
}

0 commit comments

Comments
 (0)