fix: comletion detail shows {unknown} for impl Trait in return position

This commit is contained in:
iDawer 2022-04-12 20:40:31 +05:00
parent 66c232d03b
commit f972adc201
2 changed files with 42 additions and 3 deletions

View File

@ -1358,9 +1358,9 @@ pub fn name(self, db: &dyn HirDatabase) -> Name {
/// Get this function's return type
pub fn ret_type(self, db: &dyn HirDatabase) -> Type {
let resolver = self.id.resolver(db.upcast());
let ret_type = &db.function_data(self.id).ret_type;
let ctx = hir_ty::TyLoweringContext::new(db, &resolver);
let ty = ctx.lower_ty(ret_type);
let substs = TyBuilder::placeholder_subst(db, self.id);
let callable_sig = db.callable_item_signature(self.id.into()).substitute(Interner, &substs);
let ty = callable_sig.ret().clone();
Type::new_with_resolver_inner(db, &resolver, ty)
}

View File

@ -602,3 +602,42 @@ fn variant fn() -> Enum
"#]],
);
}
#[test]
fn detail_impl_trait_in_return_position() {
check_empty(
r"
//- minicore: sized
trait Trait<T> {}
fn foo<U>() -> impl Trait<U> {}
fn main() {
self::$0
}
",
expect![[r"
tt Trait
fn main() fn()
fn foo() fn() -> impl Trait<U>
"]],
);
}
#[test]
fn detail_async_fn() {
// FIXME: #11438
check_empty(
r#"
//- minicore: future, sized
trait Trait<T> {}
async fn foo() -> u8 {}
fn main() {
self::$0
}
"#,
expect![[r"
tt Trait
fn main() fn()
fn foo() async fn() -> impl Future<Output = u8>
"]],
);
}