@@ -6,13 +6,11 @@ use rustc_hir as hir;
66use rustc_hir:: def:: DefKind ;
77use rustc_hir:: intravisit:: Visitor ;
88use rustc_hir:: lang_items:: LangItem ;
9- use rustc_hir:: { ImplicitSelfKind , ItemKind , Node } ;
109use rustc_hir_analysis:: check:: fn_maybe_err;
1110use rustc_infer:: infer:: type_variable:: { TypeVariableOrigin , TypeVariableOriginKind } ;
1211use rustc_infer:: infer:: RegionVariableOrigin ;
1312use rustc_middle:: ty:: { self , Ty , TyCtxt } ;
1413use rustc_span:: def_id:: LocalDefId ;
15- use rustc_target:: spec:: abi:: Abi ;
1614use rustc_trait_selection:: traits;
1715use std:: cell:: RefCell ;
1816
@@ -56,41 +54,6 @@ pub(super) fn check_fn<'a, 'tcx>(
5654
5755 fn_maybe_err ( tcx, span, fn_sig. abi ) ;
5856
59- if fn_sig. abi == Abi :: RustCall {
60- let expected_args = if let ImplicitSelfKind :: None = decl. implicit_self { 1 } else { 2 } ;
61-
62- let err = || {
63- let item = match tcx. hir ( ) . get ( fn_id) {
64- Node :: Item ( hir:: Item { kind : ItemKind :: Fn ( header, ..) , .. } ) => Some ( header) ,
65- Node :: ImplItem ( hir:: ImplItem {
66- kind : hir:: ImplItemKind :: Fn ( header, ..) , ..
67- } ) => Some ( header) ,
68- Node :: TraitItem ( hir:: TraitItem {
69- kind : hir:: TraitItemKind :: Fn ( header, ..) ,
70- ..
71- } ) => Some ( header) ,
72- // Closures are RustCall, but they tuple their arguments, so shouldn't be checked
73- Node :: Expr ( hir:: Expr { kind : hir:: ExprKind :: Closure { .. } , .. } ) => None ,
74- node => bug ! ( "Item being checked wasn't a function/closure: {:?}" , node) ,
75- } ;
76-
77- if let Some ( header) = item {
78- tcx. sess . span_err ( header. span , "functions with the \" rust-call\" ABI must take a single non-self argument that is a tuple" ) ;
79- }
80- } ;
81-
82- if fn_sig. inputs ( ) . len ( ) != expected_args {
83- err ( )
84- } else {
85- // FIXME(CraftSpider) Add a check on parameter expansion, so we don't just make the ICE happen later on
86- // This will probably require wide-scale changes to support a TupleKind obligation
87- // We can't resolve this without knowing the type of the param
88- if !matches ! ( fn_sig. inputs( ) [ expected_args - 1 ] . kind( ) , ty:: Tuple ( _) | ty:: Param ( _) ) {
89- err ( )
90- }
91- }
92- }
93-
9457 if body. generator_kind . is_some ( ) && can_be_generator. is_some ( ) {
9558 let yield_ty = fcx
9659 . next_ty_var ( TypeVariableOrigin { kind : TypeVariableOriginKind :: TypeInference , span } ) ;
0 commit comments