Skip to content

Commit 9169144

Browse files
committed
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)
2 parents 223238d + bf14131 commit 9169144

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

crates/hir/src/lib.rs

+12
Original file line numberDiff line numberDiff line change
@@ -2108,6 +2108,14 @@ pub struct Param {
21082108
}
21092109

21102110
impl Param {
2111+
pub fn parent_fn(&self) -> Function {
2112+
self.func
2113+
}
2114+
2115+
pub fn index(&self) -> usize {
2116+
self.idx
2117+
}
2118+
21112119
pub fn ty(&self) -> &Type {
21122120
&self.ty
21132121
}
@@ -2172,6 +2180,10 @@ impl SelfParam {
21722180
.map(|value| InFile { file_id, value })
21732181
}
21742182

2183+
pub fn parent_fn(&self) -> Function {
2184+
Function::from(self.func)
2185+
}
2186+
21752187
pub fn ty(&self, db: &dyn HirDatabase) -> Type {
21762188
let substs = TyBuilder::placeholder_subst(db, self.func);
21772189
let callable_sig =

0 commit comments

Comments
 (0)