@@ -149,9 +149,9 @@ fn signature_help_for_call(
149
149
}
150
150
// APITs (argument position `impl Trait`s) are inferred as {unknown} as the user is
151
151
// in the middle of entering call arguments.
152
- // In that case, fall back to render definition of the argument .
152
+ // In that case, fall back to render definitions of the respective parameters .
153
153
// This is overly conservative: we do not substitute known type vars
154
- // (see FIXME in tests::impl_trait).
154
+ // (see FIXME in tests::impl_trait) and falling back on any unknowns .
155
155
match ( ty. contains_unknown ( ) , fn_params. as_deref ( ) ) {
156
156
( true , Some ( fn_params) ) => format_to ! ( buf, "{}" , fn_params[ idx] . ty( ) . display( db) ) ,
157
157
_ => format_to ! ( buf, "{}" , ty. display( db) ) ,
@@ -161,12 +161,17 @@ fn signature_help_for_call(
161
161
}
162
162
res. signature . push ( ')' ) ;
163
163
164
+ let mut render = |ret_type : hir:: Type | {
165
+ if !ret_type. is_unit ( ) {
166
+ format_to ! ( res. signature, " -> {}" , ret_type. display( db) ) ;
167
+ }
168
+ } ;
164
169
match callable. kind ( ) {
170
+ hir:: CallableKind :: Function ( func) if callable. return_type ( ) . contains_unknown ( ) => {
171
+ render ( func. ret_type ( db) )
172
+ }
165
173
hir:: CallableKind :: Function ( _) | hir:: CallableKind :: Closure => {
166
- let ret_type = callable. return_type ( ) ;
167
- if !ret_type. is_unit ( ) {
168
- format_to ! ( res. signature, " -> {}" , ret_type. display( db) ) ;
169
- }
174
+ render ( callable. return_type ( ) )
170
175
}
171
176
hir:: CallableKind :: TupleStruct ( _) | hir:: CallableKind :: TupleEnumVariant ( _) => { }
172
177
}
@@ -444,7 +449,7 @@ fn foo<T>() -> T where T: Copy + Display {}
444
449
fn bar() { foo($0); }
445
450
"# ,
446
451
expect ! [ [ r#"
447
- fn foo() -> {unknown}
452
+ fn foo() -> T
448
453
"# ] ] ,
449
454
) ;
450
455
}
0 commit comments