@@ -135,9 +135,8 @@ pub fn intrinsic_operation_unsafety(tcx: TyCtxt<'_>, intrinsic_id: LocalDefId) -
135135
136136/// Remember to add all intrinsics here, in `compiler/rustc_codegen_llvm/src/intrinsic.rs`,
137137/// and in `library/core/src/intrinsics.rs`.
138- pub fn check_intrinsic_type ( tcx : TyCtxt < ' _ > , it : & hir :: ForeignItem < ' _ > ) {
138+ pub fn check_intrinsic_type ( tcx : TyCtxt < ' _ > , intrinsic_id : LocalDefId , span : Span ) {
139139 let param = |n| Ty :: new_param ( tcx, n, Symbol :: intern ( & format ! ( "P{n}" ) ) ) ;
140- let intrinsic_id = it. owner_id . def_id ;
141140 let intrinsic_name = tcx. item_name ( intrinsic_id. into ( ) ) ;
142141 let name_str = intrinsic_name. as_str ( ) ;
143142
@@ -180,7 +179,7 @@ pub fn check_intrinsic_type(tcx: TyCtxt<'_>, it: &hir::ForeignItem<'_>) {
180179 | "umin" => ( 1 , vec ! [ Ty :: new_mut_ptr( tcx, param( 0 ) ) , param( 0 ) ] , param ( 0 ) ) ,
181180 "fence" | "singlethreadfence" => ( 0 , Vec :: new ( ) , Ty :: new_unit ( tcx) ) ,
182181 op => {
183- tcx. dcx ( ) . emit_err ( UnrecognizedAtomicOperation { span : it . span , op } ) ;
182+ tcx. dcx ( ) . emit_err ( UnrecognizedAtomicOperation { span, op } ) ;
184183 return ;
185184 }
186185 } ;
@@ -466,26 +465,29 @@ pub fn check_intrinsic_type(tcx: TyCtxt<'_>, it: &hir::ForeignItem<'_>) {
466465 }
467466
468467 other => {
469- tcx. dcx ( ) . emit_err ( UnrecognizedIntrinsicFunction { span : it . span , name : other } ) ;
468+ tcx. dcx ( ) . emit_err ( UnrecognizedIntrinsicFunction { span, name : other } ) ;
470469 return ;
471470 }
472471 } ;
473472 ( n_tps, 0 , inputs, output, unsafety)
474473 } ;
475474 let sig = tcx. mk_fn_sig ( inputs, output, false , unsafety, Abi :: RustIntrinsic ) ;
476475 let sig = ty:: Binder :: bind_with_vars ( sig, bound_vars) ;
477- equate_intrinsic_type ( tcx, it . span , intrinsic_id, n_tps, n_lts, 0 , sig)
476+ equate_intrinsic_type ( tcx, span, intrinsic_id, n_tps, n_lts, 0 , sig)
478477}
479478
480479/// Type-check `extern "platform-intrinsic" { ... }` functions.
481- pub fn check_platform_intrinsic_type ( tcx : TyCtxt < ' _ > , it : & hir:: ForeignItem < ' _ > ) {
480+ pub fn check_platform_intrinsic_type (
481+ tcx : TyCtxt < ' _ > ,
482+ intrinsic_id : LocalDefId ,
483+ span : Span ,
484+ name : Symbol ,
485+ ) {
482486 let param = |n| {
483487 let name = Symbol :: intern ( & format ! ( "P{n}" ) ) ;
484488 Ty :: new_param ( tcx, n, name)
485489 } ;
486490
487- let name = it. ident . name ;
488-
489491 let ( n_tps, n_cts, inputs, output) = match name {
490492 sym:: simd_eq | sym:: simd_ne | sym:: simd_lt | sym:: simd_le | sym:: simd_gt | sym:: simd_ge => {
491493 ( 2 , 0 , vec ! [ param( 0 ) , param( 0 ) ] , param ( 1 ) )
@@ -558,12 +560,12 @@ pub fn check_platform_intrinsic_type(tcx: TyCtxt<'_>, it: &hir::ForeignItem<'_>)
558560 sym:: simd_shuffle_generic => ( 2 , 1 , vec ! [ param( 0 ) , param( 0 ) ] , param ( 1 ) ) ,
559561 _ => {
560562 let msg = format ! ( "unrecognized platform-specific intrinsic function: `{name}`" ) ;
561- tcx. dcx ( ) . span_err ( it . span , msg) ;
563+ tcx. dcx ( ) . span_err ( span, msg) ;
562564 return ;
563565 }
564566 } ;
565567
566568 let sig = tcx. mk_fn_sig ( inputs, output, false , hir:: Unsafety :: Unsafe , Abi :: PlatformIntrinsic ) ;
567569 let sig = ty:: Binder :: dummy ( sig) ;
568- equate_intrinsic_type ( tcx, it . span , it . owner_id . def_id , n_tps, 0 , n_cts, sig)
570+ equate_intrinsic_type ( tcx, span, intrinsic_id , n_tps, 0 , n_cts, sig)
569571}
0 commit comments