mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 05:23:24 +00:00
Add Function::fn_ptr_type(…)
for obtaining name-erased function type
This commit is contained in:
parent
b32f181f47
commit
7b75f1113c
1 changed files with 8 additions and 0 deletions
|
@ -1884,6 +1884,14 @@ impl Function {
|
||||||
Type::from_value_def(db, self.id)
|
Type::from_value_def(db, self.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn fn_ptr_type(self, db: &dyn HirDatabase) -> Type {
|
||||||
|
let resolver = self.id.resolver(db.upcast());
|
||||||
|
let substs = TyBuilder::placeholder_subst(db, self.id);
|
||||||
|
let callable_sig = db.callable_item_signature(self.id.into()).substitute(Interner, &substs);
|
||||||
|
let ty = TyKind::Function(callable_sig.to_fn_ptr()).intern(Interner);
|
||||||
|
Type::new_with_resolver_inner(db, &resolver, ty)
|
||||||
|
}
|
||||||
|
|
||||||
/// Get this function's return type
|
/// Get this function's return type
|
||||||
pub fn ret_type(self, db: &dyn HirDatabase) -> Type {
|
pub fn ret_type(self, db: &dyn HirDatabase) -> Type {
|
||||||
let resolver = self.id.resolver(db.upcast());
|
let resolver = self.id.resolver(db.upcast());
|
||||||
|
|
Loading…
Reference in a new issue