@@ -135,9 +135,8 @@ pub fn intrinsic_operation_unsafety(tcx: TyCtxt<'_>, intrinsic_id: LocalDefId) -
135
135
136
136
/// Remember to add all intrinsics here, in `compiler/rustc_codegen_llvm/src/intrinsic.rs`,
137
137
/// 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 ) {
139
139
let param = |n| Ty :: new_param ( tcx, n, Symbol :: intern ( & format ! ( "P{n}" ) ) ) ;
140
- let intrinsic_id = it. owner_id . def_id ;
141
140
let intrinsic_name = tcx. item_name ( intrinsic_id. into ( ) ) ;
142
141
let name_str = intrinsic_name. as_str ( ) ;
143
142
@@ -180,7 +179,7 @@ pub fn check_intrinsic_type(tcx: TyCtxt<'_>, it: &hir::ForeignItem<'_>) {
180
179
| "umin" => ( 1 , vec ! [ Ty :: new_mut_ptr( tcx, param( 0 ) ) , param( 0 ) ] , param ( 0 ) ) ,
181
180
"fence" | "singlethreadfence" => ( 0 , Vec :: new ( ) , Ty :: new_unit ( tcx) ) ,
182
181
op => {
183
- tcx. dcx ( ) . emit_err ( UnrecognizedAtomicOperation { span : it . span , op } ) ;
182
+ tcx. dcx ( ) . emit_err ( UnrecognizedAtomicOperation { span, op } ) ;
184
183
return ;
185
184
}
186
185
} ;
@@ -466,26 +465,29 @@ pub fn check_intrinsic_type(tcx: TyCtxt<'_>, it: &hir::ForeignItem<'_>) {
466
465
}
467
466
468
467
other => {
469
- tcx. dcx ( ) . emit_err ( UnrecognizedIntrinsicFunction { span : it . span , name : other } ) ;
468
+ tcx. dcx ( ) . emit_err ( UnrecognizedIntrinsicFunction { span, name : other } ) ;
470
469
return ;
471
470
}
472
471
} ;
473
472
( n_tps, 0 , inputs, output, unsafety)
474
473
} ;
475
474
let sig = tcx. mk_fn_sig ( inputs, output, false , unsafety, Abi :: RustIntrinsic ) ;
476
475
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)
478
477
}
479
478
480
479
/// 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
+ ) {
482
486
let param = |n| {
483
487
let name = Symbol :: intern ( & format ! ( "P{n}" ) ) ;
484
488
Ty :: new_param ( tcx, n, name)
485
489
} ;
486
490
487
- let name = it. ident . name ;
488
-
489
491
let ( n_tps, n_cts, inputs, output) = match name {
490
492
sym:: simd_eq | sym:: simd_ne | sym:: simd_lt | sym:: simd_le | sym:: simd_gt | sym:: simd_ge => {
491
493
( 2 , 0 , vec ! [ param( 0 ) , param( 0 ) ] , param ( 1 ) )
@@ -558,12 +560,12 @@ pub fn check_platform_intrinsic_type(tcx: TyCtxt<'_>, it: &hir::ForeignItem<'_>)
558
560
sym:: simd_shuffle_generic => ( 2 , 1 , vec ! [ param( 0 ) , param( 0 ) ] , param ( 1 ) ) ,
559
561
_ => {
560
562
let msg = format ! ( "unrecognized platform-specific intrinsic function: `{name}`" ) ;
561
- tcx. dcx ( ) . span_err ( it . span , msg) ;
563
+ tcx. dcx ( ) . span_err ( span, msg) ;
562
564
return ;
563
565
}
564
566
} ;
565
567
566
568
let sig = tcx. mk_fn_sig ( inputs, output, false , hir:: Unsafety :: Unsafe , Abi :: PlatformIntrinsic ) ;
567
569
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)
569
571
}
0 commit comments