diff options
Diffstat (limited to 'crates/ra_hir/src/semantics.rs')
-rw-r--r-- | crates/ra_hir/src/semantics.rs | 27 |
1 files changed, 9 insertions, 18 deletions
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 |