@@ -218,34 +218,18 @@ pub(crate) fn codegen_intrinsic_call<'tcx>(
218218 let intrinsic = fx. tcx . item_name ( instance. def_id ( ) ) ;
219219 let substs = instance. substs ;
220220
221- let target = if let Some ( target) = target {
222- target
223- } else {
224- // Insert non returning intrinsics here
225- match intrinsic {
226- sym:: abort => {
227- fx. bcx . ins ( ) . trap ( TrapCode :: User ( 0 ) ) ;
228- }
229- sym:: transmute => {
230- crate :: base:: codegen_panic ( fx, "Transmuting to uninhabited type." , source_info) ;
231- }
232- _ => unimplemented ! ( "unsupported intrinsic {}" , intrinsic) ,
233- }
234- return ;
235- } ;
236-
237221 if intrinsic. as_str ( ) . starts_with ( "simd_" ) {
238222 self :: simd:: codegen_simd_intrinsic_call (
239223 fx,
240224 intrinsic,
241225 substs,
242226 args,
243227 destination,
244- target,
228+ target. expect ( "target for simd intrinsic" ) ,
245229 source_info. span ,
246230 ) ;
247231 } else if codegen_float_intrinsic_call ( fx, intrinsic, args, destination) {
248- let ret_block = fx. get_block ( target) ;
232+ let ret_block = fx. get_block ( target. expect ( "target for float intrinsic" ) ) ;
249233 fx. bcx . ins ( ) . jump ( ret_block, & [ ] ) ;
250234 } else {
251235 codegen_regular_intrinsic_call (
@@ -255,7 +239,7 @@ pub(crate) fn codegen_intrinsic_call<'tcx>(
255239 substs,
256240 args,
257241 destination,
258- Some ( target) ,
242+ target,
259243 source_info,
260244 ) ;
261245 }
@@ -382,6 +366,10 @@ fn codegen_regular_intrinsic_call<'tcx>(
382366 let usize_layout = fx. layout_of ( fx. tcx . types . usize ) ;
383367
384368 match intrinsic {
369+ sym:: abort => {
370+ fx. bcx . ins ( ) . trap ( TrapCode :: User ( 0 ) ) ;
371+ return ;
372+ }
385373 sym:: likely | sym:: unlikely => {
386374 intrinsic_args ! ( fx, args => ( a) ; intrinsic) ;
387375
@@ -579,6 +567,11 @@ fn codegen_regular_intrinsic_call<'tcx>(
579567 sym:: transmute => {
580568 intrinsic_args ! ( fx, args => ( from) ; intrinsic) ;
581569
570+ if ret. layout ( ) . abi . is_uninhabited ( ) {
571+ crate :: base:: codegen_panic ( fx, "Transmuting to uninhabited type." , source_info) ;
572+ return ;
573+ }
574+
582575 ret. write_cvalue_transmute ( fx, from) ;
583576 }
584577 sym:: write_bytes | sym:: volatile_set_memory => {
0 commit comments