Skip to content

Commit f84b0b3

Browse files
committed
fix ret type in generic
1 parent 987ab1f commit f84b0b3

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

crates/ide_assists/src/handlers/generate_delegate_methods.rs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use hir::{self, HasCrate, HasSource, HirDisplay};
1+
use hir::{self, HasCrate, HasSource};
22
use syntax::ast::{self, make, AstNode, HasGenericParams, HasName, HasVisibility};
33

44
use crate::{
@@ -105,16 +105,7 @@ pub(crate) fn generate_delegate_methods(acc: &mut Assists, ctx: &AssistContext)
105105
arg_list,
106106
);
107107
let body = make::block_expr([], Some(tail_expr));
108-
let ret_type = method.ret_type(ctx.db());
109-
let ret_type = if ret_type.is_unknown() {
110-
// FIXME: we currently can't resolve certain generics, and
111-
// are returning placeholders instead. We should fix our
112-
// type resolution here, so we return fewer placeholders.
113-
Some(make::ret_type(make::ty_placeholder()))
114-
} else {
115-
let ret_type = &ret_type.display(ctx.db()).to_string();
116-
Some(make::ret_type(make::ty(ret_type)))
117-
};
108+
let ret_type = method_source.ret_type();
118109
let is_async = method_source.async_token().is_some();
119110
let f = make::fn_(vis, name, type_params, params, body, ret_type, is_async)
120111
.indent(ast::edit::IndentLevel(1))
@@ -314,7 +305,7 @@ struct Person<T> {
314305
}
315306
316307
impl<T> Person<T> {
317-
$0pub(crate) async fn age<J, 'a>(&'a mut self, ty: T, arg: J) -> _ {
308+
$0pub(crate) async fn age<J, 'a>(&'a mut self, ty: T, arg: J) -> T {
318309
self.age.age(ty, arg)
319310
}
320311
}"#,

0 commit comments

Comments
 (0)