Skip to content

Commit

Permalink
Auto merge of #16763 - regexident:param-accessors, r=Veykril
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
bors committed Mar 5, 2024
2 parents 223238d + bf14131 commit 9169144
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions crates/hir/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2108,6 +2108,14 @@ pub struct Param {
}

impl Param {
pub fn parent_fn(&self) -> Function {
self.func
}

pub fn index(&self) -> usize {
self.idx
}

pub fn ty(&self) -> &Type {
&self.ty
}
Expand Down Expand Up @@ -2172,6 +2180,10 @@ impl SelfParam {
.map(|value| InFile { file_id, value })
}

pub fn parent_fn(&self) -> Function {
Function::from(self.func)
}

pub fn ty(&self, db: &dyn HirDatabase) -> Type {
let substs = TyBuilder::placeholder_subst(db, self.func);
let callable_sig =
Expand Down

0 comments on commit 9169144

Please sign in to comment.