File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed
crates/ide_completion/src Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -382,6 +382,12 @@ impl<'a> CompletionContext<'a> {
382382 let def = self . sema. to_def( & it) ;
383383 ( def. map( |def| def. ret_type( self . db) ) , None )
384384 } ,
385+ ast:: ClosureExpr ( it) => {
386+ let ty = self . sema. type_of_expr( & it. into( ) ) ;
387+ ty. and_then( |ty| ty. as_callable( self . db) )
388+ . map( |c| ( Some ( c. return_type( ) ) , None ) )
389+ . unwrap_or( ( None , None ) )
390+ } ,
385391 ast:: Stmt ( _it) => ( None , None ) ,
386392 _ => {
387393 match node. parent( ) {
@@ -911,10 +917,11 @@ fn foo() -> u32 {
911917
912918 #[ test]
913919 fn expected_type_closure_param_return ( ) {
920+ // FIXME: make this work with `|| $0`
914921 check_expected_type_and_name (
915922 r#"
916923fn foo() {
917- bar(|| $0);
924+ bar(|| a $0);
918925}
919926
920927fn bar(f: impl FnOnce() -> u32) {}
You can’t perform that action at this time.
0 commit comments