@@ -84,9 +84,9 @@ use crate::db::{DefDatabase, HirDatabase};
8484pub use crate :: {
8585 attrs:: { HasAttrs , Namespace } ,
8686 diagnostics:: {
87- AnyDiagnostic , BreakOutsideOfLoop , InactiveCode , IncorrectCase , InvalidDeriveTarget ,
88- MacroError , MalformedDerive , MismatchedArgCount , MissingFields , MissingMatchArms ,
89- MissingUnsafe , NoSuchField , PrivateAssocItem , PrivateField ,
87+ AnyDiagnostic , BreakOutsideOfLoop , ExpectedFunction , InactiveCode , IncorrectCase ,
88+ InvalidDeriveTarget , MacroError , MalformedDerive , MismatchedArgCount , MissingFields ,
89+ MissingMatchArms , MissingUnsafe , NoSuchField , PrivateAssocItem , PrivateField ,
9090 ReplaceFilterMapNextWithFindMap , TypeMismatch , UnimplementedBuiltinMacro ,
9191 UnresolvedExternCrate , UnresolvedImport , UnresolvedMacroCall , UnresolvedModule ,
9292 UnresolvedProcMacro ,
@@ -1377,8 +1377,8 @@ impl DefWithBody {
13771377 let source_map = Lazy :: new ( || db. body_with_source_map ( self . into ( ) ) . 1 ) ;
13781378 for d in & infer. diagnostics {
13791379 match d {
1380- hir_ty:: InferenceDiagnostic :: NoSuchField { expr } => {
1381- let field = source_map. field_syntax ( * expr) ;
1380+ & hir_ty:: InferenceDiagnostic :: NoSuchField { expr } => {
1381+ let field = source_map. field_syntax ( expr) ;
13821382 acc. push ( NoSuchField { field } . into ( ) )
13831383 }
13841384 & hir_ty:: InferenceDiagnostic :: BreakOutsideOfLoop {
@@ -1391,15 +1391,10 @@ impl DefWithBody {
13911391 . expect ( "break outside of loop in synthetic syntax" ) ;
13921392 acc. push ( BreakOutsideOfLoop { expr, is_break, bad_value_break } . into ( ) )
13931393 }
1394- hir_ty:: InferenceDiagnostic :: MismatchedArgCount { call_expr, expected, found } => {
1395- match source_map. expr_syntax ( * call_expr) {
1394+ & hir_ty:: InferenceDiagnostic :: MismatchedArgCount { call_expr, expected, found } => {
1395+ match source_map. expr_syntax ( call_expr) {
13961396 Ok ( source_ptr) => acc. push (
1397- MismatchedArgCount {
1398- call_expr : source_ptr,
1399- expected : * expected,
1400- found : * found,
1401- }
1402- . into ( ) ,
1397+ MismatchedArgCount { call_expr : source_ptr, expected, found } . into ( ) ,
14031398 ) ,
14041399 Err ( SyntheticSyntax ) => ( ) ,
14051400 }
@@ -1423,6 +1418,18 @@ impl DefWithBody {
14231418 let item = item. into ( ) ;
14241419 acc. push ( PrivateAssocItem { expr_or_pat, item } . into ( ) )
14251420 }
1421+ hir_ty:: InferenceDiagnostic :: ExpectedFunction { call_expr, found } => {
1422+ let call_expr =
1423+ source_map. expr_syntax ( * call_expr) . expect ( "unexpected synthetic" ) ;
1424+
1425+ acc. push (
1426+ ExpectedFunction {
1427+ call : call_expr,
1428+ found : Type :: new ( db, DefWithBodyId :: from ( self ) , found. clone ( ) ) ,
1429+ }
1430+ . into ( ) ,
1431+ )
1432+ }
14261433 }
14271434 }
14281435 for ( pat_or_expr, mismatch) in infer. type_mismatches ( ) {
0 commit comments