From 5c720b256f5d73434250072cc65fead746250d87 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 14 Nov 2019 09:58:39 +0300 Subject: Move parse_path to Expander --- crates/ra_hir_def/src/body.rs | 4 ++++ crates/ra_hir_def/src/body/lower.rs | 16 ++++++---------- 2 files changed, 10 insertions(+), 10 deletions(-) (limited to 'crates/ra_hir_def') diff --git a/crates/ra_hir_def/src/body.rs b/crates/ra_hir_def/src/body.rs index 3b262e3bd..afceeb8de 100644 --- a/crates/ra_hir_def/src/body.rs +++ b/crates/ra_hir_def/src/body.rs @@ -59,6 +59,10 @@ impl Expander { Source { file_id: self.current_file_id, ast } } + fn parse_path(&mut self, path: ast::Path) -> Option { + Path::from_src(path, &self.hygiene) + } + fn resolve_path_as_macro(&self, db: &impl DefDatabase2, path: &Path) -> Option { self.crate_def_map.resolve_path(db, self.module.module_id, path).0.get_macros() } diff --git a/crates/ra_hir_def/src/body/lower.rs b/crates/ra_hir_def/src/body/lower.rs index 5c291421a..29c1ec2a1 100644 --- a/crates/ra_hir_def/src/body/lower.rs +++ b/crates/ra_hir_def/src/body/lower.rs @@ -262,7 +262,7 @@ where ast::Expr::PathExpr(e) => { let path = e .path() - .and_then(|path| self.parse_path(path)) + .and_then(|path| self.expander.parse_path(path)) .map(Expr::Path) .unwrap_or(Expr::Missing); self.alloc_expr(path, syntax_ptr) @@ -286,7 +286,7 @@ where self.alloc_expr(Expr::Return { expr }, syntax_ptr) } ast::Expr::RecordLit(e) => { - let path = e.path().and_then(|path| self.parse_path(path)); + let path = e.path().and_then(|path| self.expander.parse_path(path)); let mut field_ptrs = Vec::new(); let record_lit = if let Some(nfl) = e.record_field_list() { let fields = nfl @@ -439,7 +439,7 @@ where self.db.ast_id_map(self.expander.current_file_id).ast_id(&e), ); - if let Some(path) = e.path().and_then(|path| self.parse_path(path)) { + if let Some(path) = e.path().and_then(|path| self.expander.parse_path(path)) { if let Some(def) = self.expander.resolve_path_as_macro(self.db, &path) { let call_id = self.db.intern_macro(MacroCallLoc { def, ast_id }); let file_id = call_id.as_file(MacroFileKind::Expr); @@ -508,7 +508,7 @@ where Pat::Bind { name, mode: annotation, subpat } } ast::Pat::TupleStructPat(p) => { - let path = p.path().and_then(|path| self.parse_path(path)); + let path = p.path().and_then(|path| self.expander.parse_path(path)); let args = p.args().map(|p| self.collect_pat(p)).collect(); Pat::TupleStruct { path, args } } @@ -518,7 +518,7 @@ where Pat::Ref { pat, mutability } } ast::Pat::PathPat(p) => { - let path = p.path().and_then(|path| self.parse_path(path)); + let path = p.path().and_then(|path| self.expander.parse_path(path)); path.map(Pat::Path).unwrap_or(Pat::Missing) } ast::Pat::TuplePat(p) => { @@ -527,7 +527,7 @@ where } ast::Pat::PlaceholderPat(_) => Pat::Wild, ast::Pat::RecordPat(p) => { - let path = p.path().and_then(|path| self.parse_path(path)); + let path = p.path().and_then(|path| self.expander.parse_path(path)); let record_field_pat_list = p.record_field_pat_list().expect("every struct should have a field list"); let mut fields: Vec<_> = record_field_pat_list @@ -568,10 +568,6 @@ where self.missing_pat() } } - - fn parse_path(&mut self, path: ast::Path) -> Option { - Path::from_src(path, &self.expander.hygiene) - } } impl From for BinaryOp { -- cgit v1.2.3