aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-10-30 16:17:49 +0000
committerGitHub <[email protected]>2019-10-30 16:17:49 +0000
commitd929f9c49bceb3b7c32ea45c5e55c42f168bbf34 (patch)
tree3f0f71a7b9406738b1d15d53970e76302ac624c4 /crates/ra_hir
parent5806195bc1cdb1ca3fa257e99fd6e0dd897713a9 (diff)
parentcf4f7eb56660cfff355cb6bd41d5c17f7d19571b (diff)
Merge #2130
2130: improve compile time a bit r=matklad a=matklad Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_hir')
-rw-r--r--crates/ra_hir/src/adt.rs3
-rw-r--r--crates/ra_hir/src/code_model.rs8
-rw-r--r--crates/ra_hir/src/expr/lower.rs9
-rw-r--r--crates/ra_hir/src/from_source.rs2
-rw-r--r--crates/ra_hir/src/generics.rs2
-rw-r--r--crates/ra_hir/src/impl_block.rs11
-rw-r--r--crates/ra_hir/src/lib.rs18
-rw-r--r--crates/ra_hir/src/nameres/collector.rs3
-rw-r--r--crates/ra_hir/src/resolve.rs2
-rw-r--r--crates/ra_hir/src/source_binder.rs3
-rw-r--r--crates/ra_hir/src/traits.rs3
-rw-r--r--crates/ra_hir/src/ty/autoderef.rs2
-rw-r--r--crates/ra_hir/src/ty/infer.rs2
-rw-r--r--crates/ra_hir/src/ty/infer/expr.rs6
-rw-r--r--crates/ra_hir/src/ty/traits/chalk.rs3
-rw-r--r--crates/ra_hir/src/type_alias.rs7
16 files changed, 43 insertions, 41 deletions
diff --git a/crates/ra_hir/src/adt.rs b/crates/ra_hir/src/adt.rs
index d16b3a1cc..97424b39e 100644
--- a/crates/ra_hir/src/adt.rs
+++ b/crates/ra_hir/src/adt.rs
@@ -3,7 +3,8 @@
3 3
4use std::sync::Arc; 4use std::sync::Arc;
5 5
6use hir_def::{name::AsName, type_ref::TypeRef}; 6use hir_def::type_ref::TypeRef;
7use hir_expand::name::AsName;
7use ra_arena::{impl_arena_id, Arena, RawId}; 8use ra_arena::{impl_arena_id, Arena, RawId};
8use ra_syntax::ast::{self, NameOwner, StructKind, TypeAscriptionOwner}; 9use ra_syntax::ast::{self, NameOwner, StructKind, TypeAscriptionOwner};
9 10
diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs
index d865c972e..a6ce23dd1 100644
--- a/crates/ra_hir/src/code_model.rs
+++ b/crates/ra_hir/src/code_model.rs
@@ -6,13 +6,13 @@ pub(crate) mod docs;
6use std::sync::Arc; 6use std::sync::Arc;
7 7
8use hir_def::{ 8use hir_def::{
9 name::{
10 self, AsName, BOOL, CHAR, F32, F64, I128, I16, I32, I64, I8, ISIZE, SELF_TYPE, STR, U128,
11 U16, U32, U64, U8, USIZE,
12 },
13 type_ref::{Mutability, TypeRef}, 9 type_ref::{Mutability, TypeRef},
14 CrateModuleId, ModuleId, 10 CrateModuleId, ModuleId,
15}; 11};
12use hir_expand::name::{
13 self, AsName, BOOL, CHAR, F32, F64, I128, I16, I32, I64, I8, ISIZE, SELF_TYPE, STR, U128, U16,
14 U32, U64, U8, USIZE,
15};
16use ra_db::{CrateId, Edition}; 16use ra_db::{CrateId, Edition};
17use ra_syntax::ast::{self, NameOwner, TypeAscriptionOwner}; 17use ra_syntax::ast::{self, NameOwner, TypeAscriptionOwner};
18 18
diff --git a/crates/ra_hir/src/expr/lower.rs b/crates/ra_hir/src/expr/lower.rs
index ad029b868..6463dd65e 100644
--- a/crates/ra_hir/src/expr/lower.rs
+++ b/crates/ra_hir/src/expr/lower.rs
@@ -1,9 +1,9 @@
1//! FIXME: write short doc here 1//! FIXME: write short doc here
2 2
3use hir_def::{ 3use hir_def::{path::GenericArgs, type_ref::TypeRef};
4use hir_expand::{
5 hygiene::Hygiene,
4 name::{self, AsName, Name}, 6 name::{self, AsName, Name},
5 path::GenericArgs,
6 type_ref::TypeRef,
7}; 7};
8use ra_arena::Arena; 8use ra_arena::Arena;
9use ra_syntax::{ 9use ra_syntax::{
@@ -597,7 +597,8 @@ where
597 } 597 }
598 598
599 fn parse_path(&mut self, path: ast::Path) -> Option<Path> { 599 fn parse_path(&mut self, path: ast::Path) -> Option<Path> {
600 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)
601 } 602 }
602} 603}
603 604
diff --git a/crates/ra_hir/src/from_source.rs b/crates/ra_hir/src/from_source.rs
index b9fbaa367..a9de01455 100644
--- a/crates/ra_hir/src/from_source.rs
+++ b/crates/ra_hir/src/from_source.rs
@@ -1,6 +1,6 @@
1//! FIXME: write short doc here 1//! FIXME: write short doc here
2 2
3use hir_def::name::AsName; 3use hir_expand::name::AsName;
4use ra_syntax::ast::{self, AstNode, NameOwner}; 4use ra_syntax::ast::{self, AstNode, NameOwner};
5 5
6use crate::{ 6use crate::{
diff --git a/crates/ra_hir/src/generics.rs b/crates/ra_hir/src/generics.rs
index 9d5d18564..52e1fbf29 100644
--- a/crates/ra_hir/src/generics.rs
+++ b/crates/ra_hir/src/generics.rs
@@ -6,10 +6,10 @@
6use std::sync::Arc; 6use std::sync::Arc;
7 7
8use hir_def::{ 8use hir_def::{
9 name::{self, AsName},
10 path::Path, 9 path::Path,
11 type_ref::{TypeBound, TypeRef}, 10 type_ref::{TypeBound, TypeRef},
12}; 11};
12use hir_expand::name::{self, AsName};
13use ra_syntax::ast::{self, DefaultTypeParamOwner, NameOwner, TypeBoundsOwner, TypeParamsOwner}; 13use ra_syntax::ast::{self, DefaultTypeParamOwner, NameOwner, TypeBoundsOwner, TypeParamsOwner};
14 14
15use crate::{ 15use crate::{
diff --git a/crates/ra_hir/src/impl_block.rs b/crates/ra_hir/src/impl_block.rs
index 518330713..b1a014074 100644
--- a/crates/ra_hir/src/impl_block.rs
+++ b/crates/ra_hir/src/impl_block.rs
@@ -4,6 +4,7 @@ use rustc_hash::FxHashMap;
4use std::sync::Arc; 4use std::sync::Arc;
5 5
6use hir_def::{attr::Attr, type_ref::TypeRef}; 6use hir_def::{attr::Attr, type_ref::TypeRef};
7use hir_expand::hygiene::Hygiene;
7use ra_arena::{impl_arena_id, map::ArenaMap, Arena, RawId}; 8use ra_arena::{impl_arena_id, map::ArenaMap, Arena, RawId};
8use ra_cfg::CfgOptions; 9use ra_cfg::CfgOptions;
9use ra_syntax::{ 10use ra_syntax::{
@@ -227,10 +228,11 @@ impl ModuleImplBlocks {
227 owner: &dyn ast::ModuleItemOwner, 228 owner: &dyn ast::ModuleItemOwner,
228 file_id: HirFileId, 229 file_id: HirFileId,
229 ) { 230 ) {
231 let hygiene = Hygiene::new(db, file_id);
230 for item in owner.items_with_macros() { 232 for item in owner.items_with_macros() {
231 match item { 233 match item {
232 ast::ItemOrMacro::Item(ast::ModuleItem::ImplBlock(impl_block_ast)) => { 234 ast::ItemOrMacro::Item(ast::ModuleItem::ImplBlock(impl_block_ast)) => {
233 let attrs = Attr::from_attrs_owner(file_id, &impl_block_ast, db); 235 let attrs = Attr::from_attrs_owner(&impl_block_ast, &hygiene);
234 if attrs.map_or(false, |attrs| { 236 if attrs.map_or(false, |attrs| {
235 attrs.iter().any(|attr| attr.is_cfg_enabled(cfg_options) == Some(false)) 237 attrs.iter().any(|attr| attr.is_cfg_enabled(cfg_options) == Some(false))
236 }) { 238 }) {
@@ -247,7 +249,7 @@ impl ModuleImplBlocks {
247 } 249 }
248 ast::ItemOrMacro::Item(_) => (), 250 ast::ItemOrMacro::Item(_) => (),
249 ast::ItemOrMacro::Macro(macro_call) => { 251 ast::ItemOrMacro::Macro(macro_call) => {
250 let attrs = Attr::from_attrs_owner(file_id, &macro_call, db); 252 let attrs = Attr::from_attrs_owner(&macro_call, &hygiene);
251 if attrs.map_or(false, |attrs| { 253 if attrs.map_or(false, |attrs| {
252 attrs.iter().any(|attr| attr.is_cfg_enabled(cfg_options) == Some(false)) 254 attrs.iter().any(|attr| attr.is_cfg_enabled(cfg_options) == Some(false))
253 }) { 255 }) {
@@ -256,9 +258,8 @@ impl ModuleImplBlocks {
256 258
257 //FIXME: we should really cut down on the boilerplate required to process a macro 259 //FIXME: we should really cut down on the boilerplate required to process a macro
258 let ast_id = AstId::new(file_id, db.ast_id_map(file_id).ast_id(&macro_call)); 260 let ast_id = AstId::new(file_id, db.ast_id_map(file_id).ast_id(&macro_call));
259 if let Some(path) = macro_call 261 if let Some(path) =
260 .path() 262 macro_call.path().and_then(|path| Path::from_src(path, &hygiene))
261 .and_then(|path| Path::from_src(Source { ast: path, file_id }, db))
262 { 263 {
263 if let Some(def) = self.module.resolver(db).resolve_path_as_macro(db, &path) 264 if let Some(def) = self.module.resolver(db).resolve_path_as_macro(db, &path)
264 { 265 {
diff --git a/crates/ra_hir/src/lib.rs b/crates/ra_hir/src/lib.rs
index f765490b0..603b0c3dc 100644
--- a/crates/ra_hir/src/lib.rs
+++ b/crates/ra_hir/src/lib.rs
@@ -60,6 +60,13 @@ use crate::{ids::MacroFileKind, resolve::Resolver};
60 60
61pub use crate::{ 61pub use crate::{
62 adt::VariantDef, 62 adt::VariantDef,
63 code_model::{
64 docs::{DocDef, Docs, Documentation},
65 src::{HasBodySource, HasSource, Source},
66 Adt, AssocItem, BuiltinType, Const, ConstData, Container, Crate, CrateDependency,
67 DefWithBody, Enum, EnumVariant, FieldSource, FnData, Function, HasBody, MacroDef, Module,
68 ModuleDef, ModuleSource, Static, Struct, StructField, Trait, TypeAlias, Union,
69 },
63 expr::ExprScopes, 70 expr::ExprScopes,
64 from_source::FromSource, 71 from_source::FromSource,
65 generics::{GenericDef, GenericParam, GenericParams, HasGenericParams}, 72 generics::{GenericDef, GenericParam, GenericParams, HasGenericParams},
@@ -73,17 +80,8 @@ pub use crate::{
73 }, 80 },
74}; 81};
75 82
76pub use self::code_model::{
77 docs::{DocDef, Docs, Documentation},
78 src::{HasBodySource, HasSource, Source},
79 Adt, AssocItem, BuiltinType, Const, ConstData, Container, Crate, CrateDependency, DefWithBody,
80 Enum, EnumVariant, FieldSource, FnData, Function, HasBody, MacroDef, Module, ModuleDef,
81 ModuleSource, Static, Struct, StructField, Trait, TypeAlias, Union,
82};
83
84pub use hir_def::{ 83pub use hir_def::{
85 either::Either,
86 name::Name,
87 path::{Path, PathKind}, 84 path::{Path, PathKind},
88 type_ref::Mutability, 85 type_ref::Mutability,
89}; 86};
87pub use hir_expand::{either::Either, name::Name};
diff --git a/crates/ra_hir/src/nameres/collector.rs b/crates/ra_hir/src/nameres/collector.rs
index 2f342870b..e2e13805a 100644
--- a/crates/ra_hir/src/nameres/collector.rs
+++ b/crates/ra_hir/src/nameres/collector.rs
@@ -1,6 +1,7 @@
1//! FIXME: write short doc here 1//! FIXME: write short doc here
2 2
3use hir_def::{attr::Attr, name, nameres::raw}; 3use hir_def::{attr::Attr, nameres::raw};
4use hir_expand::name;
4use ra_cfg::CfgOptions; 5use ra_cfg::CfgOptions;
5use ra_db::FileId; 6use ra_db::FileId;
6use ra_syntax::{ast, SmolStr}; 7use ra_syntax::{ast, SmolStr};
diff --git a/crates/ra_hir/src/resolve.rs b/crates/ra_hir/src/resolve.rs
index 2a783b61e..f77c9df9f 100644
--- a/crates/ra_hir/src/resolve.rs
+++ b/crates/ra_hir/src/resolve.rs
@@ -2,10 +2,10 @@
2use std::sync::Arc; 2use std::sync::Arc;
3 3
4use hir_def::{ 4use hir_def::{
5 name::{self, Name},
6 path::{Path, PathKind}, 5 path::{Path, PathKind},
7 CrateModuleId, 6 CrateModuleId,
8}; 7};
8use hir_expand::name::{self, Name};
9use rustc_hash::FxHashSet; 9use rustc_hash::FxHashSet;
10 10
11use crate::{ 11use crate::{
diff --git a/crates/ra_hir/src/source_binder.rs b/crates/ra_hir/src/source_binder.rs
index 544433a0a..01f51ba5d 100644
--- a/crates/ra_hir/src/source_binder.rs
+++ b/crates/ra_hir/src/source_binder.rs
@@ -7,7 +7,8 @@
7//! purely for "IDE needs". 7//! purely for "IDE needs".
8use std::sync::Arc; 8use std::sync::Arc;
9 9
10use hir_def::{name::AsName, path::known}; 10use hir_def::path::known;
11use hir_expand::name::AsName;
11use ra_db::FileId; 12use ra_db::FileId;
12use ra_syntax::{ 13use ra_syntax::{
13 ast::{self, AstNode}, 14 ast::{self, AstNode},
diff --git a/crates/ra_hir/src/traits.rs b/crates/ra_hir/src/traits.rs
index 514c813ab..1a45dacba 100644
--- a/crates/ra_hir/src/traits.rs
+++ b/crates/ra_hir/src/traits.rs
@@ -2,7 +2,8 @@
2 2
3use std::sync::Arc; 3use std::sync::Arc;
4 4
5use hir_def::name::AsName; 5use hir_expand::name::AsName;
6
6use ra_syntax::ast::{self, NameOwner}; 7use ra_syntax::ast::{self, NameOwner};
7use rustc_hash::FxHashMap; 8use rustc_hash::FxHashMap;
8 9
diff --git a/crates/ra_hir/src/ty/autoderef.rs b/crates/ra_hir/src/ty/autoderef.rs
index 03c45546d..3645ee831 100644
--- a/crates/ra_hir/src/ty/autoderef.rs
+++ b/crates/ra_hir/src/ty/autoderef.rs
@@ -5,7 +5,7 @@
5 5
6use std::iter::successors; 6use std::iter::successors;
7 7
8use hir_def::name; 8use hir_expand::name;
9use log::{info, warn}; 9use log::{info, warn};
10 10
11use super::{traits::Solution, Canonical, Substs, Ty, TypeWalk}; 11use super::{traits::Solution, Canonical, Substs, Ty, TypeWalk};
diff --git a/crates/ra_hir/src/ty/infer.rs b/crates/ra_hir/src/ty/infer.rs
index 7466ee341..6694467a3 100644
--- a/crates/ra_hir/src/ty/infer.rs
+++ b/crates/ra_hir/src/ty/infer.rs
@@ -22,10 +22,10 @@ use ena::unify::{InPlaceUnificationTable, NoError, UnifyKey, UnifyValue};
22use rustc_hash::FxHashMap; 22use rustc_hash::FxHashMap;
23 23
24use hir_def::{ 24use hir_def::{
25 name,
26 path::known, 25 path::known,
27 type_ref::{Mutability, TypeRef}, 26 type_ref::{Mutability, TypeRef},
28}; 27};
28use hir_expand::name;
29use ra_arena::map::ArenaMap; 29use ra_arena::map::ArenaMap;
30use ra_prof::profile; 30use ra_prof::profile;
31use test_utils::tested_by; 31use test_utils::tested_by;
diff --git a/crates/ra_hir/src/ty/infer/expr.rs b/crates/ra_hir/src/ty/infer/expr.rs
index bc6437b44..fed52df39 100644
--- a/crates/ra_hir/src/ty/infer/expr.rs
+++ b/crates/ra_hir/src/ty/infer/expr.rs
@@ -3,10 +3,8 @@
3use std::iter::{repeat, repeat_with}; 3use std::iter::{repeat, repeat_with};
4use std::sync::Arc; 4use std::sync::Arc;
5 5
6use hir_def::{ 6use hir_def::path::{GenericArg, GenericArgs};
7 name, 7use hir_expand::name;
8 path::{GenericArg, GenericArgs},
9};
10 8
11use super::{BindingMode, Expectation, InferenceContext, InferenceDiagnostic, TypeMismatch}; 9use super::{BindingMode, Expectation, InferenceContext, InferenceDiagnostic, TypeMismatch};
12use crate::{ 10use crate::{
diff --git a/crates/ra_hir/src/ty/traits/chalk.rs b/crates/ra_hir/src/ty/traits/chalk.rs
index 2dd4c2fae..39ef92182 100644
--- a/crates/ra_hir/src/ty/traits/chalk.rs
+++ b/crates/ra_hir/src/ty/traits/chalk.rs
@@ -9,7 +9,8 @@ use chalk_ir::{
9}; 9};
10use chalk_rust_ir::{AssociatedTyDatum, ImplDatum, StructDatum, TraitDatum}; 10use chalk_rust_ir::{AssociatedTyDatum, ImplDatum, StructDatum, TraitDatum};
11 11
12use hir_def::name; 12use hir_expand::name;
13
13use ra_db::salsa::{InternId, InternKey}; 14use ra_db::salsa::{InternId, InternKey};
14 15
15use super::{Canonical, ChalkContext, Impl, Obligation}; 16use super::{Canonical, ChalkContext, Impl, Obligation};
diff --git a/crates/ra_hir/src/type_alias.rs b/crates/ra_hir/src/type_alias.rs
index 87126ee7f..078e6295e 100644
--- a/crates/ra_hir/src/type_alias.rs
+++ b/crates/ra_hir/src/type_alias.rs
@@ -2,10 +2,9 @@
2 2
3use std::sync::Arc; 3use std::sync::Arc;
4 4
5use hir_def::{ 5use hir_def::type_ref::TypeRef;
6 name::{AsName, Name}, 6use hir_expand::name::{AsName, Name};
7 type_ref::TypeRef, 7
8};
9use ra_syntax::ast::NameOwner; 8use ra_syntax::ast::NameOwner;
10 9
11use crate::{ 10use crate::{