mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-23 19:43:23 +00:00
Rename record_field_pat to record_pat_field
This commit is contained in:
parent
5c336e266f
commit
4d97f5f037
10 changed files with 17 additions and 17 deletions
|
@ -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<Field> {
|
||||
self.imp.resolve_record_field_pat(field)
|
||||
pub fn resolve_record_pat_field(&self, field: &ast::RecordPatField) -> Option<Field> {
|
||||
self.imp.resolve_record_pat_field(field)
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
fn resolve_record_field_pat(&self, field: &ast::RecordPatField) -> Option<Field> {
|
||||
self.analyze(field.syntax()).resolve_record_field_pat(self.db, field)
|
||||
fn resolve_record_pat_field(&self, field: &ast::RecordPatField) -> Option<Field> {
|
||||
self.analyze(field.syntax()).resolve_record_pat_field(self.db, field)
|
||||
}
|
||||
|
||||
fn resolve_macro_call(&self, macro_call: &ast::MacroCall) -> Option<MacroDef> {
|
||||
|
|
|
@ -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<Field> {
|
||||
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())
|
||||
}
|
||||
|
||||
|
|
|
@ -125,7 +125,7 @@ pub struct InferenceResult {
|
|||
field_resolutions: FxHashMap<ExprId, FieldId>,
|
||||
/// For each field in record literal, records the field it resolves to.
|
||||
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.
|
||||
variant_resolutions: FxHashMap<ExprOrPatId, VariantId>,
|
||||
/// 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> {
|
||||
self.record_field_resolutions.get(&expr).copied()
|
||||
}
|
||||
pub fn record_field_pat_resolution(&self, pat: PatId) -> Option<FieldId> {
|
||||
self.record_field_pat_resolutions.get(&pat).copied()
|
||||
pub fn record_pat_field_resolution(&self, pat: PatId) -> Option<FieldId> {
|
||||
self.record_pat_field_resolutions.get(&pat).copied()
|
||||
}
|
||||
pub fn variant_resolution_for_expr(&self, id: ExprId) -> Option<VariantId> {
|
||||
self.variant_resolutions.get(&id.into()).copied()
|
||||
|
|
|
@ -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 =
|
||||
|
|
|
@ -157,9 +157,9 @@ pub fn classify_name(sema: &Semantics<RootDatabase>, 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));
|
||||
}
|
||||
|
|
|
@ -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 } = ();
|
||||
|
|
Loading…
Reference in a new issue