Don't panic on intrinsics

This commit is contained in:
bjorn3 2018-07-20 14:20:37 +02:00
parent a3b53eb451
commit 0350f2faa9
4 changed files with 18 additions and 2 deletions

View File

@ -1,4 +1,4 @@
#![feature(no_core, lang_items)]
#![feature(no_core, lang_items, intrinsics)]
#![no_core]
#![allow(dead_code)]
@ -68,6 +68,10 @@ unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) {
drop_in_place(to_drop);
}
extern "rust-intrinsic" {
fn copy<T>(src: *const T, dst: *mut T, count: usize);
}
fn abc(a: u8) -> u8 {
a * 2
}
@ -144,3 +148,12 @@ struct DebugTuple(());
fn debug_tuple() -> DebugTuple {
DebugTuple(())
}
unsafe fn use_copy_intrinsic(src: *const u8, dst: *mut u8) {
copy::<u8>(src, dst, 1);
}
/*unsafe fn use_copy_intrinsic_ref(src: *const u8, dst: *mut u8) {
let copy2 = &copy::<u8>;
copy2(src, dst, 1);
}*/

View File

@ -15,6 +15,8 @@ pub fn cton_sig_from_fn_ty<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, fn_ty: Ty<
unimplemented!();
}
Abi::System => bug!("system abi should be selected elsewhere"),
// TODO: properly implement intrinsics
Abi::RustIntrinsic => (CallConv::SystemV, sig.inputs().to_vec(), sig.output()),
_ => unimplemented!("unsupported abi {:?}", sig.abi),
};
Signature {

View File

@ -322,7 +322,7 @@ fn trans_stmt<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, cur_ebb: Ebb, stmt: &
}
},
Rvalue::Cast(CastKind::ClosureFnPointer, operand, ty) => unimplemented!("rval closure_fn_ptr {:?} {:?}", operand, ty),
Rvalue::Cast(CastKind::Unsize, operand, ty) => unimplemented!("rval unsize {:?} {:?}", operand, ty),
Rvalue::Cast(CastKind::Unsize, operand, ty) => return Err(format!("rval unsize {:?} {:?}", operand, ty)),
Rvalue::Discriminant(place) => {
let place = trans_place(fx, place);
let dest_cton_ty = fx.cton_type(dest_layout.ty).unwrap();

View File

@ -14,6 +14,7 @@ pub fn trans_constant<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx>, const_: &Cons
}))
.unwrap(),
};
fx.tcx.sess.warn(&format!("const: {:?}", value));
let ty = fx.monomorphize(&const_.ty);
let layout = fx.layout_of(ty);