mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-14 14:13:58 +00:00
Auto merge of #16763 - regexident:param-accessors, r=Veykril
Add `fn index()` and `fn parent_fn()` accessors for `hir::Param`/`hir::SelfParam` (the PR is motivated by an outside use of the `ra_ap_hir` crate that would benefit from being able to access a `hir::Param`'s/`hir::SelfParam`'s index and parent function)
This commit is contained in:
commit
916914418a
1 changed files with 12 additions and 0 deletions
|
@ -2108,6 +2108,14 @@ pub struct Param {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Param {
|
impl Param {
|
||||||
|
pub fn parent_fn(&self) -> Function {
|
||||||
|
self.func
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn index(&self) -> usize {
|
||||||
|
self.idx
|
||||||
|
}
|
||||||
|
|
||||||
pub fn ty(&self) -> &Type {
|
pub fn ty(&self) -> &Type {
|
||||||
&self.ty
|
&self.ty
|
||||||
}
|
}
|
||||||
|
@ -2172,6 +2180,10 @@ impl SelfParam {
|
||||||
.map(|value| InFile { file_id, value })
|
.map(|value| InFile { file_id, value })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn parent_fn(&self) -> Function {
|
||||||
|
Function::from(self.func)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn ty(&self, db: &dyn HirDatabase) -> Type {
|
pub fn ty(&self, db: &dyn HirDatabase) -> Type {
|
||||||
let substs = TyBuilder::placeholder_subst(db, self.func);
|
let substs = TyBuilder::placeholder_subst(db, self.func);
|
||||||
let callable_sig =
|
let callable_sig =
|
||||||
|
|
Loading…
Reference in a new issue