Rename record_field_pat to record_pat_field

This commit is contained in:
Pavan Kumar Sunkara 2020-09-05 03:06:05 +02:00
parent 5c336e266f
commit 4d97f5f037
10 changed files with 17 additions and 17 deletions

View file

@ -207,8 +207,8 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> {
self.imp.resolve_record_field(field) self.imp.resolve_record_field(field)
} }
pub fn resolve_record_field_pat(&self, field: &ast::RecordPatField) -> Option<Field> { pub fn resolve_record_pat_field(&self, field: &ast::RecordPatField) -> Option<Field> {
self.imp.resolve_record_field_pat(field) self.imp.resolve_record_pat_field(field)
} }
pub fn resolve_macro_call(&self, macro_call: &ast::MacroCall) -> Option<MacroDef> { pub fn resolve_macro_call(&self, macro_call: &ast::MacroCall) -> Option<MacroDef> {
@ -433,8 +433,8 @@ impl<'db> SemanticsImpl<'db> {
self.analyze(field.syntax()).resolve_record_field(self.db, field) self.analyze(field.syntax()).resolve_record_field(self.db, field)
} }
fn resolve_record_field_pat(&self, field: &ast::RecordPatField) -> Option<Field> { fn resolve_record_pat_field(&self, field: &ast::RecordPatField) -> Option<Field> {
self.analyze(field.syntax()).resolve_record_field_pat(self.db, field) self.analyze(field.syntax()).resolve_record_pat_field(self.db, field)
} }
fn resolve_macro_call(&self, macro_call: &ast::MacroCall) -> Option<MacroDef> { fn resolve_macro_call(&self, macro_call: &ast::MacroCall) -> Option<MacroDef> {

View file

@ -179,13 +179,13 @@ impl SourceAnalyzer {
Some((struct_field.into(), local)) Some((struct_field.into(), local))
} }
pub(crate) fn resolve_record_field_pat( pub(crate) fn resolve_record_pat_field(
&self, &self,
_db: &dyn HirDatabase, _db: &dyn HirDatabase,
field: &ast::RecordPatField, field: &ast::RecordPatField,
) -> Option<Field> { ) -> Option<Field> {
let pat_id = self.pat_id(&field.pat()?)?; 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()) Some(struct_field.into())
} }

View file

@ -125,7 +125,7 @@ pub struct InferenceResult {
field_resolutions: FxHashMap<ExprId, FieldId>, field_resolutions: FxHashMap<ExprId, FieldId>,
/// For each field in record literal, records the field it resolves to. /// For each field in record literal, records the field it resolves to.
record_field_resolutions: FxHashMap<ExprId, FieldId>, record_field_resolutions: FxHashMap<ExprId, FieldId>,
record_field_pat_resolutions: FxHashMap<PatId, FieldId>, record_pat_field_resolutions: FxHashMap<PatId, FieldId>,
/// For each struct literal, records the variant it resolves to. /// For each struct literal, records the variant it resolves to.
variant_resolutions: FxHashMap<ExprOrPatId, VariantId>, variant_resolutions: FxHashMap<ExprOrPatId, VariantId>,
/// For each associated item record what it resolves to /// For each associated item record what it resolves to
@ -146,8 +146,8 @@ impl InferenceResult {
pub fn record_field_resolution(&self, expr: ExprId) -> Option<FieldId> { pub fn record_field_resolution(&self, expr: ExprId) -> Option<FieldId> {
self.record_field_resolutions.get(&expr).copied() self.record_field_resolutions.get(&expr).copied()
} }
pub fn record_field_pat_resolution(&self, pat: PatId) -> Option<FieldId> { pub fn record_pat_field_resolution(&self, pat: PatId) -> Option<FieldId> {
self.record_field_pat_resolutions.get(&pat).copied() self.record_pat_field_resolutions.get(&pat).copied()
} }
pub fn variant_resolution_for_expr(&self, id: ExprId) -> Option<VariantId> { pub fn variant_resolution_for_expr(&self, id: ExprId) -> Option<VariantId> {
self.variant_resolutions.get(&id.into()).copied() self.variant_resolutions.get(&id.into()).copied()

View file

@ -70,7 +70,7 @@ impl<'a> InferenceContext<'a> {
let matching_field = var_data.as_ref().and_then(|it| it.field(&subpat.name)); let matching_field = var_data.as_ref().and_then(|it| it.field(&subpat.name));
if let Some(local_id) = matching_field { if let Some(local_id) = matching_field {
let field_def = FieldId { 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); self.result.record_pat_field_resolutions.insert(subpat.pat, field_def);
} }
let expected_ty = let expected_ty =

View file

@ -157,9 +157,9 @@ pub fn classify_name(sema: &Semantics<RootDatabase>, name: &ast::Name) -> Option
ast::IdentPat(it) => { ast::IdentPat(it) => {
let local = sema.to_def(&it)?; let local = sema.to_def(&it)?;
if let Some(record_field_pat) = it.syntax().parent().and_then(ast::RecordPatField::cast) { if let Some(record_pat_field) = it.syntax().parent().and_then(ast::RecordPatField::cast) {
if record_field_pat.name_ref().is_none() { if record_pat_field.name_ref().is_none() {
if let Some(field) = sema.resolve_record_field_pat(&record_field_pat) { if let Some(field) = sema.resolve_record_pat_field(&record_pat_field) {
let field = Definition::Field(field); let field = Definition::Field(field);
return Some(NameClass::FieldShorthand { local, 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(record_pat_field) = ast::RecordPatField::cast(parent.clone()) {
if let Some(field) = sema.resolve_record_field_pat(&record_field_pat) { if let Some(field) = sema.resolve_record_pat_field(&record_pat_field) {
let field = Definition::Field(field); let field = Definition::Field(field);
return Some(NameRefClass::Definition(field)); return Some(NameRefClass::Definition(field));
} }

View file

@ -188,7 +188,7 @@ fn tuple_pat_fields(p: &mut Parser) {
p.expect(T![')']); p.expect(T![')']);
} }
// test record_field_pat_list // test record_pat_field_list
// fn foo() { // fn foo() {
// let S {} = (); // let S {} = ();
// let S { f, ref mut g } = (); // let S { f, ref mut g } = ();
@ -208,7 +208,7 @@ fn record_pat_field_list(p: &mut Parser) {
c => { c => {
let m = p.start(); let m = p.start();
match c { match c {
// test record_field_pat // test record_pat_field
// fn foo() { // fn foo() {
// let S { 0: 1 } = (); // let S { 0: 1 } = ();
// let S { x: 1 } = (); // let S { x: 1 } = ();