diff options
Diffstat (limited to 'crates/ra_hir/src/source_analyzer.rs')
-rw-r--r-- | crates/ra_hir/src/source_analyzer.rs | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/crates/ra_hir/src/source_analyzer.rs b/crates/ra_hir/src/source_analyzer.rs index 59a3a17d2..74d64c97d 100644 --- a/crates/ra_hir/src/source_analyzer.rs +++ b/crates/ra_hir/src/source_analyzer.rs | |||
@@ -14,7 +14,7 @@ use hir_def::{ | |||
14 | }, | 14 | }, |
15 | expr::{ExprId, Pat, PatId}, | 15 | expr::{ExprId, Pat, PatId}, |
16 | resolver::{resolver_for_scope, Resolver, TypeNs, ValueNs}, | 16 | resolver::{resolver_for_scope, Resolver, TypeNs, ValueNs}, |
17 | AsMacroCall, DefWithBodyId, LocalStructFieldId, StructFieldId, VariantId, | 17 | AsMacroCall, DefWithBodyId, FieldId, LocalFieldId, VariantId, |
18 | }; | 18 | }; |
19 | use hir_expand::{hygiene::Hygiene, name::AsName, HirFileId, InFile}; | 19 | use hir_expand::{hygiene::Hygiene, name::AsName, HirFileId, InFile}; |
20 | use hir_ty::{ | 20 | use hir_ty::{ |
@@ -27,8 +27,8 @@ use ra_syntax::{ | |||
27 | }; | 27 | }; |
28 | 28 | ||
29 | use crate::{ | 29 | use crate::{ |
30 | db::HirDatabase, semantics::PathResolution, Adt, Const, EnumVariant, Function, Local, MacroDef, | 30 | db::HirDatabase, semantics::PathResolution, Adt, Const, EnumVariant, Field, Function, Local, |
31 | ModPath, ModuleDef, Path, PathKind, Static, Struct, StructField, Trait, Type, TypeAlias, | 31 | MacroDef, ModPath, ModuleDef, Path, PathKind, Static, Struct, Trait, Type, TypeAlias, |
32 | TypeParam, | 32 | TypeParam, |
33 | }; | 33 | }; |
34 | use ra_db::CrateId; | 34 | use ra_db::CrateId; |
@@ -140,7 +140,7 @@ impl SourceAnalyzer { | |||
140 | &self, | 140 | &self, |
141 | db: &dyn HirDatabase, | 141 | db: &dyn HirDatabase, |
142 | field: &ast::FieldExpr, | 142 | field: &ast::FieldExpr, |
143 | ) -> Option<StructField> { | 143 | ) -> Option<Field> { |
144 | let expr_id = self.expr_id(db, &field.clone().into())?; | 144 | let expr_id = self.expr_id(db, &field.clone().into())?; |
145 | self.infer.as_ref()?.field_resolution(expr_id).map(|it| it.into()) | 145 | self.infer.as_ref()?.field_resolution(expr_id).map(|it| it.into()) |
146 | } | 146 | } |
@@ -149,7 +149,7 @@ impl SourceAnalyzer { | |||
149 | &self, | 149 | &self, |
150 | db: &dyn HirDatabase, | 150 | db: &dyn HirDatabase, |
151 | field: &ast::RecordField, | 151 | field: &ast::RecordField, |
152 | ) -> Option<(StructField, Option<Local>)> { | 152 | ) -> Option<(Field, Option<Local>)> { |
153 | let expr = field.expr()?; | 153 | let expr = field.expr()?; |
154 | let expr_id = self.expr_id(db, &expr)?; | 154 | let expr_id = self.expr_id(db, &expr)?; |
155 | let local = if field.name_ref().is_some() { | 155 | let local = if field.name_ref().is_some() { |
@@ -172,7 +172,7 @@ impl SourceAnalyzer { | |||
172 | &self, | 172 | &self, |
173 | _db: &dyn HirDatabase, | 173 | _db: &dyn HirDatabase, |
174 | field: &ast::RecordFieldPat, | 174 | field: &ast::RecordFieldPat, |
175 | ) -> Option<StructField> { | 175 | ) -> Option<Field> { |
176 | let pat_id = self.pat_id(&field.pat()?)?; | 176 | let pat_id = self.pat_id(&field.pat()?)?; |
177 | let struct_field = self.infer.as_ref()?.record_field_pat_resolution(pat_id)?; | 177 | let struct_field = self.infer.as_ref()?.record_field_pat_resolution(pat_id)?; |
178 | Some(struct_field.into()) | 178 | Some(struct_field.into()) |
@@ -232,7 +232,7 @@ impl SourceAnalyzer { | |||
232 | &self, | 232 | &self, |
233 | db: &dyn HirDatabase, | 233 | db: &dyn HirDatabase, |
234 | literal: &ast::RecordLit, | 234 | literal: &ast::RecordLit, |
235 | ) -> Option<Vec<(StructField, Type)>> { | 235 | ) -> Option<Vec<(Field, Type)>> { |
236 | let krate = self.resolver.krate()?; | 236 | let krate = self.resolver.krate()?; |
237 | let body = self.body.as_ref()?; | 237 | let body = self.body.as_ref()?; |
238 | let infer = self.infer.as_ref()?; | 238 | let infer = self.infer.as_ref()?; |
@@ -253,7 +253,7 @@ impl SourceAnalyzer { | |||
253 | &self, | 253 | &self, |
254 | db: &dyn HirDatabase, | 254 | db: &dyn HirDatabase, |
255 | pattern: &ast::RecordPat, | 255 | pattern: &ast::RecordPat, |
256 | ) -> Option<Vec<(StructField, Type)>> { | 256 | ) -> Option<Vec<(Field, Type)>> { |
257 | let krate = self.resolver.krate()?; | 257 | let krate = self.resolver.krate()?; |
258 | let body = self.body.as_ref()?; | 258 | let body = self.body.as_ref()?; |
259 | let infer = self.infer.as_ref()?; | 259 | let infer = self.infer.as_ref()?; |
@@ -276,14 +276,14 @@ impl SourceAnalyzer { | |||
276 | krate: CrateId, | 276 | krate: CrateId, |
277 | substs: &Substs, | 277 | substs: &Substs, |
278 | variant: VariantId, | 278 | variant: VariantId, |
279 | missing_fields: Vec<LocalStructFieldId>, | 279 | missing_fields: Vec<LocalFieldId>, |
280 | ) -> Vec<(StructField, Type)> { | 280 | ) -> Vec<(Field, Type)> { |
281 | let field_types = db.field_types(variant); | 281 | let field_types = db.field_types(variant); |
282 | 282 | ||
283 | missing_fields | 283 | missing_fields |
284 | .into_iter() | 284 | .into_iter() |
285 | .map(|local_id| { | 285 | .map(|local_id| { |
286 | let field = StructFieldId { parent: variant, local_id }; | 286 | let field = FieldId { parent: variant, local_id }; |
287 | let ty = field_types[local_id].clone().subst(substs); | 287 | let ty = field_types[local_id].clone().subst(substs); |
288 | (field.into(), Type::new_with_resolver_inner(db, krate, &self.resolver, ty)) | 288 | (field.into(), Type::new_with_resolver_inner(db, krate, &self.resolver, ty)) |
289 | }) | 289 | }) |