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.rs25
1 files changed, 18 insertions, 7 deletions
diff --git a/crates/hir-ty/src/infer.rs b/crates/hir-ty/src/infer.rs
index ad7ec485e9..6df64ceee6 100644
--- a/crates/hir-ty/src/infer.rs
+++ b/crates/hir-ty/src/infer.rs
@@ -349,7 +349,7 @@ pub struct InferenceResult {
/// For each struct literal or pattern, records the variant it resolves to.
variant_resolutions: FxHashMap<ExprOrPatId, VariantId>,
/// For each associated item record what it resolves to
- assoc_resolutions: FxHashMap<ExprOrPatId, AssocItemId>,
+ assoc_resolutions: FxHashMap<ExprOrPatId, (AssocItemId, Option<Substitution>)>,
pub diagnostics: Vec<InferenceDiagnostic>,
pub type_of_expr: ArenaMap<ExprId, Ty>,
/// For each pattern record the type it resolves to.
@@ -379,11 +379,17 @@ impl InferenceResult {
pub fn variant_resolution_for_pat(&self, id: PatId) -> Option<VariantId> {
self.variant_resolutions.get(&id.into()).copied()
}
- pub fn assoc_resolutions_for_expr(&self, id: ExprId) -> Option<AssocItemId> {
- self.assoc_resolutions.get(&id.into()).copied()
+ pub fn assoc_resolutions_for_expr(
+ &self,
+ id: ExprId,
+ ) -> Option<(AssocItemId, Option<Substitution>)> {
+ self.assoc_resolutions.get(&id.into()).cloned()
}
- pub fn assoc_resolutions_for_pat(&self, id: PatId) -> Option<AssocItemId> {
- self.assoc_resolutions.get(&id.into()).copied()
+ pub fn assoc_resolutions_for_pat(
+ &self,
+ id: PatId,
+ ) -> Option<(AssocItemId, Option<Substitution>)> {
+ self.assoc_resolutions.get(&id.into()).cloned()
}
pub fn type_mismatch_for_expr(&self, expr: ExprId) -> Option<&TypeMismatch> {
self.type_mismatches.get(&expr.into())
@@ -647,8 +653,13 @@ impl<'a> InferenceContext<'a> {
self.result.variant_resolutions.insert(id, variant);
}
- fn write_assoc_resolution(&mut self, id: ExprOrPatId, item: AssocItemId) {
- self.result.assoc_resolutions.insert(id, item);
+ fn write_assoc_resolution(
+ &mut self,
+ id: ExprOrPatId,
+ item: AssocItemId,
+ subs: Option<Substitution>,
+ ) {
+ self.result.assoc_resolutions.insert(id, (item, subs));
}
fn write_pat_ty(&mut self, pat: PatId, ty: Ty) {