Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit f972adc

Browse files
committed
fix: comletion detail shows {unknown} for impl Trait in return position
1 parent 66c232d commit f972adc

File tree

2 files changed

+42
-3
lines changed

2 files changed

+42
-3
lines changed

crates/hir/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1358,9 +1358,9 @@ impl Function {
13581358
/// Get this function's return type
13591359
pub fn ret_type(self, db: &dyn HirDatabase) -> Type {
13601360
let resolver = self.id.resolver(db.upcast());
1361-
let ret_type = &db.function_data(self.id).ret_type;
1362-
let ctx = hir_ty::TyLoweringContext::new(db, &resolver);
1363-
let ty = ctx.lower_ty(ret_type);
1361+
let substs = TyBuilder::placeholder_subst(db, self.id);
1362+
let callable_sig = db.callable_item_signature(self.id.into()).substitute(Interner, &substs);
1363+
let ty = callable_sig.ret().clone();
13641364
Type::new_with_resolver_inner(db, &resolver, ty)
13651365
}
13661366

crates/ide_completion/src/tests/expression.rs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -602,3 +602,42 @@ fn func() {
602602
"#]],
603603
);
604604
}
605+
606+
#[test]
607+
fn detail_impl_trait_in_return_position() {
608+
check_empty(
609+
r"
610+
//- minicore: sized
611+
trait Trait<T> {}
612+
fn foo<U>() -> impl Trait<U> {}
613+
fn main() {
614+
self::$0
615+
}
616+
",
617+
expect![[r"
618+
tt Trait
619+
fn main() fn()
620+
fn foo() fn() -> impl Trait<U>
621+
"]],
622+
);
623+
}
624+
625+
#[test]
626+
fn detail_async_fn() {
627+
// FIXME: #11438
628+
check_empty(
629+
r#"
630+
//- minicore: future, sized
631+
trait Trait<T> {}
632+
async fn foo() -> u8 {}
633+
fn main() {
634+
self::$0
635+
}
636+
"#,
637+
expect![[r"
638+
tt Trait
639+
fn main() fn()
640+
fn foo() async fn() -> impl Future<Output = u8>
641+
"]],
642+
);
643+
}

0 commit comments

Comments
 (0)