From 77f90caf2deeb6a2d2c8196399fbba61bf0c461d Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 29 Oct 2019 11:15:51 +0300 Subject: start ra_hir_def crate --- crates/ra_hir/src/expr/lower.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'crates/ra_hir/src/expr') diff --git a/crates/ra_hir/src/expr/lower.rs b/crates/ra_hir/src/expr/lower.rs index 50ea429ea..24733b3de 100644 --- a/crates/ra_hir/src/expr/lower.rs +++ b/crates/ra_hir/src/expr/lower.rs @@ -16,7 +16,7 @@ use crate::{ path::GenericArgs, ty::primitive::{FloatTy, IntTy, UncertainFloatTy, UncertainIntTy}, type_ref::TypeRef, - DefWithBody, Either, HirFileId, MacroCallLoc, MacroFileKind, Mutability, Path, Resolver, + AstId, DefWithBody, Either, HirFileId, MacroCallLoc, MacroFileKind, Mutability, Path, Resolver, Source, }; @@ -458,11 +458,10 @@ where ast::Expr::Label(_e) => self.alloc_expr(Expr::Missing, syntax_ptr), ast::Expr::RangeExpr(_e) => self.alloc_expr(Expr::Missing, syntax_ptr), ast::Expr::MacroCall(e) => { - let ast_id = self - .db - .ast_id_map(self.current_file_id) - .ast_id(&e) - .with_file_id(self.current_file_id); + let ast_id = AstId::new( + self.current_file_id, + self.db.ast_id_map(self.current_file_id).ast_id(&e), + ); if let Some(path) = e.path().and_then(|path| self.parse_path(path)) { if let Some(def) = self.resolver.resolve_path_as_macro(self.db, &path) { -- cgit v1.2.3 From 7de6eaa58ae994a5c5d39a66253e347fb039fa94 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 29 Oct 2019 16:01:14 +0300 Subject: remove not that useful indirection --- crates/ra_hir/src/expr/lower.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crates/ra_hir/src/expr') diff --git a/crates/ra_hir/src/expr/lower.rs b/crates/ra_hir/src/expr/lower.rs index 24733b3de..b3a9a2e6b 100644 --- a/crates/ra_hir/src/expr/lower.rs +++ b/crates/ra_hir/src/expr/lower.rs @@ -465,7 +465,7 @@ where if let Some(path) = e.path().and_then(|path| self.parse_path(path)) { if let Some(def) = self.resolver.resolve_path_as_macro(self.db, &path) { - let call_id = MacroCallLoc { def: def.id, ast_id }.id(self.db); + let call_id = self.db.intern_macro(MacroCallLoc { def: def.id, ast_id }); let file_id = call_id.as_file(MacroFileKind::Expr); if let Some(node) = self.db.parse_or_expand(file_id) { if let Some(expr) = ast::Expr::cast(node) { -- cgit v1.2.3 From f8ddef875af08f6c67fe69f7803f3926bc6f66bb Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 30 Oct 2019 17:19:30 +0300 Subject: remove forward pointer for name --- crates/ra_hir/src/expr/lower.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'crates/ra_hir/src/expr') diff --git a/crates/ra_hir/src/expr/lower.rs b/crates/ra_hir/src/expr/lower.rs index b3a9a2e6b..cf8a41b1e 100644 --- a/crates/ra_hir/src/expr/lower.rs +++ b/crates/ra_hir/src/expr/lower.rs @@ -1,5 +1,6 @@ //! FIXME: write short doc here +use hir_def::name::{self, AsName, Name}; use ra_arena::Arena; use ra_syntax::{ ast::{ @@ -12,7 +13,6 @@ use test_utils::tested_by; use crate::{ db::HirDatabase, - name::{AsName, Name, SELF_PARAM}, path::GenericArgs, ty::primitive::{FloatTy, IntTy, UncertainFloatTy, UncertainIntTy}, type_ref::TypeRef, @@ -78,7 +78,7 @@ where let ptr = AstPtr::new(&self_param); let param_pat = self.alloc_pat( Pat::Bind { - name: SELF_PARAM, + name: name::SELF_PARAM, mode: BindingAnnotation::Unannotated, subpat: None, }, -- cgit v1.2.3 From e56433432057712086ca623c4a1ef40089004839 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 30 Oct 2019 17:24:36 +0300 Subject: remove forward pointer to Path --- crates/ra_hir/src/expr/lower.rs | 6 ++++-- crates/ra_hir/src/expr/validation.rs | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'crates/ra_hir/src/expr') diff --git a/crates/ra_hir/src/expr/lower.rs b/crates/ra_hir/src/expr/lower.rs index cf8a41b1e..6436c3a24 100644 --- a/crates/ra_hir/src/expr/lower.rs +++ b/crates/ra_hir/src/expr/lower.rs @@ -1,6 +1,9 @@ //! FIXME: write short doc here -use hir_def::name::{self, AsName, Name}; +use hir_def::{ + name::{self, AsName, Name}, + path::GenericArgs, +}; use ra_arena::Arena; use ra_syntax::{ ast::{ @@ -13,7 +16,6 @@ use test_utils::tested_by; use crate::{ db::HirDatabase, - path::GenericArgs, ty::primitive::{FloatTy, IntTy, UncertainFloatTy, UncertainIntTy}, type_ref::TypeRef, AstId, DefWithBody, Either, HirFileId, MacroCallLoc, MacroFileKind, Mutability, Path, Resolver, 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 @@ use std::sync::Arc; +use hir_def::path::known; use ra_syntax::ast; use rustc_hash::FxHashSet; @@ -9,7 +10,6 @@ use crate::{ db::HirDatabase, diagnostics::{DiagnosticSink, MissingFields, MissingOkInTailExpr}, expr::AstPtr, - path::known, ty::{ApplicationTy, InferenceResult, Ty, TypeCtor}, Adt, Function, Name, Path, }; -- cgit v1.2.3 From e5300ad3baf80c9903235a98a12b6cfd409e9f10 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 30 Oct 2019 17:28:30 +0300 Subject: remove forward pointer for type_ref --- crates/ra_hir/src/expr/lower.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crates/ra_hir/src/expr') diff --git a/crates/ra_hir/src/expr/lower.rs b/crates/ra_hir/src/expr/lower.rs index 6436c3a24..ad029b868 100644 --- a/crates/ra_hir/src/expr/lower.rs +++ b/crates/ra_hir/src/expr/lower.rs @@ -3,6 +3,7 @@ use hir_def::{ name::{self, AsName, Name}, path::GenericArgs, + type_ref::TypeRef, }; use ra_arena::Arena; use ra_syntax::{ @@ -17,7 +18,6 @@ use test_utils::tested_by; use crate::{ db::HirDatabase, ty::primitive::{FloatTy, IntTy, UncertainFloatTy, UncertainIntTy}, - type_ref::TypeRef, AstId, DefWithBody, Either, HirFileId, MacroCallLoc, MacroFileKind, Mutability, Path, Resolver, Source, }; -- cgit v1.2.3 From 0bc7d285189caaffc13e4d6856baf895f72ed80c Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 30 Oct 2019 18:41:50 +0300 Subject: refactor $crate handling Introduce proper hygiene module, which should grow quite a bit eventually. --- crates/ra_hir/src/expr/lower.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'crates/ra_hir/src/expr') diff --git a/crates/ra_hir/src/expr/lower.rs b/crates/ra_hir/src/expr/lower.rs index ad029b868..575d78198 100644 --- a/crates/ra_hir/src/expr/lower.rs +++ b/crates/ra_hir/src/expr/lower.rs @@ -1,6 +1,7 @@ //! FIXME: write short doc here use hir_def::{ + hygiene::Hygiene, name::{self, AsName, Name}, path::GenericArgs, type_ref::TypeRef, @@ -597,7 +598,8 @@ where } fn parse_path(&mut self, path: ast::Path) -> Option { - Path::from_src(Source { ast: path, file_id: self.current_file_id }, self.db) + let hygiene = Hygiene::new(self.db, self.current_file_id); + Path::from_src(path, &hygiene) } } -- cgit v1.2.3 From 872ac566bfc6cf43ac55354cf5223b962dbc1d92 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 30 Oct 2019 18:56:20 +0300 Subject: push name down to hir_expand --- crates/ra_hir/src/expr/lower.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'crates/ra_hir/src/expr') diff --git a/crates/ra_hir/src/expr/lower.rs b/crates/ra_hir/src/expr/lower.rs index 575d78198..241ad68fd 100644 --- a/crates/ra_hir/src/expr/lower.rs +++ b/crates/ra_hir/src/expr/lower.rs @@ -1,11 +1,7 @@ //! FIXME: write short doc here -use hir_def::{ - hygiene::Hygiene, - name::{self, AsName, Name}, - path::GenericArgs, - type_ref::TypeRef, -}; +use hir_def::{hygiene::Hygiene, path::GenericArgs, type_ref::TypeRef}; +use hir_expand::name::{self, AsName, Name}; use ra_arena::Arena; use ra_syntax::{ ast::{ -- cgit v1.2.3 From ab559f170ee02e3bdd9aeeb55933bb143b520c34 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 30 Oct 2019 19:10:53 +0300 Subject: move hygiene to hir_expand --- crates/ra_hir/src/expr/lower.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'crates/ra_hir/src/expr') diff --git a/crates/ra_hir/src/expr/lower.rs b/crates/ra_hir/src/expr/lower.rs index 241ad68fd..6463dd65e 100644 --- a/crates/ra_hir/src/expr/lower.rs +++ b/crates/ra_hir/src/expr/lower.rs @@ -1,7 +1,10 @@ //! FIXME: write short doc here -use hir_def::{hygiene::Hygiene, path::GenericArgs, type_ref::TypeRef}; -use hir_expand::name::{self, AsName, Name}; +use hir_def::{path::GenericArgs, type_ref::TypeRef}; +use hir_expand::{ + hygiene::Hygiene, + name::{self, AsName, Name}, +}; use ra_arena::Arena; use ra_syntax::{ ast::{ -- cgit v1.2.3