aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/expr/lower.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src/expr/lower.rs')
-rw-r--r--crates/ra_hir/src/expr/lower.rs26
1 files changed, 14 insertions, 12 deletions
diff --git a/crates/ra_hir/src/expr/lower.rs b/crates/ra_hir/src/expr/lower.rs
index 50ea429ea..6463dd65e 100644
--- a/crates/ra_hir/src/expr/lower.rs
+++ b/crates/ra_hir/src/expr/lower.rs
@@ -1,5 +1,10 @@
1//! FIXME: write short doc here 1//! FIXME: write short doc here
2 2
3use hir_def::{path::GenericArgs, type_ref::TypeRef};
4use hir_expand::{
5 hygiene::Hygiene,
6 name::{self, AsName, Name},
7};
3use ra_arena::Arena; 8use ra_arena::Arena;
4use ra_syntax::{ 9use ra_syntax::{
5 ast::{ 10 ast::{
@@ -12,11 +17,8 @@ use test_utils::tested_by;
12 17
13use crate::{ 18use crate::{
14 db::HirDatabase, 19 db::HirDatabase,
15 name::{AsName, Name, SELF_PARAM},
16 path::GenericArgs,
17 ty::primitive::{FloatTy, IntTy, UncertainFloatTy, UncertainIntTy}, 20 ty::primitive::{FloatTy, IntTy, UncertainFloatTy, UncertainIntTy},
18 type_ref::TypeRef, 21 AstId, DefWithBody, Either, HirFileId, MacroCallLoc, MacroFileKind, Mutability, Path, Resolver,
19 DefWithBody, Either, HirFileId, MacroCallLoc, MacroFileKind, Mutability, Path, Resolver,
20 Source, 22 Source,
21}; 23};
22 24
@@ -78,7 +80,7 @@ where
78 let ptr = AstPtr::new(&self_param); 80 let ptr = AstPtr::new(&self_param);
79 let param_pat = self.alloc_pat( 81 let param_pat = self.alloc_pat(
80 Pat::Bind { 82 Pat::Bind {
81 name: SELF_PARAM, 83 name: name::SELF_PARAM,
82 mode: BindingAnnotation::Unannotated, 84 mode: BindingAnnotation::Unannotated,
83 subpat: None, 85 subpat: None,
84 }, 86 },
@@ -458,15 +460,14 @@ where
458 ast::Expr::Label(_e) => self.alloc_expr(Expr::Missing, syntax_ptr), 460 ast::Expr::Label(_e) => self.alloc_expr(Expr::Missing, syntax_ptr),
459 ast::Expr::RangeExpr(_e) => self.alloc_expr(Expr::Missing, syntax_ptr), 461 ast::Expr::RangeExpr(_e) => self.alloc_expr(Expr::Missing, syntax_ptr),
460 ast::Expr::MacroCall(e) => { 462 ast::Expr::MacroCall(e) => {
461 let ast_id = self 463 let ast_id = AstId::new(
462 .db 464 self.current_file_id,
463 .ast_id_map(self.current_file_id) 465 self.db.ast_id_map(self.current_file_id).ast_id(&e),
464 .ast_id(&e) 466 );
465 .with_file_id(self.current_file_id);
466 467
467 if let Some(path) = e.path().and_then(|path| self.parse_path(path)) { 468 if let Some(path) = e.path().and_then(|path| self.parse_path(path)) {
468 if let Some(def) = self.resolver.resolve_path_as_macro(self.db, &path) { 469 if let Some(def) = self.resolver.resolve_path_as_macro(self.db, &path) {
469 let call_id = MacroCallLoc { def: def.id, ast_id }.id(self.db); 470 let call_id = self.db.intern_macro(MacroCallLoc { def: def.id, ast_id });
470 let file_id = call_id.as_file(MacroFileKind::Expr); 471 let file_id = call_id.as_file(MacroFileKind::Expr);
471 if let Some(node) = self.db.parse_or_expand(file_id) { 472 if let Some(node) = self.db.parse_or_expand(file_id) {
472 if let Some(expr) = ast::Expr::cast(node) { 473 if let Some(expr) = ast::Expr::cast(node) {
@@ -596,7 +597,8 @@ where
596 } 597 }
597 598
598 fn parse_path(&mut self, path: ast::Path) -> Option<Path> { 599 fn parse_path(&mut self, path: ast::Path) -> Option<Path> {
599 Path::from_src(Source { ast: path, file_id: self.current_file_id }, self.db) 600 let hygiene = Hygiene::new(self.db, self.current_file_id);
601 Path::from_src(path, &hygiene)
600 } 602 }
601} 603}
602 604