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> {
382
382
let def = self . sema. to_def( & it) ;
383
383
( def. map( |def| def. ret_type( self . db) ) , None )
384
384
} ,
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
+ } ,
385
391
ast:: Stmt ( _it) => ( None , None ) ,
386
392
_ => {
387
393
match node. parent( ) {
@@ -911,10 +917,11 @@ fn foo() -> u32 {
911
917
912
918
#[ test]
913
919
fn expected_type_closure_param_return ( ) {
920
+ // FIXME: make this work with `|| $0`
914
921
check_expected_type_and_name (
915
922
r#"
916
923
fn foo() {
917
- bar(|| $0);
924
+ bar(|| a $0);
918
925
}
919
926
920
927
fn bar(f: impl FnOnce() -> u32) {}
You can’t perform that action at this time.
0 commit comments