aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/expr
diff options
context:
space:
mode:
authorSeivan Heidari <[email protected]>2019-10-31 08:43:20 +0000
committerSeivan Heidari <[email protected]>2019-10-31 08:43:20 +0000
commit8edda0e7b164009d6c03bb3d4be603fb38ad2e2a (patch)
tree744cf81075d394e2f9c06afb07642a2601800dda /crates/ra_hir/src/expr
parent49562d36b97ddde34cf7585a8c2e8f232519b657 (diff)
parentd067afb064a7fa67b172abf561b7d80740cd6f18 (diff)
Merge branch 'master' into feature/themes
Diffstat (limited to 'crates/ra_hir/src/expr')
-rw-r--r--crates/ra_hir/src/expr/lower.rs26
-rw-r--r--crates/ra_hir/src/expr/validation.rs2
2 files changed, 15 insertions, 13 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
diff --git a/crates/ra_hir/src/expr/validation.rs b/crates/ra_hir/src/expr/validation.rs
index 1aa853c3e..c685edda1 100644
--- a/crates/ra_hir/src/expr/validation.rs
+++ b/crates/ra_hir/src/expr/validation.rs
@@ -2,6 +2,7 @@
2 2
3use std::sync::Arc; 3use std::sync::Arc;
4 4
5use hir_def::path::known;
5use ra_syntax::ast; 6use ra_syntax::ast;
6use rustc_hash::FxHashSet; 7use rustc_hash::FxHashSet;
7 8
@@ -9,7 +10,6 @@ use crate::{
9 db::HirDatabase, 10 db::HirDatabase,
10 diagnostics::{DiagnosticSink, MissingFields, MissingOkInTailExpr}, 11 diagnostics::{DiagnosticSink, MissingFields, MissingOkInTailExpr},
11 expr::AstPtr, 12 expr::AstPtr,
12 path::known,
13 ty::{ApplicationTy, InferenceResult, Ty, TypeCtor}, 13 ty::{ApplicationTy, InferenceResult, Ty, TypeCtor},
14 Adt, Function, Name, Path, 14 Adt, Function, Name, Path,
15}; 15};