aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-04-18 21:18:57 +0100
committerGitHub <[email protected]>2020-04-18 21:18:57 +0100
commit36840bd6c71eaf18cdf418c92af51c24e547a4a7 (patch)
tree3fd05cafec5a30f98780670cac8402196ed2ff06 /crates/ra_hir
parent7a59cd49ff2bb47fa0844fcf5f1ec44f32523b1b (diff)
parentb79fd82559642f4fe504c0c382b86d57c666be1d (diff)
Merge #4036
4036: Fix a bunch of unresovled references r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_hir')
-rw-r--r--crates/ra_hir/src/semantics.rs4
-rw-r--r--crates/ra_hir/src/source_analyzer.rs11
2 files changed, 15 insertions, 0 deletions
diff --git a/crates/ra_hir/src/semantics.rs b/crates/ra_hir/src/semantics.rs
index 0b477f0e9..5d6edc45c 100644
--- a/crates/ra_hir/src/semantics.rs
+++ b/crates/ra_hir/src/semantics.rs
@@ -195,6 +195,10 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> {
195 self.analyze(field.syntax()).resolve_record_field(self.db, field) 195 self.analyze(field.syntax()).resolve_record_field(self.db, field)
196 } 196 }
197 197
198 pub fn resolve_record_field_pat(&self, field: &ast::RecordFieldPat) -> Option<StructField> {
199 self.analyze(field.syntax()).resolve_record_field_pat(self.db, field)
200 }
201
198 pub fn resolve_macro_call(&self, macro_call: &ast::MacroCall) -> Option<MacroDef> { 202 pub fn resolve_macro_call(&self, macro_call: &ast::MacroCall) -> Option<MacroDef> {
199 let sa = self.analyze(macro_call.syntax()); 203 let sa = self.analyze(macro_call.syntax());
200 let macro_call = self.find_file(macro_call.syntax().clone()).with_value(macro_call); 204 let macro_call = self.find_file(macro_call.syntax().clone()).with_value(macro_call);
diff --git a/crates/ra_hir/src/source_analyzer.rs b/crates/ra_hir/src/source_analyzer.rs
index 23af400b8..0ed6d0958 100644
--- a/crates/ra_hir/src/source_analyzer.rs
+++ b/crates/ra_hir/src/source_analyzer.rs
@@ -95,6 +95,7 @@ impl SourceAnalyzer {
95 } 95 }
96 96
97 fn pat_id(&self, pat: &ast::Pat) -> Option<PatId> { 97 fn pat_id(&self, pat: &ast::Pat) -> Option<PatId> {
98 // FIXME: macros, see `expr_id`
98 let src = InFile { file_id: self.file_id, value: pat }; 99 let src = InFile { file_id: self.file_id, value: pat };
99 self.body_source_map.as_ref()?.node_pat(src) 100 self.body_source_map.as_ref()?.node_pat(src)
100 } 101 }
@@ -167,6 +168,16 @@ impl SourceAnalyzer {
167 Some((struct_field.into(), local)) 168 Some((struct_field.into(), local))
168 } 169 }
169 170
171 pub(crate) fn resolve_record_field_pat(
172 &self,
173 _db: &dyn HirDatabase,
174 field: &ast::RecordFieldPat,
175 ) -> Option<StructField> {
176 let pat_id = self.pat_id(&field.pat()?)?;
177 let struct_field = self.infer.as_ref()?.record_field_pat_resolution(pat_id)?;
178 Some(struct_field.into())
179 }
180
170 pub(crate) fn resolve_macro_call( 181 pub(crate) fn resolve_macro_call(
171 &self, 182 &self,
172 db: &dyn HirDatabase, 183 db: &dyn HirDatabase,