mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
Don't panic on intrinsics
This commit is contained in:
parent
a3b53eb451
commit
0350f2faa9
15
example.rs
15
example.rs
@ -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 = ©::<u8>;
|
||||
copy2(src, dst, 1);
|
||||
}*/
|
||||
|
@ -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 {
|
||||
|
@ -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();
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user