Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-ty/src/infer.rs')
-rw-r--r--crates/hir-ty/src/infer.rs14
1 files changed, 13 insertions, 1 deletions
diff --git a/crates/hir-ty/src/infer.rs b/crates/hir-ty/src/infer.rs
index 4f739dc8ee..d527a4ae29 100644
--- a/crates/hir-ty/src/infer.rs
+++ b/crates/hir-ty/src/infer.rs
@@ -75,7 +75,7 @@ use crate::{
AliasTy, Const, DbInterner, ErrorGuaranteed, GenericArg, GenericArgs, Region,
StoredGenericArgs, StoredTy, StoredTys, Ty, TyKind, Tys,
abi::Safety,
- infer::{InferCtxt, traits::ObligationCause},
+ infer::{InferCtxt, ObligationInspector, traits::ObligationCause},
},
traits::FnTrait,
utils::TargetFeatureIsSafeInTarget,
@@ -94,11 +94,23 @@ pub(crate) use closure::analysis::{CaptureKind, CapturedItem, CapturedItemWithou
/// The entry point of type inference.
fn infer_query(db: &dyn HirDatabase, def: DefWithBodyId) -> InferenceResult {
+ infer_query_with_inspect(db, def, None)
+}
+
+pub fn infer_query_with_inspect<'db>(
+ db: &'db dyn HirDatabase,
+ def: DefWithBodyId,
+ inspect: Option<ObligationInspector<'db>>,
+) -> InferenceResult {
let _p = tracing::info_span!("infer_query").entered();
let resolver = def.resolver(db);
let body = db.body(def);
let mut ctx = InferenceContext::new(db, def, &body, resolver);
+ if let Some(inspect) = inspect {
+ ctx.table.infer_ctxt.attach_obligation_inspector(inspect);
+ }
+
match def {
DefWithBodyId::FunctionId(f) => {
ctx.collect_fn(f);