aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-04-25 13:25:28 +0100
committerGitHub <[email protected]>2020-04-25 13:25:28 +0100
commit05981823bac91ba338110902fd435c6e3166f1d6 (patch)
tree24b14acc3cfb37489c413c0dfba16dbc8b630869 /crates/ra_hir
parent7bc71732300a57fad928393220ecbe5f751cc20f (diff)
parent970dbf871795650ecf49b7198d53bdcad9c612af (diff)
Merge #4135
4135: Rename StructField -> Field r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_hir')
-rw-r--r--crates/ra_hir/src/code_model.rs34
-rw-r--r--crates/ra_hir/src/from_id.rs22
-rw-r--r--crates/ra_hir/src/has_source.rs6
-rw-r--r--crates/ra_hir/src/lib.rs4
-rw-r--r--crates/ra_hir/src/semantics.rs27
-rw-r--r--crates/ra_hir/src/semantics/source_to_def.rs8
-rw-r--r--crates/ra_hir/src/source_analyzer.rs22
7 files changed, 57 insertions, 66 deletions
diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs
index 43f932e20..3f645a1dd 100644
--- a/crates/ra_hir/src/code_model.rs
+++ b/crates/ra_hir/src/code_model.rs
@@ -13,8 +13,8 @@ use hir_def::{
13 resolver::{HasResolver, Resolver}, 13 resolver::{HasResolver, Resolver},
14 type_ref::{Mutability, TypeRef}, 14 type_ref::{Mutability, TypeRef},
15 AdtId, AssocContainerId, ConstId, DefWithBodyId, EnumId, FunctionId, GenericDefId, HasModule, 15 AdtId, AssocContainerId, ConstId, DefWithBodyId, EnumId, FunctionId, GenericDefId, HasModule,
16 ImplId, LocalEnumVariantId, LocalModuleId, LocalStructFieldId, Lookup, ModuleId, StaticId, 16 ImplId, LocalEnumVariantId, LocalFieldId, LocalModuleId, Lookup, ModuleId, StaticId, StructId,
17 StructId, TraitId, TypeAliasId, TypeParamId, UnionId, 17 TraitId, TypeAliasId, TypeParamId, UnionId,
18}; 18};
19use hir_expand::{ 19use hir_expand::{
20 diagnostics::DiagnosticSink, 20 diagnostics::DiagnosticSink,
@@ -294,9 +294,9 @@ impl Module {
294} 294}
295 295
296#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] 296#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
297pub struct StructField { 297pub struct Field {
298 pub(crate) parent: VariantDef, 298 pub(crate) parent: VariantDef,
299 pub(crate) id: LocalStructFieldId, 299 pub(crate) id: LocalFieldId,
300} 300}
301 301
302#[derive(Debug, PartialEq, Eq)] 302#[derive(Debug, PartialEq, Eq)]
@@ -305,7 +305,7 @@ pub enum FieldSource {
305 Pos(ast::TupleFieldDef), 305 Pos(ast::TupleFieldDef),
306} 306}
307 307
308impl StructField { 308impl Field {
309 pub fn name(&self, db: &dyn HirDatabase) -> Name { 309 pub fn name(&self, db: &dyn HirDatabase) -> Name {
310 self.parent.variant_data(db).fields()[self.id].name.clone() 310 self.parent.variant_data(db).fields()[self.id].name.clone()
311 } 311 }
@@ -331,7 +331,7 @@ impl StructField {
331 } 331 }
332} 332}
333 333
334impl HasVisibility for StructField { 334impl HasVisibility for Field {
335 fn visibility(&self, db: &dyn HirDatabase) -> Visibility { 335 fn visibility(&self, db: &dyn HirDatabase) -> Visibility {
336 let variant_data = self.parent.variant_data(db); 336 let variant_data = self.parent.variant_data(db);
337 let visibility = &variant_data.fields()[self.id].visibility; 337 let visibility = &variant_data.fields()[self.id].visibility;
@@ -358,12 +358,12 @@ impl Struct {
358 db.struct_data(self.id).name.clone() 358 db.struct_data(self.id).name.clone()
359 } 359 }
360 360
361 pub fn fields(self, db: &dyn HirDatabase) -> Vec<StructField> { 361 pub fn fields(self, db: &dyn HirDatabase) -> Vec<Field> {
362 db.struct_data(self.id) 362 db.struct_data(self.id)
363 .variant_data 363 .variant_data
364 .fields() 364 .fields()
365 .iter() 365 .iter()
366 .map(|(id, _)| StructField { parent: self.into(), id }) 366 .map(|(id, _)| Field { parent: self.into(), id })
367 .collect() 367 .collect()
368 } 368 }
369 369
@@ -394,12 +394,12 @@ impl Union {
394 Type::from_def(db, self.id.lookup(db.upcast()).container.module(db.upcast()).krate, self.id) 394 Type::from_def(db, self.id.lookup(db.upcast()).container.module(db.upcast()).krate, self.id)
395 } 395 }
396 396
397 pub fn fields(self, db: &dyn HirDatabase) -> Vec<StructField> { 397 pub fn fields(self, db: &dyn HirDatabase) -> Vec<Field> {
398 db.union_data(self.id) 398 db.union_data(self.id)
399 .variant_data 399 .variant_data
400 .fields() 400 .fields()
401 .iter() 401 .iter()
402 .map(|(id, _)| StructField { parent: self.into(), id }) 402 .map(|(id, _)| Field { parent: self.into(), id })
403 .collect() 403 .collect()
404 } 404 }
405 405
@@ -457,11 +457,11 @@ impl EnumVariant {
457 db.enum_data(self.parent.id).variants[self.id].name.clone() 457 db.enum_data(self.parent.id).variants[self.id].name.clone()
458 } 458 }
459 459
460 pub fn fields(self, db: &dyn HirDatabase) -> Vec<StructField> { 460 pub fn fields(self, db: &dyn HirDatabase) -> Vec<Field> {
461 self.variant_data(db) 461 self.variant_data(db)
462 .fields() 462 .fields()
463 .iter() 463 .iter()
464 .map(|(id, _)| StructField { parent: self.into(), id }) 464 .map(|(id, _)| Field { parent: self.into(), id })
465 .collect() 465 .collect()
466 } 466 }
467 467
@@ -527,7 +527,7 @@ pub enum VariantDef {
527impl_froms!(VariantDef: Struct, Union, EnumVariant); 527impl_froms!(VariantDef: Struct, Union, EnumVariant);
528 528
529impl VariantDef { 529impl VariantDef {
530 pub fn fields(self, db: &dyn HirDatabase) -> Vec<StructField> { 530 pub fn fields(self, db: &dyn HirDatabase) -> Vec<Field> {
531 match self { 531 match self {
532 VariantDef::Struct(it) => it.fields(db), 532 VariantDef::Struct(it) => it.fields(db),
533 VariantDef::Union(it) => it.fields(db), 533 VariantDef::Union(it) => it.fields(db),
@@ -1148,7 +1148,7 @@ impl Type {
1148 } 1148 }
1149 } 1149 }
1150 1150
1151 pub fn fields(&self, db: &dyn HirDatabase) -> Vec<(StructField, Type)> { 1151 pub fn fields(&self, db: &dyn HirDatabase) -> Vec<(Field, Type)> {
1152 if let Ty::Apply(a_ty) = &self.ty.value { 1152 if let Ty::Apply(a_ty) = &self.ty.value {
1153 if let TypeCtor::Adt(AdtId::StructId(s)) = a_ty.ctor { 1153 if let TypeCtor::Adt(AdtId::StructId(s)) = a_ty.ctor {
1154 let var_def = s.into(); 1154 let var_def = s.into();
@@ -1156,7 +1156,7 @@ impl Type {
1156 .field_types(var_def) 1156 .field_types(var_def)
1157 .iter() 1157 .iter()
1158 .map(|(local_id, ty)| { 1158 .map(|(local_id, ty)| {
1159 let def = StructField { parent: var_def.into(), id: local_id }; 1159 let def = Field { parent: var_def.into(), id: local_id };
1160 let ty = ty.clone().subst(&a_ty.parameters); 1160 let ty = ty.clone().subst(&a_ty.parameters);
1161 (def, self.derived(ty)) 1161 (def, self.derived(ty))
1162 }) 1162 })
@@ -1352,7 +1352,7 @@ impl ScopeDef {
1352#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] 1352#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
1353pub enum AttrDef { 1353pub enum AttrDef {
1354 Module(Module), 1354 Module(Module),
1355 StructField(StructField), 1355 Field(Field),
1356 Adt(Adt), 1356 Adt(Adt),
1357 Function(Function), 1357 Function(Function),
1358 EnumVariant(EnumVariant), 1358 EnumVariant(EnumVariant),
@@ -1365,7 +1365,7 @@ pub enum AttrDef {
1365 1365
1366impl_froms!( 1366impl_froms!(
1367 AttrDef: Module, 1367 AttrDef: Module,
1368 StructField, 1368 Field,
1369 Adt(Struct, Enum, Union), 1369 Adt(Struct, Enum, Union),
1370 EnumVariant, 1370 EnumVariant,
1371 Static, 1371 Static,
diff --git a/crates/ra_hir/src/from_id.rs b/crates/ra_hir/src/from_id.rs
index 62fb52e72..679ae8121 100644
--- a/crates/ra_hir/src/from_id.rs
+++ b/crates/ra_hir/src/from_id.rs
@@ -4,13 +4,13 @@
4//! are splitting the hir. 4//! are splitting the hir.
5 5
6use hir_def::{ 6use hir_def::{
7 expr::PatId, AdtId, AssocItemId, AttrDefId, DefWithBodyId, EnumVariantId, GenericDefId, 7 expr::PatId, AdtId, AssocItemId, AttrDefId, DefWithBodyId, EnumVariantId, FieldId,
8 ModuleDefId, StructFieldId, VariantId, 8 GenericDefId, ModuleDefId, VariantId,
9}; 9};
10 10
11use crate::{ 11use crate::{
12 code_model::ItemInNs, Adt, AssocItem, AttrDef, DefWithBody, EnumVariant, GenericDef, Local, 12 code_model::ItemInNs, Adt, AssocItem, AttrDef, DefWithBody, EnumVariant, Field, GenericDef,
13 MacroDef, ModuleDef, StructField, VariantDef, 13 Local, MacroDef, ModuleDef, VariantDef,
14}; 14};
15 15
16macro_rules! from_id { 16macro_rules! from_id {
@@ -184,15 +184,15 @@ impl From<VariantDef> for VariantId {
184 } 184 }
185} 185}
186 186
187impl From<StructField> for StructFieldId { 187impl From<Field> for FieldId {
188 fn from(def: StructField) -> Self { 188 fn from(def: Field) -> Self {
189 StructFieldId { parent: def.parent.into(), local_id: def.id } 189 FieldId { parent: def.parent.into(), local_id: def.id }
190 } 190 }
191} 191}
192 192
193impl From<StructFieldId> for StructField { 193impl From<FieldId> for Field {
194 fn from(def: StructFieldId) -> Self { 194 fn from(def: FieldId) -> Self {
195 StructField { parent: def.parent.into(), id: def.local_id } 195 Field { parent: def.parent.into(), id: def.local_id }
196 } 196 }
197} 197}
198 198
@@ -200,7 +200,7 @@ impl From<AttrDef> for AttrDefId {
200 fn from(def: AttrDef) -> Self { 200 fn from(def: AttrDef) -> Self {
201 match def { 201 match def {
202 AttrDef::Module(it) => AttrDefId::ModuleId(it.id), 202 AttrDef::Module(it) => AttrDefId::ModuleId(it.id),
203 AttrDef::StructField(it) => AttrDefId::StructFieldId(it.into()), 203 AttrDef::Field(it) => AttrDefId::FieldId(it.into()),
204 AttrDef::Adt(it) => AttrDefId::AdtId(it.into()), 204 AttrDef::Adt(it) => AttrDefId::AdtId(it.into()),
205 AttrDef::Function(it) => AttrDefId::FunctionId(it.id), 205 AttrDef::Function(it) => AttrDefId::FunctionId(it.id),
206 AttrDef::EnumVariant(it) => AttrDefId::EnumVariantId(it.into()), 206 AttrDef::EnumVariant(it) => AttrDefId::EnumVariantId(it.into()),
diff --git a/crates/ra_hir/src/has_source.rs b/crates/ra_hir/src/has_source.rs
index 129764e0a..63b8fd369 100644
--- a/crates/ra_hir/src/has_source.rs
+++ b/crates/ra_hir/src/has_source.rs
@@ -9,8 +9,8 @@ use hir_def::{
9use ra_syntax::ast; 9use ra_syntax::ast;
10 10
11use crate::{ 11use crate::{
12 db::HirDatabase, Const, Enum, EnumVariant, FieldSource, Function, ImplDef, MacroDef, Module, 12 db::HirDatabase, Const, Enum, EnumVariant, Field, FieldSource, Function, ImplDef, MacroDef,
13 Static, Struct, StructField, Trait, TypeAlias, TypeParam, Union, 13 Module, Static, Struct, Trait, TypeAlias, TypeParam, Union,
14}; 14};
15 15
16pub use hir_expand::InFile; 16pub use hir_expand::InFile;
@@ -37,7 +37,7 @@ impl Module {
37 } 37 }
38} 38}
39 39
40impl HasSource for StructField { 40impl HasSource for Field {
41 type Ast = FieldSource; 41 type Ast = FieldSource;
42 fn source(self, db: &dyn HirDatabase) -> InFile<FieldSource> { 42 fn source(self, db: &dyn HirDatabase) -> InFile<FieldSource> {
43 let var = VariantId::from(self.parent); 43 let var = VariantId::from(self.parent);
diff --git a/crates/ra_hir/src/lib.rs b/crates/ra_hir/src/lib.rs
index 5af7e5d6d..312ef3814 100644
--- a/crates/ra_hir/src/lib.rs
+++ b/crates/ra_hir/src/lib.rs
@@ -52,9 +52,9 @@ mod has_source;
52pub use crate::{ 52pub use crate::{
53 code_model::{ 53 code_model::{
54 Adt, AsAssocItem, AssocItem, AssocItemContainer, AttrDef, Const, Crate, CrateDependency, 54 Adt, AsAssocItem, AssocItem, AssocItemContainer, AttrDef, Const, Crate, CrateDependency,
55 DefWithBody, Docs, Enum, EnumVariant, FieldSource, Function, GenericDef, HasAttrs, 55 DefWithBody, Docs, Enum, EnumVariant, Field, FieldSource, Function, GenericDef, HasAttrs,
56 HasVisibility, ImplDef, Local, MacroDef, Module, ModuleDef, ScopeDef, Static, Struct, 56 HasVisibility, ImplDef, Local, MacroDef, Module, ModuleDef, ScopeDef, Static, Struct,
57 StructField, Trait, Type, TypeAlias, TypeParam, Union, VariantDef, Visibility, 57 Trait, Type, TypeAlias, TypeParam, Union, VariantDef, Visibility,
58 }, 58 },
59 has_source::HasSource, 59 has_source::HasSource,
60 semantics::{original_range, PathResolution, Semantics, SemanticsScope}, 60 semantics::{original_range, PathResolution, Semantics, SemanticsScope},
diff --git a/crates/ra_hir/src/semantics.rs b/crates/ra_hir/src/semantics.rs
index e09cf3185..86bfb416c 100644
--- a/crates/ra_hir/src/semantics.rs
+++ b/crates/ra_hir/src/semantics.rs
@@ -23,8 +23,8 @@ use crate::{
23 diagnostics::Diagnostic, 23 diagnostics::Diagnostic,
24 semantics::source_to_def::{ChildContainer, SourceToDefCache, SourceToDefCtx}, 24 semantics::source_to_def::{ChildContainer, SourceToDefCache, SourceToDefCtx},
25 source_analyzer::{resolve_hir_path, SourceAnalyzer}, 25 source_analyzer::{resolve_hir_path, SourceAnalyzer},
26 AssocItem, Function, HirFileId, ImplDef, InFile, Local, MacroDef, Module, ModuleDef, Name, 26 AssocItem, Field, Function, HirFileId, ImplDef, InFile, Local, MacroDef, Module, ModuleDef,
27 Origin, Path, ScopeDef, StructField, Trait, Type, TypeParam, 27 Name, Origin, Path, ScopeDef, Trait, Type, TypeParam,
28}; 28};
29 29
30#[derive(Debug, Clone, PartialEq, Eq)] 30#[derive(Debug, Clone, PartialEq, Eq)]
@@ -184,18 +184,15 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> {
184 self.analyze(call.syntax()).resolve_method_call(self.db, call) 184 self.analyze(call.syntax()).resolve_method_call(self.db, call)
185 } 185 }
186 186
187 pub fn resolve_field(&self, field: &ast::FieldExpr) -> Option<StructField> { 187 pub fn resolve_field(&self, field: &ast::FieldExpr) -> Option<Field> {
188 self.analyze(field.syntax()).resolve_field(self.db, field) 188 self.analyze(field.syntax()).resolve_field(self.db, field)
189 } 189 }
190 190
191 pub fn resolve_record_field( 191 pub fn resolve_record_field(&self, field: &ast::RecordField) -> Option<(Field, Option<Local>)> {
192 &self,
193 field: &ast::RecordField,
194 ) -> Option<(StructField, Option<Local>)> {
195 self.analyze(field.syntax()).resolve_record_field(self.db, field) 192 self.analyze(field.syntax()).resolve_record_field(self.db, field)
196 } 193 }
197 194
198 pub fn resolve_record_field_pat(&self, field: &ast::RecordFieldPat) -> Option<StructField> { 195 pub fn resolve_record_field_pat(&self, field: &ast::RecordFieldPat) -> Option<Field> {
199 self.analyze(field.syntax()).resolve_record_field_pat(self.db, field) 196 self.analyze(field.syntax()).resolve_record_field_pat(self.db, field)
200 } 197 }
201 198
@@ -216,19 +213,13 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> {
216 // FIXME: use this instead? 213 // FIXME: use this instead?
217 // pub fn resolve_name_ref(&self, name_ref: &ast::NameRef) -> Option<???>; 214 // pub fn resolve_name_ref(&self, name_ref: &ast::NameRef) -> Option<???>;
218 215
219 pub fn record_literal_missing_fields( 216 pub fn record_literal_missing_fields(&self, literal: &ast::RecordLit) -> Vec<(Field, Type)> {
220 &self,
221 literal: &ast::RecordLit,
222 ) -> Vec<(StructField, Type)> {
223 self.analyze(literal.syntax()) 217 self.analyze(literal.syntax())
224 .record_literal_missing_fields(self.db, literal) 218 .record_literal_missing_fields(self.db, literal)
225 .unwrap_or_default() 219 .unwrap_or_default()
226 } 220 }
227 221
228 pub fn record_pattern_missing_fields( 222 pub fn record_pattern_missing_fields(&self, pattern: &ast::RecordPat) -> Vec<(Field, Type)> {
229 &self,
230 pattern: &ast::RecordPat,
231 ) -> Vec<(StructField, Type)> {
232 self.analyze(pattern.syntax()) 223 self.analyze(pattern.syntax())
233 .record_pattern_missing_fields(self.db, pattern) 224 .record_pattern_missing_fields(self.db, pattern)
234 .unwrap_or_default() 225 .unwrap_or_default()
@@ -359,8 +350,8 @@ to_def_impls![
359 (crate::Const, ast::ConstDef, const_to_def), 350 (crate::Const, ast::ConstDef, const_to_def),
360 (crate::Static, ast::StaticDef, static_to_def), 351 (crate::Static, ast::StaticDef, static_to_def),
361 (crate::Function, ast::FnDef, fn_to_def), 352 (crate::Function, ast::FnDef, fn_to_def),
362 (crate::StructField, ast::RecordFieldDef, record_field_to_def), 353 (crate::Field, ast::RecordFieldDef, record_field_to_def),
363 (crate::StructField, ast::TupleFieldDef, tuple_field_to_def), 354 (crate::Field, ast::TupleFieldDef, tuple_field_to_def),
364 (crate::EnumVariant, ast::EnumVariant, enum_variant_to_def), 355 (crate::EnumVariant, ast::EnumVariant, enum_variant_to_def),
365 (crate::TypeParam, ast::TypeParam, type_param_to_def), 356 (crate::TypeParam, ast::TypeParam, type_param_to_def),
366 (crate::MacroDef, ast::MacroCall, macro_call_to_def), // this one is dubious, not all calls are macros 357 (crate::MacroDef, ast::MacroCall, macro_call_to_def), // this one is dubious, not all calls are macros
diff --git a/crates/ra_hir/src/semantics/source_to_def.rs b/crates/ra_hir/src/semantics/source_to_def.rs
index 66724919b..6f3b5b2da 100644
--- a/crates/ra_hir/src/semantics/source_to_def.rs
+++ b/crates/ra_hir/src/semantics/source_to_def.rs
@@ -5,8 +5,8 @@ use hir_def::{
5 dyn_map::DynMap, 5 dyn_map::DynMap,
6 expr::PatId, 6 expr::PatId,
7 keys::{self, Key}, 7 keys::{self, Key},
8 ConstId, DefWithBodyId, EnumId, EnumVariantId, FunctionId, GenericDefId, ImplId, ModuleId, 8 ConstId, DefWithBodyId, EnumId, EnumVariantId, FieldId, FunctionId, GenericDefId, ImplId,
9 StaticId, StructFieldId, StructId, TraitId, TypeAliasId, TypeParamId, UnionId, VariantId, 9 ModuleId, StaticId, StructId, TraitId, TypeAliasId, TypeParamId, UnionId, VariantId,
10}; 10};
11use hir_expand::{name::AsName, AstId, MacroDefKind}; 11use hir_expand::{name::AsName, AstId, MacroDefKind};
12use ra_db::FileId; 12use ra_db::FileId;
@@ -97,13 +97,13 @@ impl SourceToDefCtx<'_, '_> {
97 pub(super) fn record_field_to_def( 97 pub(super) fn record_field_to_def(
98 &mut self, 98 &mut self,
99 src: InFile<ast::RecordFieldDef>, 99 src: InFile<ast::RecordFieldDef>,
100 ) -> Option<StructFieldId> { 100 ) -> Option<FieldId> {
101 self.to_def(src, keys::RECORD_FIELD) 101 self.to_def(src, keys::RECORD_FIELD)
102 } 102 }
103 pub(super) fn tuple_field_to_def( 103 pub(super) fn tuple_field_to_def(
104 &mut self, 104 &mut self,
105 src: InFile<ast::TupleFieldDef>, 105 src: InFile<ast::TupleFieldDef>,
106 ) -> Option<StructFieldId> { 106 ) -> Option<FieldId> {
107 self.to_def(src, keys::TUPLE_FIELD) 107 self.to_def(src, keys::TUPLE_FIELD)
108 } 108 }
109 pub(super) fn enum_variant_to_def( 109 pub(super) fn enum_variant_to_def(
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};
19use hir_expand::{hygiene::Hygiene, name::AsName, HirFileId, InFile}; 19use hir_expand::{hygiene::Hygiene, name::AsName, HirFileId, InFile};
20use hir_ty::{ 20use hir_ty::{
@@ -27,8 +27,8 @@ use ra_syntax::{
27}; 27};
28 28
29use crate::{ 29use 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};
34use ra_db::CrateId; 34use 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 })