Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit ecda464

Browse files
committed
Auto merge of rust-lang#16705 - regexident:resolve-callable-exprs, r=Veykril
Add public function for resolving callable AST exprs to their HIR equivalents (the PR is motivated by an outside use of the `ra_ap_hir` crate that would benefit from being able to walk a `hir::Function`'s AST, resolving callable exprs within to their HIR equivalents)
2 parents a6606d1 + ed34978 commit ecda464

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

crates/hir/src/semantics.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,6 +1120,10 @@ impl<'db> SemanticsImpl<'db> {
11201120
self.analyze(pat.syntax())?.binding_mode_of_pat(self.db, pat)
11211121
}
11221122

1123+
pub fn resolve_expr_as_callable(&self, call: &ast::Expr) -> Option<Callable> {
1124+
self.analyze(call.syntax())?.resolve_expr_as_callable(self.db, call)
1125+
}
1126+
11231127
pub fn resolve_method_call(&self, call: &ast::MethodCallExpr) -> Option<Function> {
11241128
self.analyze(call.syntax())?.resolve_method_call(self.db, call)
11251129
}

crates/hir/src/source_analyzer.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,14 @@ impl SourceAnalyzer {
303303
}
304304
}
305305

306+
pub(crate) fn resolve_expr_as_callable(
307+
&self,
308+
db: &dyn HirDatabase,
309+
call: &ast::Expr,
310+
) -> Option<Callable> {
311+
self.type_of_expr(db, &call.clone())?.0.as_callable(db)
312+
}
313+
306314
pub(crate) fn resolve_field(
307315
&self,
308316
db: &dyn HirDatabase,

0 commit comments

Comments
 (0)