File tree Expand file tree Collapse file tree 1 file changed +10
-14
lines changed
compiler/rustc_typeck/src/check Expand file tree Collapse file tree 1 file changed +10
-14
lines changed Original file line number Diff line number Diff line change @@ -525,27 +525,23 @@ fn typeck_with_fallback<'tcx>(
525525 let expected_args = if let ImplicitSelfKind :: None = decl. implicit_self { 1 } else { 2 } ;
526526
527527 let err = || {
528- if let Node :: Item ( item) = tcx. hir ( ) . get ( id) {
529- if let hir :: ItemKind :: Fn ( header , .. ) = & item . kind {
530- tcx . sess . span_err ( header. span , "A function with the \" rust-call \" ABI must take a single non-self argument that is a tuple" )
531- }
528+ let item = tcx. hir ( ) . expect_item ( id) ;
529+
530+ if let hir :: ItemKind :: Fn ( header, .. ) = & item . kind {
531+ tcx . sess . span_err ( header . span , "A function with the \" rust-call \" ABI must take a single non-self argument that is a tuple" )
532532 } else {
533- bug ! ( "Couldn't get span of FnHeader being checked " )
533+ bug ! ( "Item being checked wasn't a function " )
534534 }
535535 } ;
536536
537537 if fn_sig. inputs ( ) . len ( ) != expected_args {
538538 err ( )
539539 } else {
540- match fn_sig. inputs ( ) [ expected_args - 1 ] . kind ( ) {
541- ty:: Tuple ( _) => ( ) ,
542- // FIXME(CraftSpider) Add a check on parameter expansion, so we don't just make the ICE happen later on
543- // This will probably require wide-scale changes to support a TupleKind obligation
544- // We can't resolve this without knowing the type of the param
545- ty:: Param ( _) => ( ) ,
546- _ => {
547- err ( )
548- }
540+ // FIXME(CraftSpider) Add a check on parameter expansion, so we don't just make the ICE happen later on
541+ // This will probably require wide-scale changes to support a TupleKind obligation
542+ // We can't resolve this without knowing the type of the param
543+ if !matches ! ( fn_sig. inputs( ) [ expected_args - 1 ] . kind( ) , ty:: Tuple ( _) | ty:: Param ( _) ) {
544+ err ( )
549545 }
550546 }
551547 }
You can’t perform that action at this time.
0 commit comments