Skip to content

Commit d8b5a3e

Browse files
committed
Fix to examples
1 parent e74f6ff commit d8b5a3e

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

example/mini_core.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ pub trait Sized {}
1717
#[lang = "destruct"]
1818
pub trait Destruct {}
1919

20+
#[lang = "tuple_trait"]
21+
pub trait Tuple {}
22+
2023
#[lang = "unsize"]
2124
pub trait Unsize<T: ?Sized> {}
2225

@@ -396,7 +399,7 @@ pub struct PhantomData<T: ?Sized>;
396399

397400
#[lang = "fn_once"]
398401
#[rustc_paren_sugar]
399-
pub trait FnOnce<Args> {
402+
pub trait FnOnce<Args: Tuple> {
400403
#[lang = "fn_once_output"]
401404
type Output;
402405

@@ -405,7 +408,7 @@ pub trait FnOnce<Args> {
405408

406409
#[lang = "fn_mut"]
407410
#[rustc_paren_sugar]
408-
pub trait FnMut<Args>: FnOnce<Args> {
411+
pub trait FnMut<Args: Tuple>: FnOnce<Args> {
409412
extern "rust-call" fn call_mut(&mut self, args: Args) -> Self::Output;
410413
}
411414

@@ -418,8 +421,8 @@ pub fn panic(_msg: &'static str) -> ! {
418421
}
419422
}
420423

421-
#[lang = "panic_no_unwind"]
422-
fn panic_no_unwind() -> ! {
424+
#[lang = "panic_cannot_unwind"]
425+
fn panic_cannot_unwind() -> ! {
423426
unsafe {
424427
libc::puts("Panicking\n\0" as *const str as *const u8);
425428
intrinsics::abort();
@@ -531,16 +534,22 @@ pub mod intrinsics {
531534
use crate::Sized;
532535

533536
extern "rust-intrinsic" {
537+
#[rustc_safe_intrinsic]
534538
pub fn abort() -> !;
539+
#[rustc_safe_intrinsic]
535540
pub fn size_of<T>() -> usize;
536541
pub fn size_of_val<T: ?Sized>(val: *const T) -> usize;
542+
#[rustc_safe_intrinsic]
537543
pub fn min_align_of<T>() -> usize;
538544
pub fn min_align_of_val<T: ?Sized>(val: *const T) -> usize;
539545
pub fn copy<T>(src: *const T, dst: *mut T, count: usize);
540546
pub fn transmute<T, U>(e: T) -> U;
541547
pub fn ctlz_nonzero<T>(x: T) -> T;
548+
#[rustc_safe_intrinsic]
542549
pub fn needs_drop<T: ?Sized>() -> bool;
550+
#[rustc_safe_intrinsic]
543551
pub fn bitreverse<T>(x: T) -> T;
552+
#[rustc_safe_intrinsic]
544553
pub fn bswap<T>(x: T) -> T;
545554
pub fn write_bytes<T>(dst: *mut T, val: u8, count: usize);
546555
pub fn unreachable() -> !;

example/mini_core_hello_world.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ fn start<T: Termination + 'static>(
8585
main: fn() -> T,
8686
argc: isize,
8787
argv: *const *const u8,
88+
_sigpipe: u8,
8889
) -> isize {
8990
if argc == 3 {
9091
unsafe { puts(*argv); }

src/common.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ impl<'gcc, 'tcx> ConstMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
115115
self.const_uint(self.usize_type, i)
116116
}
117117

118-
fn const_u8(&self, _i: u8) -> RValue<'gcc> {
119-
unimplemented!();
118+
fn const_u8(&self, i: u8) -> RValue<'gcc> {
119+
self.const_uint(self.type_u8(), i as u64)
120120
}
121121

122122
fn const_real(&self, typ: Type<'gcc>, val: f64) -> RValue<'gcc> {

0 commit comments

Comments
 (0)