From 970dbf871795650ecf49b7198d53bdcad9c612af Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 25 Apr 2020 14:23:34 +0200 Subject: Rename StructField -> Field --- crates/ra_hir_ty/src/db.rs | 4 ++-- crates/ra_hir_ty/src/expr.rs | 14 +++++++------- crates/ra_hir_ty/src/infer.rs | 16 ++++++++-------- crates/ra_hir_ty/src/infer/expr.rs | 8 +++----- crates/ra_hir_ty/src/infer/pat.rs | 4 ++-- crates/ra_hir_ty/src/lower.rs | 6 +++--- 6 files changed, 25 insertions(+), 27 deletions(-) (limited to 'crates/ra_hir_ty/src') diff --git a/crates/ra_hir_ty/src/db.rs b/crates/ra_hir_ty/src/db.rs index 9e5dfeab3..fdb49560b 100644 --- a/crates/ra_hir_ty/src/db.rs +++ b/crates/ra_hir_ty/src/db.rs @@ -3,7 +3,7 @@ use std::sync::Arc; use hir_def::{ - db::DefDatabase, DefWithBodyId, GenericDefId, ImplId, LocalStructFieldId, TraitId, TypeParamId, + db::DefDatabase, DefWithBodyId, GenericDefId, ImplId, LocalFieldId, TraitId, TypeParamId, VariantId, }; use ra_arena::map::ArenaMap; @@ -43,7 +43,7 @@ pub trait HirDatabase: DefDatabase + Upcast { fn impl_trait(&self, def: ImplId) -> Option>; #[salsa::invoke(crate::lower::field_types_query)] - fn field_types(&self, var: VariantId) -> Arc>>; + fn field_types(&self, var: VariantId) -> Arc>>; #[salsa::invoke(crate::callable_item_sig)] fn callable_item_signature(&self, def: CallableDef) -> PolyFnSig; diff --git a/crates/ra_hir_ty/src/expr.rs b/crates/ra_hir_ty/src/expr.rs index fd59f4320..f04968e14 100644 --- a/crates/ra_hir_ty/src/expr.rs +++ b/crates/ra_hir_ty/src/expr.rs @@ -24,7 +24,7 @@ pub use hir_def::{ ArithOp, Array, BinaryOp, BindingAnnotation, CmpOp, Expr, ExprId, Literal, LogicOp, MatchArm, Ordering, Pat, PatId, RecordFieldPat, RecordLitField, Statement, UnaryOp, }, - LocalStructFieldId, VariantId, + LocalFieldId, VariantId, }; pub struct ExprValidator<'a, 'b: 'a> { @@ -83,7 +83,7 @@ impl<'a, 'b> ExprValidator<'a, 'b> { id: ExprId, db: &dyn HirDatabase, variant_def: VariantId, - missed_fields: Vec, + missed_fields: Vec, ) { // XXX: only look at source_map if we do have missing fields let (_, source_map) = db.body_with_source_map(self.func.into()); @@ -112,7 +112,7 @@ impl<'a, 'b> ExprValidator<'a, 'b> { id: PatId, db: &dyn HirDatabase, variant_def: VariantId, - missed_fields: Vec, + missed_fields: Vec, ) { // XXX: only look at source_map if we do have missing fields let (_, source_map) = db.body_with_source_map(self.func.into()); @@ -256,7 +256,7 @@ pub fn record_literal_missing_fields( infer: &InferenceResult, id: ExprId, expr: &Expr, -) -> Option<(VariantId, Vec, /*exhaustive*/ bool)> { +) -> Option<(VariantId, Vec, /*exhaustive*/ bool)> { let (fields, exhausitve) = match expr { Expr::RecordLit { path: _, fields, spread } => (fields, spread.is_none()), _ => return None, @@ -270,7 +270,7 @@ pub fn record_literal_missing_fields( let variant_data = variant_data(db.upcast(), variant_def); let specified_fields: FxHashSet<_> = fields.iter().map(|f| &f.name).collect(); - let missed_fields: Vec = variant_data + let missed_fields: Vec = variant_data .fields() .iter() .filter_map(|(f, d)| if specified_fields.contains(&d.name) { None } else { Some(f) }) @@ -286,7 +286,7 @@ pub fn record_pattern_missing_fields( infer: &InferenceResult, id: PatId, pat: &Pat, -) -> Option<(VariantId, Vec, /*exhaustive*/ bool)> { +) -> Option<(VariantId, Vec, /*exhaustive*/ bool)> { let (fields, exhaustive) = match pat { Pat::Record { path: _, args, ellipsis } => (args, !ellipsis), _ => return None, @@ -300,7 +300,7 @@ pub fn record_pattern_missing_fields( let variant_data = variant_data(db.upcast(), variant_def); let specified_fields: FxHashSet<_> = fields.iter().map(|f| &f.name).collect(); - let missed_fields: Vec = variant_data + let missed_fields: Vec = variant_data .fields() .iter() .filter_map(|(f, d)| if specified_fields.contains(&d.name) { None } else { Some(f) }) diff --git a/crates/ra_hir_ty/src/infer.rs b/crates/ra_hir_ty/src/infer.rs index dfb6a435f..6a53be621 100644 --- a/crates/ra_hir_ty/src/infer.rs +++ b/crates/ra_hir_ty/src/infer.rs @@ -28,7 +28,7 @@ use hir_def::{ path::{path, Path}, resolver::{HasResolver, Resolver, TypeNs}, type_ref::{Mutability, TypeRef}, - AdtId, AssocItemId, DefWithBodyId, FunctionId, StructFieldId, TraitId, TypeAliasId, VariantId, + AdtId, AssocItemId, DefWithBodyId, FieldId, FunctionId, TraitId, TypeAliasId, VariantId, }; use hir_expand::{diagnostics::DiagnosticSink, name::name}; use ra_arena::map::ArenaMap; @@ -124,10 +124,10 @@ pub struct InferenceResult { /// For each method call expr, records the function it resolves to. method_resolutions: FxHashMap, /// For each field access expr, records the field it resolves to. - field_resolutions: FxHashMap, + field_resolutions: FxHashMap, /// For each field in record literal, records the field it resolves to. - record_field_resolutions: FxHashMap, - record_field_pat_resolutions: FxHashMap, + record_field_resolutions: FxHashMap, + record_field_pat_resolutions: FxHashMap, /// For each struct literal, records the variant it resolves to. variant_resolutions: FxHashMap, /// For each associated item record what it resolves to @@ -142,13 +142,13 @@ impl InferenceResult { pub fn method_resolution(&self, expr: ExprId) -> Option { self.method_resolutions.get(&expr).copied() } - pub fn field_resolution(&self, expr: ExprId) -> Option { + pub fn field_resolution(&self, expr: ExprId) -> Option { self.field_resolutions.get(&expr).copied() } - pub fn record_field_resolution(&self, expr: ExprId) -> Option { + pub fn record_field_resolution(&self, expr: ExprId) -> Option { self.record_field_resolutions.get(&expr).copied() } - pub fn record_field_pat_resolution(&self, pat: PatId) -> Option { + pub fn record_field_pat_resolution(&self, pat: PatId) -> Option { self.record_field_pat_resolutions.get(&pat).copied() } pub fn variant_resolution_for_expr(&self, id: ExprId) -> Option { @@ -249,7 +249,7 @@ impl<'a> InferenceContext<'a> { self.result.method_resolutions.insert(expr, func); } - fn write_field_resolution(&mut self, expr: ExprId, field: StructFieldId) { + fn write_field_resolution(&mut self, expr: ExprId, field: FieldId) { self.result.field_resolutions.insert(expr, field); } diff --git a/crates/ra_hir_ty/src/infer/expr.rs b/crates/ra_hir_ty/src/infer/expr.rs index 1fdb235a0..83f946eee 100644 --- a/crates/ra_hir_ty/src/infer/expr.rs +++ b/crates/ra_hir_ty/src/infer/expr.rs @@ -8,7 +8,7 @@ use hir_def::{ expr::{Array, BinaryOp, Expr, ExprId, Literal, Statement, UnaryOp}, path::{GenericArg, GenericArgs}, resolver::resolver_for_expr, - AdtId, AssocContainerId, Lookup, StructFieldId, + AdtId, AssocContainerId, FieldId, Lookup, }; use hir_expand::name::Name; use ra_syntax::ast::RangeOp; @@ -216,9 +216,7 @@ impl<'a> InferenceContext<'a> { for (field_idx, field) in fields.iter().enumerate() { let field_def = variant_data.as_ref().and_then(|it| match it.field(&field.name) { - Some(local_id) => { - Some(StructFieldId { parent: def_id.unwrap(), local_id }) - } + Some(local_id) => Some(FieldId { parent: def_id.unwrap(), local_id }), None => { self.push_diagnostic(InferenceDiagnostic::NoSuchField { expr: tgt_expr, @@ -257,7 +255,7 @@ impl<'a> InferenceContext<'a> { .and_then(|idx| a_ty.parameters.0.get(idx).cloned()), TypeCtor::Adt(AdtId::StructId(s)) => { self.db.struct_data(s).variant_data.field(name).map(|local_id| { - let field = StructFieldId { parent: s.into(), local_id }; + let field = FieldId { parent: s.into(), local_id }; self.write_field_resolution(tgt_expr, field); self.db.field_types(s.into())[field.local_id] .clone() diff --git a/crates/ra_hir_ty/src/infer/pat.rs b/crates/ra_hir_ty/src/infer/pat.rs index 7c2ad4384..54ec870df 100644 --- a/crates/ra_hir_ty/src/infer/pat.rs +++ b/crates/ra_hir_ty/src/infer/pat.rs @@ -7,7 +7,7 @@ use hir_def::{ expr::{BindingAnnotation, Pat, PatId, RecordFieldPat}, path::Path, type_ref::Mutability, - StructFieldId, + FieldId, }; use hir_expand::name::Name; use test_utils::tested_by; @@ -69,7 +69,7 @@ impl<'a> InferenceContext<'a> { for subpat in subpats { let matching_field = var_data.as_ref().and_then(|it| it.field(&subpat.name)); if let Some(local_id) = matching_field { - let field_def = StructFieldId { parent: def.unwrap(), local_id }; + let field_def = FieldId { parent: def.unwrap(), local_id }; self.result.record_field_pat_resolutions.insert(subpat.pat, field_def); } diff --git a/crates/ra_hir_ty/src/lower.rs b/crates/ra_hir_ty/src/lower.rs index c2812e178..b57214296 100644 --- a/crates/ra_hir_ty/src/lower.rs +++ b/crates/ra_hir_ty/src/lower.rs @@ -18,8 +18,8 @@ use hir_def::{ resolver::{HasResolver, Resolver, TypeNs}, type_ref::{TypeBound, TypeRef}, AdtId, AssocContainerId, ConstId, EnumId, EnumVariantId, FunctionId, GenericDefId, HasModule, - ImplId, LocalStructFieldId, Lookup, StaticId, StructId, TraitId, TypeAliasId, TypeParamId, - UnionId, VariantId, + ImplId, LocalFieldId, Lookup, StaticId, StructId, TraitId, TypeAliasId, TypeParamId, UnionId, + VariantId, }; use ra_arena::map::ArenaMap; use ra_db::CrateId; @@ -682,7 +682,7 @@ pub fn callable_item_sig(db: &dyn HirDatabase, def: CallableDef) -> PolyFnSig { pub(crate) fn field_types_query( db: &dyn HirDatabase, variant_id: VariantId, -) -> Arc>> { +) -> Arc>> { let var_data = variant_data(db.upcast(), variant_id); let (resolver, def): (_, GenericDefId) = match variant_id { VariantId::StructId(it) => (it.resolver(db.upcast()), it.into()), -- cgit v1.2.3