From 4d97f5f037c1b061215d4b0fb32d48a1b8be836f Mon Sep 17 00:00:00 2001 From: Pavan Kumar Sunkara Date: Sat, 5 Sep 2020 03:06:05 +0200 Subject: [PATCH] Rename record_field_pat to record_pat_field --- crates/hir/src/semantics.rs | 8 ++++---- crates/hir/src/source_analyzer.rs | 4 ++-- crates/hir_ty/src/infer.rs | 6 +++--- crates/hir_ty/src/infer/pat.rs | 2 +- crates/ide_db/src/defs.rs | 10 +++++----- crates/parser/src/grammar/patterns.rs | 4 ++-- ...d_pat_list.rast => 0102_record_pat_field_list.rast} | 0 ...field_pat_list.rs => 0102_record_pat_field_list.rs} | 0 ...ecord_field_pat.rast => 0145_record_pat_field.rast} | 0 ...45_record_field_pat.rs => 0145_record_pat_field.rs} | 0 10 files changed, 17 insertions(+), 17 deletions(-) rename crates/syntax/test_data/parser/inline/ok/{0102_record_field_pat_list.rast => 0102_record_pat_field_list.rast} (100%) rename crates/syntax/test_data/parser/inline/ok/{0102_record_field_pat_list.rs => 0102_record_pat_field_list.rs} (100%) rename crates/syntax/test_data/parser/inline/ok/{0145_record_field_pat.rast => 0145_record_pat_field.rast} (100%) rename crates/syntax/test_data/parser/inline/ok/{0145_record_field_pat.rs => 0145_record_pat_field.rs} (100%) diff --git a/crates/hir/src/semantics.rs b/crates/hir/src/semantics.rs index 1594d4f0ff..0516a05b41 100644 --- a/crates/hir/src/semantics.rs +++ b/crates/hir/src/semantics.rs @@ -207,8 +207,8 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> { self.imp.resolve_record_field(field) } - pub fn resolve_record_field_pat(&self, field: &ast::RecordPatField) -> Option { - self.imp.resolve_record_field_pat(field) + pub fn resolve_record_pat_field(&self, field: &ast::RecordPatField) -> Option { + self.imp.resolve_record_pat_field(field) } pub fn resolve_macro_call(&self, macro_call: &ast::MacroCall) -> Option { @@ -433,8 +433,8 @@ impl<'db> SemanticsImpl<'db> { self.analyze(field.syntax()).resolve_record_field(self.db, field) } - fn resolve_record_field_pat(&self, field: &ast::RecordPatField) -> Option { - self.analyze(field.syntax()).resolve_record_field_pat(self.db, field) + fn resolve_record_pat_field(&self, field: &ast::RecordPatField) -> Option { + self.analyze(field.syntax()).resolve_record_pat_field(self.db, field) } fn resolve_macro_call(&self, macro_call: &ast::MacroCall) -> Option { diff --git a/crates/hir/src/source_analyzer.rs b/crates/hir/src/source_analyzer.rs index 1d13c4f1d3..1aef0f33f5 100644 --- a/crates/hir/src/source_analyzer.rs +++ b/crates/hir/src/source_analyzer.rs @@ -179,13 +179,13 @@ impl SourceAnalyzer { Some((struct_field.into(), local)) } - pub(crate) fn resolve_record_field_pat( + pub(crate) fn resolve_record_pat_field( &self, _db: &dyn HirDatabase, field: &ast::RecordPatField, ) -> Option { let pat_id = self.pat_id(&field.pat()?)?; - let struct_field = self.infer.as_ref()?.record_field_pat_resolution(pat_id)?; + let struct_field = self.infer.as_ref()?.record_pat_field_resolution(pat_id)?; Some(struct_field.into()) } diff --git a/crates/hir_ty/src/infer.rs b/crates/hir_ty/src/infer.rs index 03b00b101c..2b53b82973 100644 --- a/crates/hir_ty/src/infer.rs +++ b/crates/hir_ty/src/infer.rs @@ -125,7 +125,7 @@ pub struct InferenceResult { 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_pat_field_resolutions: FxHashMap, /// For each struct literal, records the variant it resolves to. variant_resolutions: FxHashMap, /// For each associated item record what it resolves to @@ -146,8 +146,8 @@ impl InferenceResult { 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 { - self.record_field_pat_resolutions.get(&pat).copied() + pub fn record_pat_field_resolution(&self, pat: PatId) -> Option { + self.record_pat_field_resolutions.get(&pat).copied() } pub fn variant_resolution_for_expr(&self, id: ExprId) -> Option { self.variant_resolutions.get(&id.into()).copied() diff --git a/crates/hir_ty/src/infer/pat.rs b/crates/hir_ty/src/infer/pat.rs index 4dd4f9802d..dde38bc397 100644 --- a/crates/hir_ty/src/infer/pat.rs +++ b/crates/hir_ty/src/infer/pat.rs @@ -70,7 +70,7 @@ impl<'a> InferenceContext<'a> { let matching_field = var_data.as_ref().and_then(|it| it.field(&subpat.name)); if let Some(local_id) = matching_field { let field_def = FieldId { parent: def.unwrap(), local_id }; - self.result.record_field_pat_resolutions.insert(subpat.pat, field_def); + self.result.record_pat_field_resolutions.insert(subpat.pat, field_def); } let expected_ty = diff --git a/crates/ide_db/src/defs.rs b/crates/ide_db/src/defs.rs index 0d0affc273..f8c7aa491e 100644 --- a/crates/ide_db/src/defs.rs +++ b/crates/ide_db/src/defs.rs @@ -157,9 +157,9 @@ pub fn classify_name(sema: &Semantics, name: &ast::Name) -> Option ast::IdentPat(it) => { let local = sema.to_def(&it)?; - if let Some(record_field_pat) = it.syntax().parent().and_then(ast::RecordPatField::cast) { - if record_field_pat.name_ref().is_none() { - if let Some(field) = sema.resolve_record_field_pat(&record_field_pat) { + if let Some(record_pat_field) = it.syntax().parent().and_then(ast::RecordPatField::cast) { + if record_pat_field.name_ref().is_none() { + if let Some(field) = sema.resolve_record_pat_field(&record_pat_field) { let field = Definition::Field(field); return Some(NameClass::FieldShorthand { local, field }); } @@ -275,8 +275,8 @@ pub fn classify_name_ref( } } - if let Some(record_field_pat) = ast::RecordPatField::cast(parent.clone()) { - if let Some(field) = sema.resolve_record_field_pat(&record_field_pat) { + if let Some(record_pat_field) = ast::RecordPatField::cast(parent.clone()) { + if let Some(field) = sema.resolve_record_pat_field(&record_pat_field) { let field = Definition::Field(field); return Some(NameRefClass::Definition(field)); } diff --git a/crates/parser/src/grammar/patterns.rs b/crates/parser/src/grammar/patterns.rs index 796f206e12..7e7f73deea 100644 --- a/crates/parser/src/grammar/patterns.rs +++ b/crates/parser/src/grammar/patterns.rs @@ -188,7 +188,7 @@ fn tuple_pat_fields(p: &mut Parser) { p.expect(T![')']); } -// test record_field_pat_list +// test record_pat_field_list // fn foo() { // let S {} = (); // let S { f, ref mut g } = (); @@ -208,7 +208,7 @@ fn record_pat_field_list(p: &mut Parser) { c => { let m = p.start(); match c { - // test record_field_pat + // test record_pat_field // fn foo() { // let S { 0: 1 } = (); // let S { x: 1 } = (); diff --git a/crates/syntax/test_data/parser/inline/ok/0102_record_field_pat_list.rast b/crates/syntax/test_data/parser/inline/ok/0102_record_pat_field_list.rast similarity index 100% rename from crates/syntax/test_data/parser/inline/ok/0102_record_field_pat_list.rast rename to crates/syntax/test_data/parser/inline/ok/0102_record_pat_field_list.rast diff --git a/crates/syntax/test_data/parser/inline/ok/0102_record_field_pat_list.rs b/crates/syntax/test_data/parser/inline/ok/0102_record_pat_field_list.rs similarity index 100% rename from crates/syntax/test_data/parser/inline/ok/0102_record_field_pat_list.rs rename to crates/syntax/test_data/parser/inline/ok/0102_record_pat_field_list.rs diff --git a/crates/syntax/test_data/parser/inline/ok/0145_record_field_pat.rast b/crates/syntax/test_data/parser/inline/ok/0145_record_pat_field.rast similarity index 100% rename from crates/syntax/test_data/parser/inline/ok/0145_record_field_pat.rast rename to crates/syntax/test_data/parser/inline/ok/0145_record_pat_field.rast diff --git a/crates/syntax/test_data/parser/inline/ok/0145_record_field_pat.rs b/crates/syntax/test_data/parser/inline/ok/0145_record_pat_field.rs similarity index 100% rename from crates/syntax/test_data/parser/inline/ok/0145_record_field_pat.rs rename to crates/syntax/test_data/parser/inline/ok/0145_record_pat_field.rs