mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-28 14:03:35 +00:00
fix: comletion detail shows {unknown}
for impl Trait
in return position
This commit is contained in:
parent
66c232d03b
commit
f972adc201
2 changed files with 42 additions and 3 deletions
|
@ -1358,9 +1358,9 @@ impl Function {
|
|||
/// 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)
|
||||
}
|
||||
|
||||
|
|
|
@ -602,3 +602,42 @@ fn func() {
|
|||
"#]],
|
||||
);
|
||||
}
|
||||
|
||||
#[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>
|
||||
"]],
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue