diff options
Diffstat (limited to 'crates/ra_hir')
35 files changed, 267 insertions, 240 deletions
diff --git a/crates/ra_hir/src/adt.rs b/crates/ra_hir/src/adt.rs index b3843b35c..9c0c8fdd0 100644 --- a/crates/ra_hir/src/adt.rs +++ b/crates/ra_hir/src/adt.rs | |||
@@ -3,16 +3,15 @@ | |||
3 | 3 | ||
4 | use std::sync::Arc; | 4 | use std::sync::Arc; |
5 | 5 | ||
6 | use ra_arena::{RawId, Arena, impl_arena_id}; | 6 | use ra_arena::{impl_arena_id, Arena, RawId}; |
7 | use ra_syntax::{ | 7 | use ra_syntax::{ |
8 | ast::{self, NameOwner, StructKind, TypeAscriptionOwner}, | ||
8 | TreeArc, | 9 | TreeArc, |
9 | ast::{self, NameOwner, StructKind, TypeAscriptionOwner} | ||
10 | }; | 10 | }; |
11 | 11 | ||
12 | use crate::{ | 12 | use crate::{ |
13 | Name, AsName, Struct, Union, Enum, EnumVariant, Crate, AstDatabase, | 13 | type_ref::TypeRef, AsName, AstDatabase, Crate, DefDatabase, Enum, EnumVariant, FieldSource, |
14 | HirDatabase, StructField, FieldSource, Source, HasSource, | 14 | HasSource, HirDatabase, Name, Source, Struct, StructField, Union, |
15 | type_ref::TypeRef, DefDatabase, | ||
16 | }; | 15 | }; |
17 | 16 | ||
18 | #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] | 17 | #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] |
diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs index 75914ccb0..ed640d7fc 100644 --- a/crates/ra_hir/src/code_model.rs +++ b/crates/ra_hir/src/code_model.rs | |||
@@ -3,24 +3,32 @@ pub(crate) mod docs; | |||
3 | 3 | ||
4 | use std::sync::Arc; | 4 | use std::sync::Arc; |
5 | 5 | ||
6 | use ra_db::{CrateId, SourceRootId, Edition, FileId}; | 6 | use ra_db::{CrateId, Edition, FileId, SourceRootId}; |
7 | use ra_syntax::{ast::{self, NameOwner, TypeAscriptionOwner}, TreeArc}; | 7 | use ra_syntax::{ |
8 | ast::{self, NameOwner, TypeAscriptionOwner}, | ||
9 | TreeArc, | ||
10 | }; | ||
8 | 11 | ||
9 | use crate::{ | 12 | use crate::{ |
10 | Name, AsName, AstId, Ty, Either, KnownName, HasSource, | ||
11 | HirDatabase, DefDatabase, AstDatabase, | ||
12 | type_ref::TypeRef, | ||
13 | nameres::{ModuleScope, Namespace, ImportId, CrateModuleId}, | ||
14 | expr::{Body, BodySourceMap, validation::ExprValidator}, | ||
15 | ty::{TraitRef, InferenceResult, primitive::{IntTy, FloatTy, Signedness, IntBitness, FloatBitness}}, | ||
16 | adt::{EnumVariantId, StructFieldId, VariantDef}, | 13 | adt::{EnumVariantId, StructFieldId, VariantDef}, |
14 | diagnostics::DiagnosticSink, | ||
15 | expr::{validation::ExprValidator, Body, BodySourceMap}, | ||
17 | generics::HasGenericParams, | 16 | generics::HasGenericParams, |
18 | ids::{FunctionId, StructId, EnumId, AstItemDef, ConstId, StaticId, TraitId, TypeAliasId, MacroDefId}, | 17 | ids::{ |
18 | AstItemDef, ConstId, EnumId, FunctionId, MacroDefId, StaticId, StructId, TraitId, | ||
19 | TypeAliasId, | ||
20 | }, | ||
19 | impl_block::ImplBlock, | 21 | impl_block::ImplBlock, |
22 | nameres::{CrateModuleId, ImportId, ModuleScope, Namespace}, | ||
20 | resolve::Resolver, | 23 | resolve::Resolver, |
21 | diagnostics::{DiagnosticSink}, | 24 | traits::{TraitData, TraitItem}, |
22 | traits::{TraitItem, TraitData}, | 25 | ty::{ |
26 | primitive::{FloatBitness, FloatTy, IntBitness, IntTy, Signedness}, | ||
27 | InferenceResult, TraitRef, | ||
28 | }, | ||
23 | type_ref::Mutability, | 29 | type_ref::Mutability, |
30 | type_ref::TypeRef, | ||
31 | AsName, AstDatabase, AstId, DefDatabase, Either, HasSource, HirDatabase, KnownName, Name, Ty, | ||
24 | }; | 32 | }; |
25 | 33 | ||
26 | /// hir::Crate describes a single crate. It's the main interface with which | 34 | /// hir::Crate describes a single crate. It's the main interface with which |
diff --git a/crates/ra_hir/src/code_model/docs.rs b/crates/ra_hir/src/code_model/docs.rs index da2b9b854..f696307a7 100644 --- a/crates/ra_hir/src/code_model/docs.rs +++ b/crates/ra_hir/src/code_model/docs.rs | |||
@@ -3,8 +3,8 @@ use std::sync::Arc; | |||
3 | use ra_syntax::ast; | 3 | use ra_syntax::ast; |
4 | 4 | ||
5 | use crate::{ | 5 | use crate::{ |
6 | HirDatabase, DefDatabase, AstDatabase, HasSource, | 6 | AstDatabase, Const, DefDatabase, Enum, EnumVariant, FieldSource, Function, HasSource, |
7 | Module, StructField, Struct, Enum, EnumVariant, Static, Const, Function, Union, Trait, TypeAlias, FieldSource, MacroDef, | 7 | HirDatabase, MacroDef, Module, Static, Struct, StructField, Trait, TypeAlias, Union, |
8 | }; | 8 | }; |
9 | 9 | ||
10 | #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] | 10 | #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] |
diff --git a/crates/ra_hir/src/code_model/src.rs b/crates/ra_hir/src/code_model/src.rs index 5785d3b26..72451e0e7 100644 --- a/crates/ra_hir/src/code_model/src.rs +++ b/crates/ra_hir/src/code_model/src.rs | |||
@@ -1,9 +1,9 @@ | |||
1 | use ra_syntax::{TreeArc, ast}; | 1 | use ra_syntax::{ast, TreeArc}; |
2 | 2 | ||
3 | use crate::{ | 3 | use crate::{ |
4 | HirFileId, DefDatabase, AstDatabase, Module, ModuleSource, | 4 | ids::AstItemDef, AstDatabase, Const, DefDatabase, Enum, EnumVariant, FieldSource, Function, |
5 | StructField, Struct, Enum, Union, EnumVariant, Function, Static, Trait, Const, TypeAlias, | 5 | HirFileId, MacroDef, Module, ModuleSource, Static, Struct, StructField, Trait, TypeAlias, |
6 | FieldSource, MacroDef, ids::AstItemDef, | 6 | Union, |
7 | }; | 7 | }; |
8 | 8 | ||
9 | pub struct Source<T> { | 9 | pub struct Source<T> { |
diff --git a/crates/ra_hir/src/db.rs b/crates/ra_hir/src/db.rs index eda22c0b0..a9c6c52d9 100644 --- a/crates/ra_hir/src/db.rs +++ b/crates/ra_hir/src/db.rs | |||
@@ -1,23 +1,25 @@ | |||
1 | use std::sync::Arc; | 1 | use std::sync::Arc; |
2 | 2 | ||
3 | use parking_lot::Mutex; | 3 | use parking_lot::Mutex; |
4 | use ra_syntax::{SyntaxNode, TreeArc, SmolStr, ast}; | 4 | use ra_db::{salsa, SourceDatabase}; |
5 | use ra_db::{SourceDatabase, salsa}; | 5 | use ra_syntax::{ast, SmolStr, SyntaxNode, TreeArc}; |
6 | 6 | ||
7 | use crate::{ | 7 | use crate::{ |
8 | HirFileId, MacroDefId, AstIdMap, ErasedFileAstId, Crate, Module, MacroCallLoc, | 8 | adt::{EnumData, StructData}, |
9 | Function, FnData, ExprScopes, TypeAlias, | 9 | generics::{GenericDef, GenericParams}, |
10 | Struct, Enum, StructField, | ||
11 | Const, ConstData, Static, | ||
12 | DefWithBody, Trait, | ||
13 | ids, | 10 | ids, |
14 | nameres::{Namespace, ImportSourceMap, RawItems, CrateDefMap}, | 11 | impl_block::{ImplBlock, ImplSourceMap, ModuleImplBlocks}, |
15 | ty::{InferenceResult, Ty, method_resolution::CrateImplBlocks, TypableDef, CallableDef, FnSig, TypeCtor, GenericPredicate, Substs}, | 12 | lang_item::{LangItemTarget, LangItems}, |
16 | adt::{StructData, EnumData}, | 13 | nameres::{CrateDefMap, ImportSourceMap, Namespace, RawItems}, |
17 | impl_block::{ModuleImplBlocks, ImplSourceMap, ImplBlock}, | ||
18 | generics::{GenericParams, GenericDef}, | ||
19 | traits::TraitData, | 14 | traits::TraitData, |
20 | lang_item::{LangItems, LangItemTarget}, type_alias::TypeAliasData, | 15 | ty::{ |
16 | method_resolution::CrateImplBlocks, CallableDef, FnSig, GenericPredicate, InferenceResult, | ||
17 | Substs, Ty, TypableDef, TypeCtor, | ||
18 | }, | ||
19 | type_alias::TypeAliasData, | ||
20 | AstIdMap, Const, ConstData, Crate, DefWithBody, Enum, ErasedFileAstId, ExprScopes, FnData, | ||
21 | Function, HirFileId, MacroCallLoc, MacroDefId, Module, Static, Struct, StructField, Trait, | ||
22 | TypeAlias, | ||
21 | }; | 23 | }; |
22 | 24 | ||
23 | /// We store all interned things in the single QueryGroup. | 25 | /// We store all interned things in the single QueryGroup. |
diff --git a/crates/ra_hir/src/diagnostics.rs b/crates/ra_hir/src/diagnostics.rs index 2557ef18e..f5f2e65f3 100644 --- a/crates/ra_hir/src/diagnostics.rs +++ b/crates/ra_hir/src/diagnostics.rs | |||
@@ -1,9 +1,9 @@ | |||
1 | use std::{fmt, any::Any}; | 1 | use std::{any::Any, fmt}; |
2 | 2 | ||
3 | use ra_syntax::{SyntaxNodePtr, TreeArc, AstPtr, TextRange, ast, SyntaxNode}; | 3 | use ra_syntax::{ast, AstPtr, SyntaxNode, SyntaxNodePtr, TextRange, TreeArc}; |
4 | use relative_path::RelativePathBuf; | 4 | use relative_path::RelativePathBuf; |
5 | 5 | ||
6 | use crate::{HirFileId, HirDatabase, Name}; | 6 | use crate::{HirDatabase, HirFileId, Name}; |
7 | 7 | ||
8 | /// Diagnostic defines hir API for errors and warnings. | 8 | /// Diagnostic defines hir API for errors and warnings. |
9 | /// | 9 | /// |
diff --git a/crates/ra_hir/src/expr.rs b/crates/ra_hir/src/expr.rs index b1973d19d..d5b4ba6b6 100644 --- a/crates/ra_hir/src/expr.rs +++ b/crates/ra_hir/src/expr.rs | |||
@@ -3,19 +3,25 @@ use std::sync::Arc; | |||
3 | 3 | ||
4 | use rustc_hash::FxHashMap; | 4 | use rustc_hash::FxHashMap; |
5 | 5 | ||
6 | use ra_arena::{Arena, RawId, impl_arena_id, map::ArenaMap}; | 6 | use ra_arena::{impl_arena_id, map::ArenaMap, Arena, RawId}; |
7 | use ra_syntax::{ | 7 | use ra_syntax::{ |
8 | SyntaxNodePtr, AstPtr, AstNode, | 8 | ast::{ |
9 | ast::{self, TryBlockBodyOwner, LoopBodyOwner, ArgListOwner, NameOwner, LiteralKind,ArrayExprKind, TypeAscriptionOwner}, | 9 | self, ArgListOwner, ArrayExprKind, LiteralKind, LoopBodyOwner, NameOwner, |
10 | TryBlockBodyOwner, TypeAscriptionOwner, | ||
11 | }, | ||
12 | AstNode, AstPtr, SyntaxNodePtr, | ||
10 | }; | 13 | }; |
11 | 14 | ||
12 | use crate::{ | 15 | use crate::{ |
13 | Path, Name, HirDatabase, Resolver,DefWithBody, Either, HirFileId, MacroCallLoc, MacroFileKind, | ||
14 | HasSource, | ||
15 | name::AsName, | 16 | name::AsName, |
16 | type_ref::{Mutability, TypeRef}, | 17 | type_ref::{Mutability, TypeRef}, |
18 | DefWithBody, Either, HasSource, HirDatabase, HirFileId, MacroCallLoc, MacroFileKind, Name, | ||
19 | Path, Resolver, | ||
20 | }; | ||
21 | use crate::{ | ||
22 | path::GenericArgs, | ||
23 | ty::primitive::{FloatTy, IntTy, UncertainFloatTy, UncertainIntTy}, | ||
17 | }; | 24 | }; |
18 | use crate::{path::GenericArgs, ty::primitive::{IntTy, UncertainIntTy, FloatTy, UncertainFloatTy}}; | ||
19 | 25 | ||
20 | pub use self::scope::ExprScopes; | 26 | pub use self::scope::ExprScopes; |
21 | 27 | ||
@@ -249,8 +255,8 @@ pub enum Expr { | |||
249 | Literal(Literal), | 255 | Literal(Literal), |
250 | } | 256 | } |
251 | 257 | ||
252 | pub use ra_syntax::ast::PrefixOp as UnaryOp; | ||
253 | pub use ra_syntax::ast::BinOp as BinaryOp; | 258 | pub use ra_syntax::ast::BinOp as BinaryOp; |
259 | pub use ra_syntax::ast::PrefixOp as UnaryOp; | ||
254 | #[derive(Debug, Clone, Eq, PartialEq)] | 260 | #[derive(Debug, Clone, Eq, PartialEq)] |
255 | pub enum Array { | 261 | pub enum Array { |
256 | ElementList(Vec<ExprId>), | 262 | ElementList(Vec<ExprId>), |
diff --git a/crates/ra_hir/src/expr/scope.rs b/crates/ra_hir/src/expr/scope.rs index 83d226fc1..f27cc6e8d 100644 --- a/crates/ra_hir/src/expr/scope.rs +++ b/crates/ra_hir/src/expr/scope.rs | |||
@@ -1,12 +1,11 @@ | |||
1 | use std::sync::Arc; | 1 | use std::sync::Arc; |
2 | 2 | ||
3 | use ra_arena::{impl_arena_id, Arena, RawId}; | ||
3 | use rustc_hash::FxHashMap; | 4 | use rustc_hash::FxHashMap; |
4 | use ra_arena::{Arena, RawId, impl_arena_id}; | ||
5 | 5 | ||
6 | use crate::{ | 6 | use crate::{ |
7 | Name, DefWithBody, | 7 | expr::{Body, Expr, ExprId, Pat, PatId, Statement}, |
8 | expr::{PatId, ExprId, Pat, Expr, Body, Statement}, | 8 | DefWithBody, HirDatabase, Name, |
9 | HirDatabase, | ||
10 | }; | 9 | }; |
11 | 10 | ||
12 | #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] | 11 | #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] |
@@ -173,10 +172,10 @@ fn compute_expr_scopes(expr: ExprId, body: &Body, scopes: &mut ExprScopes, scope | |||
173 | #[cfg(test)] | 172 | #[cfg(test)] |
174 | mod tests { | 173 | mod tests { |
175 | use ra_db::SourceDatabase; | 174 | use ra_db::SourceDatabase; |
176 | use ra_syntax::{algo::find_node_at_offset, AstNode, SyntaxNodePtr, ast}; | 175 | use ra_syntax::{algo::find_node_at_offset, ast, AstNode, SyntaxNodePtr}; |
177 | use test_utils::{extract_offset, assert_eq_text}; | 176 | use test_utils::{assert_eq_text, extract_offset}; |
178 | 177 | ||
179 | use crate::{source_binder::SourceAnalyzer, mock::MockDatabase}; | 178 | use crate::{mock::MockDatabase, source_binder::SourceAnalyzer}; |
180 | 179 | ||
181 | fn do_check(code: &str, expected: &[&str]) { | 180 | fn do_check(code: &str, expected: &[&str]) { |
182 | let (off, code) = extract_offset(code); | 181 | let (off, code) = extract_offset(code); |
diff --git a/crates/ra_hir/src/expr/validation.rs b/crates/ra_hir/src/expr/validation.rs index 534fd482b..8206dae2e 100644 --- a/crates/ra_hir/src/expr/validation.rs +++ b/crates/ra_hir/src/expr/validation.rs | |||
@@ -1,17 +1,16 @@ | |||
1 | use std::sync::Arc; | ||
2 | use rustc_hash::FxHashSet; | 1 | use rustc_hash::FxHashSet; |
2 | use std::sync::Arc; | ||
3 | 3 | ||
4 | use ra_syntax::ast::{AstNode, StructLit}; | 4 | use ra_syntax::ast::{AstNode, StructLit}; |
5 | 5 | ||
6 | use super::{Expr, ExprId, StructLitField}; | ||
6 | use crate::{ | 7 | use crate::{ |
7 | expr::AstPtr, | ||
8 | HirDatabase, Function, Name, HasSource, | ||
9 | diagnostics::{DiagnosticSink, MissingFields}, | ||
10 | adt::AdtDef, | 8 | adt::AdtDef, |
11 | Path, | 9 | diagnostics::{DiagnosticSink, MissingFields}, |
10 | expr::AstPtr, | ||
12 | ty::InferenceResult, | 11 | ty::InferenceResult, |
12 | Function, HasSource, HirDatabase, Name, Path, | ||
13 | }; | 13 | }; |
14 | use super::{Expr, StructLitField, ExprId}; | ||
15 | 14 | ||
16 | pub(crate) struct ExprValidator<'a, 'b: 'a> { | 15 | pub(crate) struct ExprValidator<'a, 'b: 'a> { |
17 | func: Function, | 16 | func: Function, |
diff --git a/crates/ra_hir/src/generics.rs b/crates/ra_hir/src/generics.rs index 462b136b7..9929331d3 100644 --- a/crates/ra_hir/src/generics.rs +++ b/crates/ra_hir/src/generics.rs | |||
@@ -5,13 +5,14 @@ | |||
5 | 5 | ||
6 | use std::sync::Arc; | 6 | use std::sync::Arc; |
7 | 7 | ||
8 | use ra_syntax::ast::{self, NameOwner, TypeParamsOwner, TypeBoundsOwner, DefaultTypeParamOwner}; | 8 | use ra_syntax::ast::{self, DefaultTypeParamOwner, NameOwner, TypeBoundsOwner, TypeParamsOwner}; |
9 | 9 | ||
10 | use crate::{ | 10 | use crate::{ |
11 | HasSource, | 11 | db::{AstDatabase, DefDatabase, HirDatabase}, |
12 | Name, AsName, Function, Struct, Union, Enum, Trait, TypeAlias, ImplBlock, Container, AdtDef, | 12 | path::Path, |
13 | db::{HirDatabase, DefDatabase, AstDatabase}, | 13 | type_ref::TypeRef, |
14 | path::Path, type_ref::TypeRef, | 14 | AdtDef, AsName, Container, Enum, Function, HasSource, ImplBlock, Name, Struct, Trait, |
15 | TypeAlias, Union, | ||
15 | }; | 16 | }; |
16 | 17 | ||
17 | /// Data about a generic parameter (to a function, struct, impl, ...). | 18 | /// Data about a generic parameter (to a function, struct, impl, ...). |
diff --git a/crates/ra_hir/src/ids.rs b/crates/ra_hir/src/ids.rs index b7215ac03..bd1e2f2e6 100644 --- a/crates/ra_hir/src/ids.rs +++ b/crates/ra_hir/src/ids.rs | |||
@@ -3,14 +3,12 @@ use std::{ | |||
3 | sync::Arc, | 3 | sync::Arc, |
4 | }; | 4 | }; |
5 | 5 | ||
6 | use ra_db::{FileId, salsa}; | ||
7 | use ra_syntax::{TreeArc, AstNode, ast, SyntaxNode}; | ||
8 | use ra_prof::profile; | ||
9 | use mbe::MacroRules; | 6 | use mbe::MacroRules; |
7 | use ra_db::{salsa, FileId}; | ||
8 | use ra_prof::profile; | ||
9 | use ra_syntax::{ast, AstNode, SyntaxNode, TreeArc}; | ||
10 | 10 | ||
11 | use crate::{ | 11 | use crate::{AstDatabase, AstId, DefDatabase, FileAstId, InternDatabase, Module, Source}; |
12 | Module, DefDatabase, AstId, FileAstId, AstDatabase, Source, InternDatabase, | ||
13 | }; | ||
14 | 12 | ||
15 | /// hir makes heavy use of ids: integer (u32) handlers to various things. You | 13 | /// hir makes heavy use of ids: integer (u32) handlers to various things. You |
16 | /// can think of id as a pointer (but without a lifetime) or a file descriptor | 14 | /// can think of id as a pointer (but without a lifetime) or a file descriptor |
diff --git a/crates/ra_hir/src/impl_block.rs b/crates/ra_hir/src/impl_block.rs index fb9daf1bf..ce134b27a 100644 --- a/crates/ra_hir/src/impl_block.rs +++ b/crates/ra_hir/src/impl_block.rs | |||
@@ -1,21 +1,21 @@ | |||
1 | use std::sync::Arc; | ||
2 | use rustc_hash::FxHashMap; | 1 | use rustc_hash::FxHashMap; |
2 | use std::sync::Arc; | ||
3 | 3 | ||
4 | use ra_arena::{Arena, RawId, impl_arena_id, map::ArenaMap}; | 4 | use ra_arena::{impl_arena_id, map::ArenaMap, Arena, RawId}; |
5 | use ra_syntax::{ | 5 | use ra_syntax::{ |
6 | ast::{self, AstNode}, | ||
6 | AstPtr, SourceFile, TreeArc, | 7 | AstPtr, SourceFile, TreeArc, |
7 | ast::{self, AstNode} | ||
8 | }; | 8 | }; |
9 | 9 | ||
10 | use crate::{ | 10 | use crate::{ |
11 | Const, TypeAlias, Function, HirFileId, AstDatabase, HasSource, Source, | 11 | code_model::{Module, ModuleSource}, |
12 | HirDatabase, DefDatabase, TraitRef, | 12 | generics::HasGenericParams, |
13 | type_ref::TypeRef, | ||
14 | ids::LocationCtx, | 13 | ids::LocationCtx, |
15 | resolve::Resolver, | 14 | resolve::Resolver, |
16 | ty::Ty, | 15 | ty::Ty, |
17 | generics::HasGenericParams, | 16 | type_ref::TypeRef, |
18 | code_model::{Module, ModuleSource} | 17 | AstDatabase, Const, DefDatabase, Function, HasSource, HirDatabase, HirFileId, Source, TraitRef, |
18 | TypeAlias, | ||
19 | }; | 19 | }; |
20 | 20 | ||
21 | #[derive(Debug, Default, PartialEq, Eq)] | 21 | #[derive(Debug, Default, PartialEq, Eq)] |
diff --git a/crates/ra_hir/src/lang_item.rs b/crates/ra_hir/src/lang_item.rs index 48b60f2dd..f9fe47b0f 100644 --- a/crates/ra_hir/src/lang_item.rs +++ b/crates/ra_hir/src/lang_item.rs | |||
@@ -1,11 +1,11 @@ | |||
1 | use std::sync::Arc; | ||
2 | use rustc_hash::FxHashMap; | 1 | use rustc_hash::FxHashMap; |
2 | use std::sync::Arc; | ||
3 | 3 | ||
4 | use ra_syntax::{SmolStr, TreeArc, ast::AttrsOwner}; | 4 | use ra_syntax::{ast::AttrsOwner, SmolStr, TreeArc}; |
5 | 5 | ||
6 | use crate::{ | 6 | use crate::{ |
7 | Crate, DefDatabase, Enum, Function, HirDatabase, ImplBlock, Module, | 7 | AstDatabase, Crate, DefDatabase, Enum, Function, HasSource, HirDatabase, ImplBlock, Module, |
8 | Static, Struct, Trait, ModuleDef, AstDatabase, HasSource | 8 | ModuleDef, Static, Struct, Trait, |
9 | }; | 9 | }; |
10 | 10 | ||
11 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | 11 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] |
diff --git a/crates/ra_hir/src/lib.rs b/crates/ra_hir/src/lib.rs index 5afd846f5..ec0676783 100644 --- a/crates/ra_hir/src/lib.rs +++ b/crates/ra_hir/src/lib.rs | |||
@@ -47,39 +47,33 @@ mod code_model; | |||
47 | mod marks; | 47 | mod marks; |
48 | 48 | ||
49 | use crate::{ | 49 | use crate::{ |
50 | db::{InternDatabase, AstDatabase, DefDatabase, HirDatabase}, | 50 | db::{AstDatabase, DefDatabase, HirDatabase, InternDatabase}, |
51 | ids::MacroFileKind, | ||
51 | name::{AsName, KnownName}, | 52 | name::{AsName, KnownName}, |
52 | source_id::{FileAstId, AstId}, | ||
53 | resolve::Resolver, | 53 | resolve::Resolver, |
54 | ids::MacroFileKind, | 54 | source_id::{AstId, FileAstId}, |
55 | }; | 55 | }; |
56 | 56 | ||
57 | pub use self::{ | 57 | pub use self::{ |
58 | either::Either, | ||
59 | path::{Path, PathKind}, | ||
60 | name::Name, | ||
61 | source_id::{AstIdMap, ErasedFileAstId}, | ||
62 | ids::{HirFileId, MacroDefId, MacroCallId, MacroCallLoc, MacroFile}, | ||
63 | nameres::{PerNs, Namespace, ImportId}, | ||
64 | ty::{Ty, ApplicationTy, TypeCtor, TraitRef, Substs, display::HirDisplay, CallableDef}, | ||
65 | impl_block::{ImplBlock, ImplItem}, | ||
66 | adt::AdtDef, | 58 | adt::AdtDef, |
59 | either::Either, | ||
67 | expr::ExprScopes, | 60 | expr::ExprScopes, |
61 | generics::{GenericParam, GenericParams, HasGenericParams}, | ||
62 | ids::{HirFileId, MacroCallId, MacroCallLoc, MacroDefId, MacroFile}, | ||
63 | impl_block::{ImplBlock, ImplItem}, | ||
64 | name::Name, | ||
65 | nameres::{ImportId, Namespace, PerNs}, | ||
66 | path::{Path, PathKind}, | ||
68 | resolve::Resolution, | 67 | resolve::Resolution, |
69 | generics::{GenericParams, GenericParam, HasGenericParams}, | 68 | source_binder::{PathResolution, ScopeEntryWithSyntax, SourceAnalyzer}, |
70 | source_binder::{SourceAnalyzer, PathResolution, ScopeEntryWithSyntax}, | 69 | source_id::{AstIdMap, ErasedFileAstId}, |
70 | ty::{display::HirDisplay, ApplicationTy, CallableDef, Substs, TraitRef, Ty, TypeCtor}, | ||
71 | }; | 71 | }; |
72 | 72 | ||
73 | pub use self::code_model::{ | 73 | pub use self::code_model::{ |
74 | Crate, CrateDependency, | 74 | docs::{DocDef, Docs, Documentation}, |
75 | DefWithBody, | 75 | src::{HasSource, Source}, |
76 | Module, ModuleDef, ModuleSource, | 76 | BuiltinType, Const, ConstData, Container, Crate, CrateDependency, DefWithBody, Enum, |
77 | Struct, Union, Enum, EnumVariant, | 77 | EnumVariant, FieldSource, FnData, Function, MacroDef, Module, ModuleDef, ModuleSource, Static, |
78 | Function, FnData, | 78 | Struct, StructField, Trait, TypeAlias, Union, |
79 | StructField, FieldSource, | ||
80 | Static, Const, ConstData, | ||
81 | Trait, TypeAlias, MacroDef, Container, | ||
82 | BuiltinType, | ||
83 | src::{Source, HasSource}, | ||
84 | docs::{Docs, Documentation, DocDef}, | ||
85 | }; | 79 | }; |
diff --git a/crates/ra_hir/src/mock.rs b/crates/ra_hir/src/mock.rs index c57dfbf01..b26ea58c9 100644 --- a/crates/ra_hir/src/mock.rs +++ b/crates/ra_hir/src/mock.rs | |||
@@ -1,13 +1,12 @@ | |||
1 | use std::{sync::Arc, panic}; | 1 | use std::{panic, sync::Arc}; |
2 | 2 | ||
3 | use parking_lot::Mutex; | 3 | use parking_lot::Mutex; |
4 | use ra_db::{ | 4 | use ra_db::{ |
5 | FilePosition, FileId, CrateGraph, SourceRoot, SourceRootId, SourceDatabase, salsa, | 5 | salsa, CrateGraph, Edition, FileId, FilePosition, SourceDatabase, SourceRoot, SourceRootId, |
6 | Edition, | ||
7 | }; | 6 | }; |
8 | use relative_path::RelativePathBuf; | 7 | use relative_path::RelativePathBuf; |
9 | use test_utils::{parse_fixture, CURSOR_MARKER, extract_offset}; | ||
10 | use rustc_hash::FxHashMap; | 8 | use rustc_hash::FxHashMap; |
9 | use test_utils::{extract_offset, parse_fixture, CURSOR_MARKER}; | ||
11 | 10 | ||
12 | use crate::{db, diagnostics::DiagnosticSink}; | 11 | use crate::{db, diagnostics::DiagnosticSink}; |
13 | 12 | ||
diff --git a/crates/ra_hir/src/nameres.rs b/crates/ra_hir/src/nameres.rs index f4ca454e4..53ef8d58a 100644 --- a/crates/ra_hir/src/nameres.rs +++ b/crates/ra_hir/src/nameres.rs | |||
@@ -55,28 +55,24 @@ mod tests; | |||
55 | 55 | ||
56 | use std::sync::Arc; | 56 | use std::sync::Arc; |
57 | 57 | ||
58 | use once_cell::sync::Lazy; | ||
59 | use ra_arena::{impl_arena_id, Arena, RawId}; | ||
60 | use ra_db::{Edition, FileId}; | ||
61 | use ra_prof::profile; | ||
62 | use ra_syntax::ast; | ||
58 | use rustc_hash::{FxHashMap, FxHashSet}; | 63 | use rustc_hash::{FxHashMap, FxHashSet}; |
59 | use ra_arena::{Arena, RawId, impl_arena_id}; | ||
60 | use ra_db::{FileId, Edition}; | ||
61 | use test_utils::tested_by; | 64 | use test_utils::tested_by; |
62 | use ra_syntax::ast; | ||
63 | use ra_prof::profile; | ||
64 | use once_cell::sync::Lazy; | ||
65 | 65 | ||
66 | use crate::{ | 66 | use crate::{ |
67 | ModuleDef, Name, Crate, Module, MacroDef, AsName, BuiltinType, AstDatabase, | 67 | diagnostics::DiagnosticSink, either::Either, ids::MacroDefId, |
68 | DefDatabase, Path, PathKind, HirFileId, Trait, | 68 | nameres::diagnostics::DefDiagnostic, AsName, AstDatabase, AstId, BuiltinType, Crate, |
69 | ids::MacroDefId, | 69 | DefDatabase, HirFileId, MacroDef, Module, ModuleDef, Name, Path, PathKind, Trait, |
70 | diagnostics::DiagnosticSink, | ||
71 | nameres::diagnostics::DefDiagnostic, | ||
72 | either::Either, | ||
73 | AstId, | ||
74 | }; | 70 | }; |
75 | 71 | ||
76 | pub(crate) use self::raw::{RawItems, ImportSourceMap}; | 72 | pub(crate) use self::raw::{ImportSourceMap, RawItems}; |
77 | 73 | ||
78 | pub use self::{ | 74 | pub use self::{ |
79 | per_ns::{PerNs, Namespace}, | 75 | per_ns::{Namespace, PerNs}, |
80 | raw::ImportId, | 76 | raw::ImportId, |
81 | }; | 77 | }; |
82 | 78 | ||
@@ -512,14 +508,14 @@ impl CrateDefMap { | |||
512 | } | 508 | } |
513 | 509 | ||
514 | mod diagnostics { | 510 | mod diagnostics { |
511 | use ra_syntax::{ast, AstPtr}; | ||
515 | use relative_path::RelativePathBuf; | 512 | use relative_path::RelativePathBuf; |
516 | use ra_syntax::{AstPtr, ast}; | ||
517 | 513 | ||
518 | use crate::{ | 514 | use crate::{ |
519 | AstId, DefDatabase, AstDatabase, | 515 | diagnostics::{DiagnosticSink, UnresolvedModule}, |
520 | nameres::CrateModuleId, | 516 | nameres::CrateModuleId, |
521 | diagnostics::{DiagnosticSink, UnresolvedModule} | 517 | AstDatabase, AstId, DefDatabase, |
522 | }; | 518 | }; |
523 | 519 | ||
524 | #[derive(Debug, PartialEq, Eq)] | 520 | #[derive(Debug, PartialEq, Eq)] |
525 | pub(super) enum DefDiagnostic { | 521 | pub(super) enum DefDiagnostic { |
diff --git a/crates/ra_hir/src/nameres/collector.rs b/crates/ra_hir/src/nameres/collector.rs index ef4d1ed70..2b07ebf4a 100644 --- a/crates/ra_hir/src/nameres/collector.rs +++ b/crates/ra_hir/src/nameres/collector.rs | |||
@@ -1,22 +1,19 @@ | |||
1 | use arrayvec::ArrayVec; | 1 | use arrayvec::ArrayVec; |
2 | use rustc_hash::FxHashMap; | ||
3 | use relative_path::RelativePathBuf; | ||
4 | use test_utils::tested_by; | ||
5 | use ra_db::FileId; | 2 | use ra_db::FileId; |
6 | use ra_syntax::ast; | 3 | use ra_syntax::ast; |
4 | use relative_path::RelativePathBuf; | ||
5 | use rustc_hash::FxHashMap; | ||
6 | use test_utils::tested_by; | ||
7 | 7 | ||
8 | use crate::{ | 8 | use crate::{ |
9 | Function, Module, Struct, Union, Enum, Const, Static, Trait, TypeAlias, MacroDef, | 9 | either::Either, |
10 | DefDatabase, HirFileId, Name, Path, | 10 | ids::{AstItemDef, LocationCtx, MacroCallId, MacroCallLoc, MacroDefId, MacroFileKind}, |
11 | KnownName, AstId, | ||
12 | nameres::{ | 11 | nameres::{ |
13 | Resolution, PerNs, ModuleDef, ReachedFixedPoint, ResolveMode, | 12 | diagnostics::DefDiagnostic, raw, CrateDefMap, CrateModuleId, ItemOrMacro, ModuleData, |
14 | CrateDefMap, CrateModuleId, ModuleData, ItemOrMacro, | 13 | ModuleDef, PerNs, ReachedFixedPoint, Resolution, ResolveMode, |
15 | diagnostics::DefDiagnostic, | ||
16 | raw, | ||
17 | }, | 14 | }, |
18 | ids::{AstItemDef, LocationCtx, MacroCallLoc, MacroCallId, MacroDefId, MacroFileKind}, | 15 | AstId, Const, DefDatabase, Enum, Function, HirFileId, KnownName, MacroDef, Module, Name, Path, |
19 | either::Either, | 16 | Static, Struct, Trait, TypeAlias, Union, |
20 | }; | 17 | }; |
21 | 18 | ||
22 | pub(super) fn collect_defs(db: &impl DefDatabase, mut def_map: CrateDefMap) -> CrateDefMap { | 19 | pub(super) fn collect_defs(db: &impl DefDatabase, mut def_map: CrateDefMap) -> CrateDefMap { |
@@ -666,9 +663,9 @@ fn resolve_submodule( | |||
666 | mod tests { | 663 | mod tests { |
667 | use ra_db::SourceDatabase; | 664 | use ra_db::SourceDatabase; |
668 | 665 | ||
669 | use crate::{Crate, mock::MockDatabase, DefDatabase}; | ||
670 | use ra_arena::{Arena}; | ||
671 | use super::*; | 666 | use super::*; |
667 | use crate::{mock::MockDatabase, Crate, DefDatabase}; | ||
668 | use ra_arena::Arena; | ||
672 | use rustc_hash::FxHashSet; | 669 | use rustc_hash::FxHashSet; |
673 | 670 | ||
674 | fn do_collect_defs( | 671 | fn do_collect_defs( |
diff --git a/crates/ra_hir/src/nameres/raw.rs b/crates/ra_hir/src/nameres/raw.rs index a0afe282c..7ea59cb75 100644 --- a/crates/ra_hir/src/nameres/raw.rs +++ b/crates/ra_hir/src/nameres/raw.rs | |||
@@ -1,13 +1,16 @@ | |||
1 | use std::{sync::Arc, ops::Index}; | 1 | use std::{ops::Index, sync::Arc}; |
2 | 2 | ||
3 | use test_utils::tested_by; | 3 | use ra_arena::{impl_arena_id, map::ArenaMap, Arena, RawId}; |
4 | use ra_arena::{Arena, impl_arena_id, RawId, map::ArenaMap}; | ||
5 | use ra_syntax::{ | 4 | use ra_syntax::{ |
6 | AstNode, SourceFile, AstPtr, TreeArc, | 5 | ast::{self, AttrsOwner, NameOwner}, |
7 | ast::{self, NameOwner, AttrsOwner}, | 6 | AstNode, AstPtr, SourceFile, TreeArc, |
8 | }; | 7 | }; |
8 | use test_utils::tested_by; | ||
9 | 9 | ||
10 | use crate::{DefDatabase, Name, AsName, Path, HirFileId, ModuleSource, AstIdMap, FileAstId, Either, AstDatabase}; | 10 | use crate::{ |
11 | AsName, AstDatabase, AstIdMap, DefDatabase, Either, FileAstId, HirFileId, ModuleSource, Name, | ||
12 | Path, | ||
13 | }; | ||
11 | 14 | ||
12 | /// `RawItems` is a set of top-level items in a file (except for impls). | 15 | /// `RawItems` is a set of top-level items in a file (except for impls). |
13 | /// | 16 | /// |
diff --git a/crates/ra_hir/src/nameres/tests.rs b/crates/ra_hir/src/nameres/tests.rs index 07b533e29..bd2d855cf 100644 --- a/crates/ra_hir/src/nameres/tests.rs +++ b/crates/ra_hir/src/nameres/tests.rs | |||
@@ -5,14 +5,14 @@ mod primitives; | |||
5 | 5 | ||
6 | use std::sync::Arc; | 6 | use std::sync::Arc; |
7 | 7 | ||
8 | use insta::assert_snapshot_matches; | ||
8 | use ra_db::SourceDatabase; | 9 | use ra_db::SourceDatabase; |
9 | use test_utils::covers; | 10 | use test_utils::covers; |
10 | use insta::assert_snapshot_matches; | ||
11 | 11 | ||
12 | use crate::{ | 12 | use crate::{ |
13 | Crate, Either, | 13 | mock::{CrateGraphFixture, MockDatabase}, |
14 | mock::{MockDatabase, CrateGraphFixture}, | ||
15 | nameres::Resolution, | 14 | nameres::Resolution, |
15 | Crate, Either, | ||
16 | }; | 16 | }; |
17 | 17 | ||
18 | use super::*; | 18 | use super::*; |
diff --git a/crates/ra_hir/src/path.rs b/crates/ra_hir/src/path.rs index 67afd5027..bce9d2d4b 100644 --- a/crates/ra_hir/src/path.rs +++ b/crates/ra_hir/src/path.rs | |||
@@ -1,8 +1,11 @@ | |||
1 | use std::sync::Arc; | 1 | use std::sync::Arc; |
2 | 2 | ||
3 | use ra_syntax::{ast::{self, NameOwner}, AstNode}; | 3 | use ra_syntax::{ |
4 | ast::{self, NameOwner}, | ||
5 | AstNode, | ||
6 | }; | ||
4 | 7 | ||
5 | use crate::{Name, AsName, type_ref::TypeRef}; | 8 | use crate::{type_ref::TypeRef, AsName, Name}; |
6 | 9 | ||
7 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 10 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
8 | pub struct Path { | 11 | pub struct Path { |
diff --git a/crates/ra_hir/src/resolve.rs b/crates/ra_hir/src/resolve.rs index 7f8b3812c..fc981e9b3 100644 --- a/crates/ra_hir/src/resolve.rs +++ b/crates/ra_hir/src/resolve.rs | |||
@@ -4,16 +4,19 @@ use std::sync::Arc; | |||
4 | use rustc_hash::{FxHashMap, FxHashSet}; | 4 | use rustc_hash::{FxHashMap, FxHashSet}; |
5 | 5 | ||
6 | use crate::{ | 6 | use crate::{ |
7 | ModuleDef, Trait, MacroDef, | ||
8 | code_model::Crate, | 7 | code_model::Crate, |
9 | db::HirDatabase, | 8 | db::HirDatabase, |
10 | name::{Name, KnownName}, | 9 | either::Either, |
11 | nameres::{PerNs, CrateDefMap, CrateModuleId}, | 10 | expr::{ |
11 | scope::{ExprScopes, ScopeId}, | ||
12 | PatId, | ||
13 | }, | ||
12 | generics::GenericParams, | 14 | generics::GenericParams, |
13 | expr::{scope::{ExprScopes, ScopeId}, PatId}, | ||
14 | impl_block::ImplBlock, | 15 | impl_block::ImplBlock, |
16 | name::{KnownName, Name}, | ||
17 | nameres::{CrateDefMap, CrateModuleId, PerNs}, | ||
15 | path::Path, | 18 | path::Path, |
16 | either::Either, | 19 | MacroDef, ModuleDef, Trait, |
17 | }; | 20 | }; |
18 | 21 | ||
19 | #[derive(Debug, Clone, Default)] | 22 | #[derive(Debug, Clone, Default)] |
diff --git a/crates/ra_hir/src/source_binder.rs b/crates/ra_hir/src/source_binder.rs index 08e86844d..429575fee 100644 --- a/crates/ra_hir/src/source_binder.rs +++ b/crates/ra_hir/src/source_binder.rs | |||
@@ -7,21 +7,25 @@ | |||
7 | /// purely for "IDE needs". | 7 | /// purely for "IDE needs". |
8 | use std::sync::Arc; | 8 | use std::sync::Arc; |
9 | 9 | ||
10 | use rustc_hash::{FxHashSet, FxHashMap}; | ||
11 | use ra_db::{FileId, FilePosition}; | 10 | use ra_db::{FileId, FilePosition}; |
12 | use ra_syntax::{ | 11 | use ra_syntax::{ |
13 | SyntaxNode, AstPtr, TextUnit, SyntaxNodePtr, TextRange, | ||
14 | ast::{self, AstNode, NameOwner}, | ||
15 | algo::find_node_at_offset, | 12 | algo::find_node_at_offset, |
13 | ast::{self, AstNode, NameOwner}, | ||
14 | AstPtr, | ||
16 | SyntaxKind::*, | 15 | SyntaxKind::*, |
16 | SyntaxNode, SyntaxNodePtr, TextRange, TextUnit, | ||
17 | }; | 17 | }; |
18 | use rustc_hash::{FxHashMap, FxHashSet}; | ||
18 | 19 | ||
19 | use crate::{ | 20 | use crate::{ |
20 | HirDatabase, Function, Struct, Enum, Const, Static, Either, DefWithBody, PerNs, Name, | 21 | expr, |
21 | AsName, Module, HirFileId, Crate, Trait, Resolver, Ty, Path, MacroDef, | 22 | expr::{ |
22 | expr::{BodySourceMap, scope::{ScopeId, ExprScopes}}, | 23 | scope::{ExprScopes, ScopeId}, |
24 | BodySourceMap, | ||
25 | }, | ||
23 | ids::LocationCtx, | 26 | ids::LocationCtx, |
24 | expr, AstId, | 27 | AsName, AstId, Const, Crate, DefWithBody, Either, Enum, Function, HirDatabase, HirFileId, |
28 | MacroDef, Module, Name, Path, PerNs, Resolver, Static, Struct, Trait, Ty, | ||
25 | }; | 29 | }; |
26 | 30 | ||
27 | /// Locates the module by `FileId`. Picks topmost module in the file. | 31 | /// Locates the module by `FileId`. Picks topmost module in the file. |
diff --git a/crates/ra_hir/src/source_id.rs b/crates/ra_hir/src/source_id.rs index 986269e00..324b79824 100644 --- a/crates/ra_hir/src/source_id.rs +++ b/crates/ra_hir/src/source_id.rs | |||
@@ -1,9 +1,13 @@ | |||
1 | use std::{marker::PhantomData, sync::Arc, hash::{Hash, Hasher}}; | 1 | use std::{ |
2 | hash::{Hash, Hasher}, | ||
3 | marker::PhantomData, | ||
4 | sync::Arc, | ||
5 | }; | ||
2 | 6 | ||
3 | use ra_arena::{Arena, RawId, impl_arena_id}; | 7 | use ra_arena::{impl_arena_id, Arena, RawId}; |
4 | use ra_syntax::{SyntaxNodePtr, TreeArc, SyntaxNode, AstNode, ast}; | 8 | use ra_syntax::{ast, AstNode, SyntaxNode, SyntaxNodePtr, TreeArc}; |
5 | 9 | ||
6 | use crate::{HirFileId, AstDatabase}; | 10 | use crate::{AstDatabase, HirFileId}; |
7 | 11 | ||
8 | /// `AstId` points to an AST node in any file. | 12 | /// `AstId` points to an AST node in any file. |
9 | /// | 13 | /// |
diff --git a/crates/ra_hir/src/traits.rs b/crates/ra_hir/src/traits.rs index f2950e1b2..fc0368303 100644 --- a/crates/ra_hir/src/traits.rs +++ b/crates/ra_hir/src/traits.rs | |||
@@ -1,13 +1,13 @@ | |||
1 | //! HIR for trait definitions. | 1 | //! HIR for trait definitions. |
2 | 2 | ||
3 | use std::sync::Arc; | ||
4 | use rustc_hash::FxHashMap; | 3 | use rustc_hash::FxHashMap; |
4 | use std::sync::Arc; | ||
5 | 5 | ||
6 | use ra_syntax::ast::{self, NameOwner}; | 6 | use ra_syntax::ast::{self, NameOwner}; |
7 | 7 | ||
8 | use crate::{ | 8 | use crate::{ |
9 | Function, Const, TypeAlias, Name, DefDatabase, Trait, AstDatabase, Module, HasSource, | 9 | ids::LocationCtx, name::AsName, AstDatabase, Const, DefDatabase, Function, HasSource, Module, |
10 | ids::LocationCtx, name::AsName, | 10 | Name, Trait, TypeAlias, |
11 | }; | 11 | }; |
12 | 12 | ||
13 | #[derive(Debug, Clone, PartialEq, Eq)] | 13 | #[derive(Debug, Clone, PartialEq, Eq)] |
diff --git a/crates/ra_hir/src/ty.rs b/crates/ra_hir/src/ty.rs index 842d49e1f..11afdc0f3 100644 --- a/crates/ra_hir/src/ty.rs +++ b/crates/ra_hir/src/ty.rs | |||
@@ -12,17 +12,20 @@ mod lower; | |||
12 | mod infer; | 12 | mod infer; |
13 | pub(crate) mod display; | 13 | pub(crate) mod display; |
14 | 14 | ||
15 | use std::sync::Arc; | ||
16 | use std::ops::Deref; | 15 | use std::ops::Deref; |
16 | use std::sync::Arc; | ||
17 | use std::{fmt, mem}; | 17 | use std::{fmt, mem}; |
18 | 18 | ||
19 | use crate::{Name, AdtDef, type_ref::Mutability, db::HirDatabase, Trait, GenericParams, TypeAlias}; | 19 | use crate::{db::HirDatabase, type_ref::Mutability, AdtDef, GenericParams, Name, Trait, TypeAlias}; |
20 | use display::{HirDisplay, HirFormatter}; | 20 | use display::{HirDisplay, HirFormatter}; |
21 | 21 | ||
22 | pub(crate) use lower::{TypableDef, type_for_def, type_for_field, callable_item_sig, generic_predicates, generic_defaults}; | ||
23 | pub(crate) use infer::{infer_query, InferenceResult, InferTy}; | ||
24 | pub use lower::CallableDef; | ||
25 | pub(crate) use autoderef::autoderef; | 22 | pub(crate) use autoderef::autoderef; |
23 | pub(crate) use infer::{infer_query, InferTy, InferenceResult}; | ||
24 | pub use lower::CallableDef; | ||
25 | pub(crate) use lower::{ | ||
26 | callable_item_sig, generic_defaults, generic_predicates, type_for_def, type_for_field, | ||
27 | TypableDef, | ||
28 | }; | ||
26 | pub(crate) use traits::ProjectionPredicate; | 29 | pub(crate) use traits::ProjectionPredicate; |
27 | 30 | ||
28 | /// A type constructor or type name: this might be something like the primitive | 31 | /// A type constructor or type name: this might be something like the primitive |
diff --git a/crates/ra_hir/src/ty/autoderef.rs b/crates/ra_hir/src/ty/autoderef.rs index 1f443d49b..90c1ae630 100644 --- a/crates/ra_hir/src/ty/autoderef.rs +++ b/crates/ra_hir/src/ty/autoderef.rs | |||
@@ -7,8 +7,8 @@ use std::iter::successors; | |||
7 | 7 | ||
8 | use log::{info, warn}; | 8 | use log::{info, warn}; |
9 | 9 | ||
10 | use crate::{HirDatabase, Name, Resolver, HasGenericParams}; | 10 | use super::{traits::Solution, Canonical, Ty}; |
11 | use super::{traits::Solution, Ty, Canonical}; | 11 | use crate::{HasGenericParams, HirDatabase, Name, Resolver}; |
12 | 12 | ||
13 | const AUTODEREF_RECURSION_LIMIT: usize = 10; | 13 | const AUTODEREF_RECURSION_LIMIT: usize = 10; |
14 | 14 | ||
diff --git a/crates/ra_hir/src/ty/infer.rs b/crates/ra_hir/src/ty/infer.rs index 2c05ca734..a2dc92370 100644 --- a/crates/ra_hir/src/ty/infer.rs +++ b/crates/ra_hir/src/ty/infer.rs | |||
@@ -15,38 +15,37 @@ | |||
15 | 15 | ||
16 | use std::borrow::Cow; | 16 | use std::borrow::Cow; |
17 | use std::iter::repeat; | 17 | use std::iter::repeat; |
18 | use std::mem; | ||
18 | use std::ops::Index; | 19 | use std::ops::Index; |
19 | use std::sync::Arc; | 20 | use std::sync::Arc; |
20 | use std::mem; | ||
21 | 21 | ||
22 | use ena::unify::{InPlaceUnificationTable, UnifyKey, UnifyValue, NoError}; | 22 | use ena::unify::{InPlaceUnificationTable, NoError, UnifyKey, UnifyValue}; |
23 | use rustc_hash::FxHashMap; | 23 | use rustc_hash::FxHashMap; |
24 | 24 | ||
25 | use ra_arena::map::ArenaMap; | 25 | use ra_arena::map::ArenaMap; |
26 | use ra_prof::profile; | 26 | use ra_prof::profile; |
27 | use test_utils::tested_by; | 27 | use test_utils::tested_by; |
28 | 28 | ||
29 | use super::{ | ||
30 | autoderef, method_resolution, op, primitive, | ||
31 | traits::{Guidance, Obligation, Solution}, | ||
32 | ApplicationTy, CallableDef, Substs, TraitRef, Ty, TypableDef, TypeCtor, | ||
33 | }; | ||
29 | use crate::{ | 34 | use crate::{ |
30 | Function, StructField, Path, Name, FnData, AdtDef, ConstData, HirDatabase, | 35 | adt::VariantDef, |
31 | DefWithBody, ImplItem, | 36 | diagnostics::DiagnosticSink, |
32 | type_ref::{TypeRef, Mutability}, | ||
33 | expr::{ | 37 | expr::{ |
34 | Body, Expr, BindingAnnotation, Literal, ExprId, Pat, PatId, UnaryOp, BinaryOp, Statement, | 38 | self, Array, BinaryOp, BindingAnnotation, Body, Expr, ExprId, FieldPat, Literal, Pat, |
35 | FieldPat, Array, self, | 39 | PatId, Statement, UnaryOp, |
36 | }, | 40 | }, |
37 | generics::{GenericParams, HasGenericParams}, | 41 | generics::{GenericParams, HasGenericParams}, |
38 | path::{GenericArgs, GenericArg}, | ||
39 | ModuleDef, | ||
40 | adt::VariantDef, | ||
41 | resolve::{Resolver, Resolution}, | ||
42 | nameres::Namespace, | 42 | nameres::Namespace, |
43 | path::{GenericArg, GenericArgs}, | ||
44 | resolve::{Resolution, Resolver}, | ||
43 | ty::infer::diagnostics::InferenceDiagnostic, | 45 | ty::infer::diagnostics::InferenceDiagnostic, |
44 | diagnostics::DiagnosticSink, | 46 | type_ref::{Mutability, TypeRef}, |
45 | }; | 47 | AdtDef, ConstData, DefWithBody, FnData, Function, HirDatabase, ImplItem, ModuleDef, Name, Path, |
46 | use super::{ | 48 | StructField, |
47 | Ty, TypableDef, Substs, primitive, op, ApplicationTy, TypeCtor, CallableDef, TraitRef, | ||
48 | traits::{Solution, Obligation, Guidance}, | ||
49 | method_resolution, autoderef, | ||
50 | }; | 49 | }; |
51 | 50 | ||
52 | mod unify; | 51 | mod unify; |
@@ -1415,10 +1414,10 @@ impl Expectation { | |||
1415 | 1414 | ||
1416 | mod diagnostics { | 1415 | mod diagnostics { |
1417 | use crate::{ | 1416 | use crate::{ |
1418 | expr::ExprId, | ||
1419 | diagnostics::{DiagnosticSink, NoSuchField}, | 1417 | diagnostics::{DiagnosticSink, NoSuchField}, |
1420 | HirDatabase, Function, HasSource, | 1418 | expr::ExprId, |
1421 | }; | 1419 | Function, HasSource, HirDatabase, |
1420 | }; | ||
1422 | 1421 | ||
1423 | #[derive(Debug, PartialEq, Eq, Clone)] | 1422 | #[derive(Debug, PartialEq, Eq, Clone)] |
1424 | pub(super) enum InferenceDiagnostic { | 1423 | pub(super) enum InferenceDiagnostic { |
diff --git a/crates/ra_hir/src/ty/infer/unify.rs b/crates/ra_hir/src/ty/infer/unify.rs index bc9719725..04633bdb2 100644 --- a/crates/ra_hir/src/ty/infer/unify.rs +++ b/crates/ra_hir/src/ty/infer/unify.rs | |||
@@ -1,8 +1,8 @@ | |||
1 | //! Unification and canonicalization logic. | 1 | //! Unification and canonicalization logic. |
2 | 2 | ||
3 | use crate::db::HirDatabase; | ||
4 | use crate::ty::{Ty, Canonical, TraitRef, InferTy}; | ||
5 | use super::InferenceContext; | 3 | use super::InferenceContext; |
4 | use crate::db::HirDatabase; | ||
5 | use crate::ty::{Canonical, InferTy, TraitRef, Ty}; | ||
6 | 6 | ||
7 | impl<'a, D: HirDatabase> InferenceContext<'a, D> { | 7 | impl<'a, D: HirDatabase> InferenceContext<'a, D> { |
8 | pub(super) fn canonicalizer<'b>(&'b mut self) -> Canonicalizer<'a, 'b, D> | 8 | pub(super) fn canonicalizer<'b>(&'b mut self) -> Canonicalizer<'a, 'b, D> |
diff --git a/crates/ra_hir/src/ty/lower.rs b/crates/ra_hir/src/ty/lower.rs index cb494baf4..8b1b2a7f9 100644 --- a/crates/ra_hir/src/ty/lower.rs +++ b/crates/ra_hir/src/ty/lower.rs | |||
@@ -5,23 +5,22 @@ | |||
5 | //! - Building the type for an item: This happens through the `type_for_def` query. | 5 | //! - Building the type for an item: This happens through the `type_for_def` query. |
6 | //! | 6 | //! |
7 | //! This usually involves resolving names, collecting generic arguments etc. | 7 | //! This usually involves resolving names, collecting generic arguments etc. |
8 | use std::sync::Arc; | ||
9 | use std::iter; | 8 | use std::iter; |
9 | use std::sync::Arc; | ||
10 | 10 | ||
11 | use super::{FnSig, GenericPredicate, Substs, TraitRef, Ty, TypeCtor}; | ||
11 | use crate::{ | 12 | use crate::{ |
12 | Function, Struct, Union, StructField, Enum, EnumVariant, Path, ModuleDef, TypeAlias, Const, Static, | ||
13 | HirDatabase, BuiltinType, | ||
14 | type_ref::TypeRef, | ||
15 | nameres::Namespace, | ||
16 | resolve::{Resolver, Resolution}, | ||
17 | path::{PathSegment, GenericArg}, | ||
18 | generics::{HasGenericParams}, | ||
19 | adt::VariantDef, | 13 | adt::VariantDef, |
20 | Trait, | 14 | generics::HasGenericParams, |
21 | generics::{WherePredicate, GenericDef}, | 15 | generics::{GenericDef, WherePredicate}, |
16 | nameres::Namespace, | ||
17 | path::{GenericArg, PathSegment}, | ||
18 | resolve::{Resolution, Resolver}, | ||
22 | ty::AdtDef, | 19 | ty::AdtDef, |
20 | type_ref::TypeRef, | ||
21 | BuiltinType, Const, Enum, EnumVariant, Function, HirDatabase, ModuleDef, Path, Static, Struct, | ||
22 | StructField, Trait, TypeAlias, Union, | ||
23 | }; | 23 | }; |
24 | use super::{Ty, FnSig, Substs, TypeCtor, TraitRef, GenericPredicate}; | ||
25 | 24 | ||
26 | impl Ty { | 25 | impl Ty { |
27 | pub(crate) fn from_hir(db: &impl HirDatabase, resolver: &Resolver, type_ref: &TypeRef) -> Self { | 26 | pub(crate) fn from_hir(db: &impl HirDatabase, resolver: &Resolver, type_ref: &TypeRef) -> Self { |
diff --git a/crates/ra_hir/src/ty/method_resolution.rs b/crates/ra_hir/src/ty/method_resolution.rs index e023ff25a..bc890fe79 100644 --- a/crates/ra_hir/src/ty/method_resolution.rs +++ b/crates/ra_hir/src/ty/method_resolution.rs | |||
@@ -7,17 +7,17 @@ use std::sync::Arc; | |||
7 | use arrayvec::ArrayVec; | 7 | use arrayvec::ArrayVec; |
8 | use rustc_hash::FxHashMap; | 8 | use rustc_hash::FxHashMap; |
9 | 9 | ||
10 | use super::{autoderef, Canonical, TraitRef}; | ||
10 | use crate::{ | 11 | use crate::{ |
11 | HirDatabase, Module, Crate, Name, Function, Trait, | 12 | generics::HasGenericParams, |
12 | impl_block::{ImplId, ImplBlock, ImplItem}, | 13 | impl_block::{ImplBlock, ImplId, ImplItem}, |
13 | ty::{Ty, TypeCtor}, | ||
14 | nameres::CrateModuleId, | 14 | nameres::CrateModuleId, |
15 | resolve::Resolver, | 15 | resolve::Resolver, |
16 | traits::TraitItem, | 16 | traits::TraitItem, |
17 | generics::HasGenericParams, | 17 | ty::primitive::{UncertainFloatTy, UncertainIntTy}, |
18 | ty::primitive::{UncertainIntTy, UncertainFloatTy} | 18 | ty::{Ty, TypeCtor}, |
19 | Crate, Function, HirDatabase, Module, Name, Trait, | ||
19 | }; | 20 | }; |
20 | use super::{TraitRef, Canonical, autoderef}; | ||
21 | 21 | ||
22 | /// This is used as a key for indexing impls. | 22 | /// This is used as a key for indexing impls. |
23 | #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] | 23 | #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] |
diff --git a/crates/ra_hir/src/ty/op.rs b/crates/ra_hir/src/ty/op.rs index 235661a5d..9ba868298 100644 --- a/crates/ra_hir/src/ty/op.rs +++ b/crates/ra_hir/src/ty/op.rs | |||
@@ -1,5 +1,5 @@ | |||
1 | use crate::{ ty::ApplicationTy, expr::BinaryOp}; | 1 | use super::{InferTy, Ty, TypeCtor}; |
2 | use super::{Ty, TypeCtor, InferTy}; | 2 | use crate::{expr::BinaryOp, ty::ApplicationTy}; |
3 | 3 | ||
4 | pub(super) fn binary_op_return_ty(op: BinaryOp, rhs_ty: Ty) -> Ty { | 4 | pub(super) fn binary_op_return_ty(op: BinaryOp, rhs_ty: Ty) -> Ty { |
5 | match op { | 5 | match op { |
diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs index 0fe7805e2..20fa74fb4 100644 --- a/crates/ra_hir/src/ty/tests.rs +++ b/crates/ra_hir/src/ty/tests.rs | |||
@@ -1,17 +1,18 @@ | |||
1 | use std::sync::Arc; | ||
2 | use std::fmt::Write; | 1 | use std::fmt::Write; |
2 | use std::sync::Arc; | ||
3 | 3 | ||
4 | use insta::assert_snapshot_matches; | 4 | use insta::assert_snapshot_matches; |
5 | 5 | ||
6 | use ra_db::{SourceDatabase, salsa::Database, FilePosition}; | 6 | use ra_db::{salsa::Database, FilePosition, SourceDatabase}; |
7 | use ra_syntax::{algo, ast::{self, AstNode}, SyntaxKind::*}; | 7 | use ra_syntax::{ |
8 | algo, | ||
9 | ast::{self, AstNode}, | ||
10 | SyntaxKind::*, | ||
11 | }; | ||
8 | use test_utils::covers; | 12 | use test_utils::covers; |
9 | 13 | ||
10 | use crate::{ | 14 | use crate::{ |
11 | mock::MockDatabase, | 15 | expr::BodySourceMap, mock::MockDatabase, ty::display::HirDisplay, ty::InferenceResult, |
12 | ty::display::HirDisplay, | ||
13 | ty::InferenceResult, | ||
14 | expr::BodySourceMap, | ||
15 | SourceAnalyzer, | 16 | SourceAnalyzer, |
16 | }; | 17 | }; |
17 | 18 | ||
diff --git a/crates/ra_hir/src/ty/traits.rs b/crates/ra_hir/src/ty/traits.rs index 69c03a36c..3c902451b 100644 --- a/crates/ra_hir/src/ty/traits.rs +++ b/crates/ra_hir/src/ty/traits.rs | |||
@@ -1,16 +1,16 @@ | |||
1 | //! Trait solving using Chalk. | 1 | //! Trait solving using Chalk. |
2 | use std::sync::Arc; | 2 | use std::sync::Arc; |
3 | 3 | ||
4 | use parking_lot::Mutex; | ||
5 | use rustc_hash::FxHashSet; | ||
6 | use log::debug; | ||
7 | use chalk_ir::cast::Cast; | 4 | use chalk_ir::cast::Cast; |
5 | use log::debug; | ||
6 | use parking_lot::Mutex; | ||
8 | use ra_prof::profile; | 7 | use ra_prof::profile; |
8 | use rustc_hash::FxHashSet; | ||
9 | 9 | ||
10 | use crate::{Crate, Trait, db::HirDatabase, ImplBlock}; | 10 | use super::{Canonical, ProjectionTy, TraitRef, Ty}; |
11 | use super::{TraitRef, Ty, Canonical, ProjectionTy}; | 11 | use crate::{db::HirDatabase, Crate, ImplBlock, Trait}; |
12 | 12 | ||
13 | use self::chalk::{ToChalk, from_chalk}; | 13 | use self::chalk::{from_chalk, ToChalk}; |
14 | 14 | ||
15 | pub(crate) mod chalk; | 15 | pub(crate) mod chalk; |
16 | 16 | ||
diff --git a/crates/ra_hir/src/ty/traits/chalk.rs b/crates/ra_hir/src/ty/traits/chalk.rs index 4ceb8b70b..2a0537bc3 100644 --- a/crates/ra_hir/src/ty/traits/chalk.rs +++ b/crates/ra_hir/src/ty/traits/chalk.rs | |||
@@ -3,20 +3,25 @@ use std::sync::Arc; | |||
3 | 3 | ||
4 | use log::debug; | 4 | use log::debug; |
5 | 5 | ||
6 | use chalk_ir::{TypeId, ImplId, TypeKindId, Parameter, Identifier, cast::Cast, PlaceholderIndex, UniverseIndex, TypeName}; | 6 | use chalk_ir::{ |
7 | use chalk_rust_ir::{AssociatedTyDatum, TraitDatum, StructDatum, ImplDatum}; | 7 | cast::Cast, Identifier, ImplId, Parameter, PlaceholderIndex, TypeId, TypeKindId, TypeName, |
8 | UniverseIndex, | ||
9 | }; | ||
10 | use chalk_rust_ir::{AssociatedTyDatum, ImplDatum, StructDatum, TraitDatum}; | ||
8 | 11 | ||
9 | use test_utils::tested_by; | ||
10 | use ra_db::salsa::{InternId, InternKey}; | 12 | use ra_db::salsa::{InternId, InternKey}; |
13 | use test_utils::tested_by; | ||
11 | 14 | ||
15 | use super::ChalkContext; | ||
12 | use crate::{ | 16 | use crate::{ |
13 | Trait, HasGenericParams, ImplBlock, Crate, | ||
14 | db::HirDatabase, | 17 | db::HirDatabase, |
15 | ty::{TraitRef, Ty, ApplicationTy, TypeCtor, Substs, GenericPredicate, CallableDef, ProjectionTy}, | 18 | generics::GenericDef, |
16 | ty::display::HirDisplay, | 19 | ty::display::HirDisplay, |
17 | generics::GenericDef, TypeAlias, ImplItem, | 20 | ty::{ |
21 | ApplicationTy, CallableDef, GenericPredicate, ProjectionTy, Substs, TraitRef, Ty, TypeCtor, | ||
22 | }, | ||
23 | Crate, HasGenericParams, ImplBlock, ImplItem, Trait, TypeAlias, | ||
18 | }; | 24 | }; |
19 | use super::ChalkContext; | ||
20 | 25 | ||
21 | /// This represents a trait whose name we could not resolve. | 26 | /// This represents a trait whose name we could not resolve. |
22 | const UNKNOWN_TRAIT: chalk_ir::TraitId = | 27 | const UNKNOWN_TRAIT: chalk_ir::TraitId = |
diff --git a/crates/ra_hir/src/type_alias.rs b/crates/ra_hir/src/type_alias.rs index eada37274..3b38c4740 100644 --- a/crates/ra_hir/src/type_alias.rs +++ b/crates/ra_hir/src/type_alias.rs | |||
@@ -4,7 +4,12 @@ use std::sync::Arc; | |||
4 | 4 | ||
5 | use ra_syntax::ast::NameOwner; | 5 | use ra_syntax::ast::NameOwner; |
6 | 6 | ||
7 | use crate::{TypeAlias, db::{DefDatabase, AstDatabase}, type_ref::TypeRef, name::{Name, AsName}, HasSource}; | 7 | use crate::{ |
8 | db::{AstDatabase, DefDatabase}, | ||
9 | name::{AsName, Name}, | ||
10 | type_ref::TypeRef, | ||
11 | HasSource, TypeAlias, | ||
12 | }; | ||
8 | 13 | ||
9 | #[derive(Debug, Clone, PartialEq, Eq)] | 14 | #[derive(Debug, Clone, PartialEq, Eq)] |
10 | pub struct TypeAliasData { | 15 | pub struct TypeAliasData { |