11use std:: cell:: LazyCell ;
22use std:: ops:: ControlFlow ;
33
4- use rustc_abi:: FieldIdx ;
4+ use rustc_abi:: { ExternAbi , FieldIdx } ;
55use rustc_attr_data_structures:: ReprAttr :: ReprPacked ;
66use rustc_attr_data_structures:: { AttributeKind , find_attr} ;
77use rustc_data_structures:: unord:: { UnordMap , UnordSet } ;
@@ -13,7 +13,6 @@ use rustc_infer::infer::{RegionVariableOrigin, TyCtxtInferExt};
1313use rustc_infer:: traits:: { Obligation , ObligationCauseCode } ;
1414use rustc_lint_defs:: builtin:: {
1515 REPR_TRANSPARENT_EXTERNAL_PRIVATE_FIELDS , UNSUPPORTED_CALLING_CONVENTIONS ,
16- UNSUPPORTED_FN_PTR_CALLING_CONVENTIONS ,
1716} ;
1817use rustc_middle:: hir:: nested_filter;
1918use rustc_middle:: middle:: resolve_bound_vars:: ResolvedArg ;
@@ -71,30 +70,6 @@ pub fn check_abi(tcx: TyCtxt<'_>, hir_id: hir::HirId, span: Span, abi: ExternAbi
7170 }
7271}
7372
74- pub fn check_abi_fn_ptr ( tcx : TyCtxt < ' _ > , hir_id : hir:: HirId , span : Span , abi : ExternAbi ) {
75- // This is always an FCW, even for `AbiMapping::Invalid`, since we started linting later than
76- // in `check_abi` above.
77- match AbiMap :: from_target ( & tcx. sess . target ) . canonize_abi ( abi, false ) {
78- AbiMapping :: Direct ( ..) => ( ) ,
79- // This is not a redundant match arm: these ABIs started linting after introducing
80- // UNSUPPORTED_FN_PTR_CALLING_CONVENTIONS already existed and we want to
81- // avoid expanding the scope of that lint so it can move to a hard error sooner.
82- AbiMapping :: Deprecated ( ..) => {
83- tcx. node_span_lint ( UNSUPPORTED_CALLING_CONVENTIONS , hir_id, span, |lint| {
84- lint. primary_message ( "use of calling convention not supported on this target" ) ;
85- add_abi_diag_help ( abi, lint) ;
86- } ) ;
87- }
88- AbiMapping :: Invalid => {
89- tcx. node_span_lint ( UNSUPPORTED_FN_PTR_CALLING_CONVENTIONS , hir_id, span, |lint| {
90- lint. primary_message ( format ! (
91- "the calling convention {abi} is not supported on this target"
92- ) ) ;
93- } ) ;
94- }
95- }
96- }
97-
9873pub fn check_custom_abi ( tcx : TyCtxt < ' _ > , def_id : LocalDefId , fn_sig : FnSig < ' _ > , fn_sig_span : Span ) {
9974 if fn_sig. abi == ExternAbi :: Custom {
10075 // Function definitions that use `extern "custom"` must be naked functions.
@@ -862,6 +837,7 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) {
862837 let hir:: ItemKind :: ForeignMod { abi, items } = it. kind else {
863838 return ;
864839 } ;
840+
865841 check_abi ( tcx, it. hir_id ( ) , it. span , abi) ;
866842
867843 for item in items {
0 commit comments