aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/ty/infer.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-11-27 13:25:01 +0000
committerAleksey Kladov <[email protected]>2019-11-27 13:25:01 +0000
commit9fa46ff5c67bd1809cc748f6fc0e93d7c9be3fdb (patch)
tree8a6e1440ae2efc86a53aa77f65bdfad6cff00b0d /crates/ra_hir/src/ty/infer.rs
parent17680f6060be1abe8f021538aeff0a95e9c569da (diff)
Use Id for variats
Diffstat (limited to 'crates/ra_hir/src/ty/infer.rs')
-rw-r--r--crates/ra_hir/src/ty/infer.rs18
1 files changed, 9 insertions, 9 deletions
diff --git a/crates/ra_hir/src/ty/infer.rs b/crates/ra_hir/src/ty/infer.rs
index 1eca4883d..59e4e5f36 100644
--- a/crates/ra_hir/src/ty/infer.rs
+++ b/crates/ra_hir/src/ty/infer.rs
@@ -28,7 +28,7 @@ use hir_def::{
28 path::{known, Path}, 28 path::{known, Path},
29 resolver::{HasResolver, Resolver, TypeNs}, 29 resolver::{HasResolver, Resolver, TypeNs},
30 type_ref::{Mutability, TypeRef}, 30 type_ref::{Mutability, TypeRef},
31 AdtId, AssocItemId, DefWithBodyId, FunctionId, StructFieldId, TypeAliasId, 31 AdtId, AssocItemId, DefWithBodyId, FunctionId, StructFieldId, TypeAliasId, VariantId,
32}; 32};
33use hir_expand::{diagnostics::DiagnosticSink, name}; 33use hir_expand::{diagnostics::DiagnosticSink, name};
34use ra_arena::map::ArenaMap; 34use ra_arena::map::ArenaMap;
@@ -41,7 +41,7 @@ use super::{
41 ApplicationTy, InEnvironment, ProjectionTy, Substs, TraitEnvironment, TraitRef, Ty, TypeCtor, 41 ApplicationTy, InEnvironment, ProjectionTy, Substs, TraitEnvironment, TraitRef, Ty, TypeCtor,
42 TypeWalk, Uncertain, 42 TypeWalk, Uncertain,
43}; 43};
44use crate::{db::HirDatabase, ty::infer::diagnostics::InferenceDiagnostic, VariantDef}; 44use crate::{db::HirDatabase, ty::infer::diagnostics::InferenceDiagnostic};
45 45
46macro_rules! ty_app { 46macro_rules! ty_app {
47 ($ctor:pat, $param:pat) => { 47 ($ctor:pat, $param:pat) => {
@@ -124,7 +124,7 @@ pub struct InferenceResult {
124 /// For each field in record literal, records the field it resolves to. 124 /// For each field in record literal, records the field it resolves to.
125 record_field_resolutions: FxHashMap<ExprId, StructFieldId>, 125 record_field_resolutions: FxHashMap<ExprId, StructFieldId>,
126 /// For each struct literal, records the variant it resolves to. 126 /// For each struct literal, records the variant it resolves to.
127 variant_resolutions: FxHashMap<ExprOrPatId, VariantDef>, 127 variant_resolutions: FxHashMap<ExprOrPatId, VariantId>,
128 /// For each associated item record what it resolves to 128 /// For each associated item record what it resolves to
129 assoc_resolutions: FxHashMap<ExprOrPatId, AssocItemId>, 129 assoc_resolutions: FxHashMap<ExprOrPatId, AssocItemId>,
130 diagnostics: Vec<InferenceDiagnostic>, 130 diagnostics: Vec<InferenceDiagnostic>,
@@ -143,10 +143,10 @@ impl InferenceResult {
143 pub fn record_field_resolution(&self, expr: ExprId) -> Option<StructFieldId> { 143 pub fn record_field_resolution(&self, expr: ExprId) -> Option<StructFieldId> {
144 self.record_field_resolutions.get(&expr).copied() 144 self.record_field_resolutions.get(&expr).copied()
145 } 145 }
146 pub fn variant_resolution_for_expr(&self, id: ExprId) -> Option<VariantDef> { 146 pub fn variant_resolution_for_expr(&self, id: ExprId) -> Option<VariantId> {
147 self.variant_resolutions.get(&id.into()).copied() 147 self.variant_resolutions.get(&id.into()).copied()
148 } 148 }
149 pub fn variant_resolution_for_pat(&self, id: PatId) -> Option<VariantDef> { 149 pub fn variant_resolution_for_pat(&self, id: PatId) -> Option<VariantId> {
150 self.variant_resolutions.get(&id.into()).copied() 150 self.variant_resolutions.get(&id.into()).copied()
151 } 151 }
152 pub fn assoc_resolutions_for_expr(&self, id: ExprId) -> Option<AssocItemId> { 152 pub fn assoc_resolutions_for_expr(&self, id: ExprId) -> Option<AssocItemId> {
@@ -248,7 +248,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
248 self.result.field_resolutions.insert(expr, field); 248 self.result.field_resolutions.insert(expr, field);
249 } 249 }
250 250
251 fn write_variant_resolution(&mut self, id: ExprOrPatId, variant: VariantDef) { 251 fn write_variant_resolution(&mut self, id: ExprOrPatId, variant: VariantId) {
252 self.result.variant_resolutions.insert(id, variant); 252 self.result.variant_resolutions.insert(id, variant);
253 } 253 }
254 254
@@ -511,7 +511,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
511 }) 511 })
512 } 512 }
513 513
514 fn resolve_variant(&mut self, path: Option<&Path>) -> (Ty, Option<VariantDef>) { 514 fn resolve_variant(&mut self, path: Option<&Path>) -> (Ty, Option<VariantId>) {
515 let path = match path { 515 let path = match path {
516 Some(path) => path, 516 Some(path) => path,
517 None => return (Ty::Unknown, None), 517 None => return (Ty::Unknown, None),
@@ -524,13 +524,13 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
524 let substs = Ty::substs_from_path(self.db, resolver, path, strukt.into()); 524 let substs = Ty::substs_from_path(self.db, resolver, path, strukt.into());
525 let ty = self.db.ty(strukt.into()); 525 let ty = self.db.ty(strukt.into());
526 let ty = self.insert_type_vars(ty.apply_substs(substs)); 526 let ty = self.insert_type_vars(ty.apply_substs(substs));
527 (ty, Some(VariantDef::Struct(strukt.into()))) 527 (ty, Some(strukt.into()))
528 } 528 }
529 Some(TypeNs::EnumVariantId(var)) => { 529 Some(TypeNs::EnumVariantId(var)) => {
530 let substs = Ty::substs_from_path(self.db, resolver, path, var.into()); 530 let substs = Ty::substs_from_path(self.db, resolver, path, var.into());
531 let ty = self.db.ty(var.parent.into()); 531 let ty = self.db.ty(var.parent.into());
532 let ty = self.insert_type_vars(ty.apply_substs(substs)); 532 let ty = self.insert_type_vars(ty.apply_substs(substs));
533 (ty, Some(VariantDef::EnumVariant(var.into()))) 533 (ty, Some(var.into()))
534 } 534 }
535 Some(_) | None => (Ty::Unknown, None), 535 Some(_) | None => (Ty::Unknown, None),
536 } 536 }