@@ -531,13 +531,16 @@ pub fn check_drop_impls(ccx: &CrateCtxt) -> CompileResult {
531
531
fn check_bare_fn < ' a , ' tcx > ( ccx : & CrateCtxt < ' a , ' tcx > ,
532
532
decl : & ' tcx hir:: FnDecl ,
533
533
body : & ' tcx hir:: Block ,
534
- fn_id : ast:: NodeId ) {
534
+ fn_id : ast:: NodeId ,
535
+ span : Span ) {
535
536
let raw_fty = ccx. tcx . lookup_item_type ( ccx. tcx . map . local_def_id ( fn_id) ) . ty ;
536
537
let fn_ty = match raw_fty. sty {
537
538
ty:: TyFnDef ( .., f) => f,
538
539
_ => span_bug ! ( body. span, "check_bare_fn: function type expected" )
539
540
} ;
540
541
542
+ check_abi ( ccx, span, fn_ty. abi ) ;
543
+
541
544
ccx. inherited ( fn_id) . enter ( |inh| {
542
545
// Compute the fty from point of view of inside fn.
543
546
let fn_scope = inh. tcx . region_maps . call_site_extent ( fn_id, body. id ) ;
@@ -561,6 +564,13 @@ fn check_bare_fn<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
561
564
} ) ;
562
565
}
563
566
567
+ fn check_abi < ' a , ' tcx > ( ccx : & CrateCtxt < ' a , ' tcx > , span : Span , abi : Abi ) {
568
+ if !ccx. tcx . sess . target . target . is_abi_supported ( abi) {
569
+ struct_span_err ! ( ccx. tcx. sess, span, E0570 ,
570
+ "The ABI `{}` is not supported for the current target" , abi) . emit ( )
571
+ }
572
+ }
573
+
564
574
struct GatherLocalsVisitor < ' a , ' gcx : ' a +' tcx , ' tcx : ' a > {
565
575
fcx : & ' a FnCtxt < ' a , ' gcx , ' tcx >
566
576
}
@@ -767,6 +777,8 @@ pub fn check_item_type<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>, it: &'tcx hir::Item) {
767
777
check_bounds_are_used ( ccx, generics, pty_ty) ;
768
778
}
769
779
hir:: ItemForeignMod ( ref m) => {
780
+ check_abi ( ccx, it. span , m. abi ) ;
781
+
770
782
if m. abi == Abi :: RustIntrinsic {
771
783
for item in & m. items {
772
784
intrinsic:: check_intrinsic_type ( ccx, item) ;
@@ -804,7 +816,7 @@ pub fn check_item_body<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>, it: &'tcx hir::Item) {
804
816
let _indenter = indenter ( ) ;
805
817
match it. node {
806
818
hir:: ItemFn ( ref decl, .., ref body) => {
807
- check_bare_fn ( ccx, & decl, & body, it. id ) ;
819
+ check_bare_fn ( ccx, & decl, & body, it. id , it . span ) ;
808
820
}
809
821
hir:: ItemImpl ( .., ref impl_items) => {
810
822
debug ! ( "ItemImpl {} with id {}" , it. name, it. id) ;
@@ -815,7 +827,7 @@ pub fn check_item_body<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>, it: &'tcx hir::Item) {
815
827
check_const ( ccx, & expr, impl_item. id )
816
828
}
817
829
hir:: ImplItemKind :: Method ( ref sig, ref body) => {
818
- check_bare_fn ( ccx, & sig. decl , body, impl_item. id ) ;
830
+ check_bare_fn ( ccx, & sig. decl , body, impl_item. id , impl_item . span ) ;
819
831
}
820
832
hir:: ImplItemKind :: Type ( _) => {
821
833
// Nothing to do here.
@@ -830,7 +842,7 @@ pub fn check_item_body<'a,'tcx>(ccx: &CrateCtxt<'a,'tcx>, it: &'tcx hir::Item) {
830
842
check_const ( ccx, & expr, trait_item. id )
831
843
}
832
844
hir:: MethodTraitItem ( ref sig, Some ( ref body) ) => {
833
- check_bare_fn ( ccx, & sig. decl , body, trait_item. id ) ;
845
+ check_bare_fn ( ccx, & sig. decl , body, trait_item. id , trait_item . span ) ;
834
846
}
835
847
hir:: MethodTraitItem ( _, None ) |
836
848
hir:: ConstTraitItem ( _, None ) |
0 commit comments