mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-28 05:53:45 +00:00
cleanup hir db imports
This commit is contained in:
parent
787f1206a9
commit
6021a2a83a
24 changed files with 65 additions and 43 deletions
|
@ -7,8 +7,10 @@ use ra_arena::{impl_arena_id, Arena, RawId};
|
|||
use ra_syntax::ast::{self, NameOwner, StructKind, TypeAscriptionOwner};
|
||||
|
||||
use crate::{
|
||||
type_ref::TypeRef, AsName, AstDatabase, Crate, DefDatabase, Enum, EnumVariant, FieldSource,
|
||||
HasSource, HirDatabase, Name, Source, Struct, StructField, Union,
|
||||
db::{AstDatabase, DefDatabase, HirDatabase},
|
||||
type_ref::TypeRef,
|
||||
AsName, Crate, Enum, EnumVariant, FieldSource, HasSource, Name, Source, Struct, StructField,
|
||||
Union,
|
||||
};
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
||||
|
|
|
@ -8,6 +8,7 @@ use ra_syntax::ast::{self, NameOwner, TypeAscriptionOwner};
|
|||
|
||||
use crate::{
|
||||
adt::{EnumVariantId, StructFieldId, VariantDef},
|
||||
db::{AstDatabase, DefDatabase, HirDatabase},
|
||||
diagnostics::DiagnosticSink,
|
||||
expr::{validation::ExprValidator, Body, BodySourceMap},
|
||||
generics::HasGenericParams,
|
||||
|
@ -29,7 +30,7 @@ use crate::{
|
|||
},
|
||||
type_ref::Mutability,
|
||||
type_ref::TypeRef,
|
||||
AsName, AstDatabase, AstId, DefDatabase, Either, HasSource, HirDatabase, Name, Ty,
|
||||
AsName, AstId, Either, HasSource, Name, Ty,
|
||||
};
|
||||
|
||||
/// hir::Crate describes a single crate. It's the main interface with which
|
||||
|
|
|
@ -3,8 +3,9 @@ use std::sync::Arc;
|
|||
use ra_syntax::ast;
|
||||
|
||||
use crate::{
|
||||
AstDatabase, Const, DefDatabase, Enum, EnumVariant, FieldSource, Function, HasSource,
|
||||
HirDatabase, MacroDef, Module, Static, Struct, StructField, Trait, TypeAlias, Union,
|
||||
db::{AstDatabase, DefDatabase, HirDatabase},
|
||||
Const, Enum, EnumVariant, FieldSource, Function, HasSource, MacroDef, Module, Static, Struct,
|
||||
StructField, Trait, TypeAlias, Union,
|
||||
};
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
||||
|
|
|
@ -4,9 +4,10 @@ use ra_syntax::{
|
|||
};
|
||||
|
||||
use crate::{
|
||||
ids::AstItemDef, AstDatabase, Const, DefDatabase, Either, Enum, EnumVariant, FieldSource,
|
||||
Function, HasBody, HirDatabase, HirFileId, MacroDef, Module, ModuleSource, Static, Struct,
|
||||
StructField, Trait, TypeAlias, Union,
|
||||
db::{AstDatabase, DefDatabase, HirDatabase},
|
||||
ids::AstItemDef,
|
||||
Const, Either, Enum, EnumVariant, FieldSource, Function, HasBody, HirFileId, MacroDef, Module,
|
||||
ModuleSource, Static, Struct, StructField, Trait, TypeAlias, Union,
|
||||
};
|
||||
|
||||
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
|
||||
|
|
|
@ -3,7 +3,7 @@ use std::{any::Any, fmt};
|
|||
use ra_syntax::{ast, AstNode, AstPtr, SyntaxNode, SyntaxNodePtr, TextRange};
|
||||
use relative_path::RelativePathBuf;
|
||||
|
||||
use crate::{HirDatabase, HirFileId, Name, Source};
|
||||
use crate::{db::HirDatabase, HirFileId, Name, Source};
|
||||
|
||||
/// Diagnostic defines hir API for errors and warnings.
|
||||
///
|
||||
|
|
|
@ -9,10 +9,11 @@ use ra_syntax::{ast, AstPtr};
|
|||
use rustc_hash::FxHashMap;
|
||||
|
||||
use crate::{
|
||||
db::HirDatabase,
|
||||
path::GenericArgs,
|
||||
ty::primitive::{UncertainFloatTy, UncertainIntTy},
|
||||
type_ref::{Mutability, TypeRef},
|
||||
DefWithBody, Either, HasSource, HirDatabase, Name, Path, Resolver, Source,
|
||||
DefWithBody, Either, HasSource, Name, Path, Resolver, Source,
|
||||
};
|
||||
|
||||
pub use self::scope::ExprScopes;
|
||||
|
|
|
@ -9,12 +9,13 @@ use ra_syntax::{
|
|||
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,
|
||||
DefWithBody, Either, HirDatabase, HirFileId, MacroCallLoc, MacroFileKind, Mutability, Path,
|
||||
Resolver, Source,
|
||||
DefWithBody, Either, HirFileId, MacroCallLoc, MacroFileKind, Mutability, Path, Resolver,
|
||||
Source,
|
||||
};
|
||||
|
||||
use super::{
|
||||
|
|
|
@ -4,8 +4,9 @@ use ra_arena::{impl_arena_id, Arena, RawId};
|
|||
use rustc_hash::FxHashMap;
|
||||
|
||||
use crate::{
|
||||
db::HirDatabase,
|
||||
expr::{Body, Expr, ExprId, Pat, PatId, Statement},
|
||||
DefWithBody, HirDatabase, Name,
|
||||
DefWithBody, Name,
|
||||
};
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
|
|
|
@ -5,12 +5,13 @@ use rustc_hash::FxHashSet;
|
|||
|
||||
use crate::{
|
||||
adt::AdtDef,
|
||||
db::HirDatabase,
|
||||
diagnostics::{DiagnosticSink, MissingFields, MissingOkInTailExpr},
|
||||
expr::AstPtr,
|
||||
name,
|
||||
path::{PathKind, PathSegment},
|
||||
ty::{ApplicationTy, InferenceResult, Ty, TypeCtor},
|
||||
Function, HirDatabase, ModuleDef, Name, Path, PerNs, Resolution,
|
||||
Function, ModuleDef, Name, Path, PerNs, Resolution,
|
||||
};
|
||||
|
||||
use super::{Expr, ExprId, RecordLitField};
|
||||
|
|
|
@ -8,7 +8,10 @@ use ra_db::{salsa, FileId};
|
|||
use ra_prof::profile;
|
||||
use ra_syntax::{ast, AstNode, Parse, SyntaxNode};
|
||||
|
||||
use crate::{AstDatabase, AstId, DefDatabase, FileAstId, InternDatabase, Module, Source};
|
||||
use crate::{
|
||||
db::{AstDatabase, DefDatabase, InternDatabase},
|
||||
AstId, FileAstId, Module, Source,
|
||||
};
|
||||
|
||||
/// hir makes heavy use of ids: integer (u32) handlers to various things. You
|
||||
/// can think of id as a pointer (but without a lifetime) or a file descriptor
|
||||
|
|
|
@ -9,13 +9,13 @@ use ra_syntax::{
|
|||
|
||||
use crate::{
|
||||
code_model::{Module, ModuleSource},
|
||||
db::{AstDatabase, DefDatabase, HirDatabase},
|
||||
generics::HasGenericParams,
|
||||
ids::LocationCtx,
|
||||
resolve::Resolver,
|
||||
ty::Ty,
|
||||
type_ref::TypeRef,
|
||||
AstDatabase, Const, DefDatabase, Function, HasSource, HirDatabase, HirFileId, Source, TraitRef,
|
||||
TypeAlias,
|
||||
Const, Function, HasSource, HirFileId, Source, TraitRef, TypeAlias,
|
||||
};
|
||||
|
||||
#[derive(Debug, Default, PartialEq, Eq)]
|
||||
|
|
|
@ -4,8 +4,8 @@ use std::sync::Arc;
|
|||
use ra_syntax::{ast::AttrsOwner, SmolStr};
|
||||
|
||||
use crate::{
|
||||
AstDatabase, Crate, DefDatabase, Enum, Function, HasSource, HirDatabase, ImplBlock, Module,
|
||||
ModuleDef, Static, Struct, Trait,
|
||||
db::{AstDatabase, DefDatabase, HirDatabase},
|
||||
Crate, Enum, Function, HasSource, ImplBlock, Module, ModuleDef, Static, Struct, Trait,
|
||||
};
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
|
|
|
@ -49,7 +49,6 @@ mod code_model;
|
|||
mod marks;
|
||||
|
||||
use crate::{
|
||||
db::{AstDatabase, DefDatabase, HirDatabase, InternDatabase},
|
||||
ids::MacroFileKind,
|
||||
name::AsName,
|
||||
resolve::Resolver,
|
||||
|
|
|
@ -65,9 +65,12 @@ use rustc_hash::{FxHashMap, FxHashSet};
|
|||
use test_utils::tested_by;
|
||||
|
||||
use crate::{
|
||||
diagnostics::DiagnosticSink, either::Either, ids::MacroDefId,
|
||||
nameres::diagnostics::DefDiagnostic, AstDatabase, AstId, BuiltinType, Crate, DefDatabase,
|
||||
HirFileId, MacroDef, Module, ModuleDef, Name, Path, PathKind, Trait,
|
||||
db::{AstDatabase, DefDatabase},
|
||||
diagnostics::DiagnosticSink,
|
||||
either::Either,
|
||||
ids::MacroDefId,
|
||||
nameres::diagnostics::DefDiagnostic,
|
||||
AstId, BuiltinType, Crate, HirFileId, MacroDef, Module, ModuleDef, Name, Path, PathKind, Trait,
|
||||
};
|
||||
|
||||
pub(crate) use self::raw::{ImportSourceMap, RawItems};
|
||||
|
@ -516,9 +519,10 @@ mod diagnostics {
|
|||
use relative_path::RelativePathBuf;
|
||||
|
||||
use crate::{
|
||||
db::{AstDatabase, DefDatabase},
|
||||
diagnostics::{DiagnosticSink, UnresolvedModule},
|
||||
nameres::CrateModuleId,
|
||||
AstDatabase, AstId, DefDatabase,
|
||||
AstId,
|
||||
};
|
||||
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
|
|
|
@ -4,6 +4,7 @@ use rustc_hash::FxHashMap;
|
|||
use test_utils::tested_by;
|
||||
|
||||
use crate::{
|
||||
db::DefDatabase,
|
||||
either::Either,
|
||||
ids::{AstItemDef, LocationCtx, MacroCallId, MacroCallLoc, MacroDefId, MacroFileKind},
|
||||
name::MACRO_RULES,
|
||||
|
@ -13,8 +14,8 @@ use crate::{
|
|||
raw, CrateDefMap, CrateModuleId, ItemOrMacro, ModuleData, ModuleDef, PerNs,
|
||||
ReachedFixedPoint, Resolution, ResolveMode,
|
||||
},
|
||||
AstId, Const, DefDatabase, Enum, Function, HirFileId, MacroDef, Module, Name, Path, Static,
|
||||
Struct, Trait, TypeAlias, Union,
|
||||
AstId, Const, Enum, Function, HirFileId, MacroDef, Module, Name, Path, Static, Struct, Trait,
|
||||
TypeAlias, Union,
|
||||
};
|
||||
|
||||
pub(super) fn collect_defs(db: &impl DefDatabase, mut def_map: CrateDefMap) -> CrateDefMap {
|
||||
|
@ -699,7 +700,7 @@ mod tests {
|
|||
use ra_db::SourceDatabase;
|
||||
|
||||
use super::*;
|
||||
use crate::{mock::MockDatabase, Crate, DefDatabase};
|
||||
use crate::{db::DefDatabase, mock::MockDatabase, Crate};
|
||||
use ra_arena::Arena;
|
||||
use rustc_hash::FxHashSet;
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ use ra_db::{FileId, SourceRoot};
|
|||
use ra_syntax::SmolStr;
|
||||
use relative_path::RelativePathBuf;
|
||||
|
||||
use crate::{DefDatabase, HirFileId, Name};
|
||||
use crate::{db::DefDatabase, HirFileId, Name};
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
pub(super) struct ParentModule<'a> {
|
||||
|
|
|
@ -8,8 +8,8 @@ use ra_syntax::{
|
|||
use test_utils::tested_by;
|
||||
|
||||
use crate::{
|
||||
AsName, AstDatabase, AstIdMap, DefDatabase, Either, FileAstId, HirFileId, ModuleSource, Name,
|
||||
Path,
|
||||
db::{AstDatabase, DefDatabase},
|
||||
AsName, AstIdMap, Either, FileAstId, HirFileId, ModuleSource, Name, Path,
|
||||
};
|
||||
|
||||
/// `RawItems` is a set of top-level items in a file (except for impls).
|
||||
|
|
|
@ -18,6 +18,7 @@ use ra_syntax::{
|
|||
use rustc_hash::{FxHashMap, FxHashSet};
|
||||
|
||||
use crate::{
|
||||
db::HirDatabase,
|
||||
expr::{
|
||||
self,
|
||||
scope::{ExprScopes, ScopeId},
|
||||
|
@ -27,9 +28,8 @@ use crate::{
|
|||
name,
|
||||
path::{PathKind, PathSegment},
|
||||
ty::method_resolution::implements_trait,
|
||||
AsName, AstId, Const, Crate, DefWithBody, Either, Enum, Function, HasBody, HirDatabase,
|
||||
HirFileId, MacroDef, Module, ModuleDef, Name, Path, PerNs, Resolution, Resolver, Static,
|
||||
Struct, Trait, Ty,
|
||||
AsName, AstId, Const, Crate, DefWithBody, Either, Enum, Function, HasBody, HirFileId, MacroDef,
|
||||
Module, ModuleDef, Name, Path, PerNs, Resolution, Resolver, Static, Struct, Trait, Ty,
|
||||
};
|
||||
|
||||
/// Locates the module by `FileId`. Picks topmost module in the file.
|
||||
|
|
|
@ -7,7 +7,7 @@ use std::{
|
|||
use ra_arena::{impl_arena_id, Arena, RawId};
|
||||
use ra_syntax::{ast, AstNode, SyntaxNode, SyntaxNodePtr};
|
||||
|
||||
use crate::{AstDatabase, HirFileId};
|
||||
use crate::{db::AstDatabase, HirFileId};
|
||||
|
||||
/// `AstId` points to an AST node in any file.
|
||||
///
|
||||
|
|
|
@ -6,8 +6,10 @@ use std::sync::Arc;
|
|||
use ra_syntax::ast::{self, NameOwner};
|
||||
|
||||
use crate::{
|
||||
ids::LocationCtx, name::AsName, AstDatabase, Const, DefDatabase, Function, HasSource, Module,
|
||||
Name, Trait, TypeAlias,
|
||||
db::{AstDatabase, DefDatabase},
|
||||
ids::LocationCtx,
|
||||
name::AsName,
|
||||
Const, Function, HasSource, Module, Name, Trait, TypeAlias,
|
||||
};
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
|
|
|
@ -8,7 +8,7 @@ use std::iter::successors;
|
|||
use log::{info, warn};
|
||||
|
||||
use super::{traits::Solution, Canonical, Ty, TypeWalk};
|
||||
use crate::{name, HasGenericParams, HirDatabase, Resolver};
|
||||
use crate::{db::HirDatabase, name, HasGenericParams, Resolver};
|
||||
|
||||
const AUTODEREF_RECURSION_LIMIT: usize = 10;
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@ use super::{
|
|||
use crate::{
|
||||
adt::VariantDef,
|
||||
code_model::{ModuleDef::Trait, TypeAlias},
|
||||
db::HirDatabase,
|
||||
diagnostics::DiagnosticSink,
|
||||
expr::{
|
||||
self, Array, BinaryOp, BindingAnnotation, Body, Expr, ExprId, Literal, Pat, PatId,
|
||||
|
@ -50,8 +51,8 @@ use crate::{
|
|||
},
|
||||
ty::infer::diagnostics::InferenceDiagnostic,
|
||||
type_ref::{Mutability, TypeRef},
|
||||
AdtDef, ConstData, DefWithBody, FnData, Function, HasBody, HirDatabase, ImplItem, ModuleDef,
|
||||
Name, Path, StructField,
|
||||
AdtDef, ConstData, DefWithBody, FnData, Function, HasBody, ImplItem, ModuleDef, Name, Path,
|
||||
StructField,
|
||||
};
|
||||
|
||||
mod unify;
|
||||
|
@ -1614,9 +1615,10 @@ impl Expectation {
|
|||
|
||||
mod diagnostics {
|
||||
use crate::{
|
||||
db::HirDatabase,
|
||||
diagnostics::{DiagnosticSink, NoSuchField},
|
||||
expr::ExprId,
|
||||
Function, HasSource, HirDatabase,
|
||||
Function, HasSource,
|
||||
};
|
||||
|
||||
#[derive(Debug, PartialEq, Eq, Clone)]
|
||||
|
|
|
@ -14,6 +14,7 @@ use super::{
|
|||
};
|
||||
use crate::{
|
||||
adt::VariantDef,
|
||||
db::HirDatabase,
|
||||
generics::HasGenericParams,
|
||||
generics::{GenericDef, WherePredicate},
|
||||
nameres::Namespace,
|
||||
|
@ -21,8 +22,8 @@ use crate::{
|
|||
resolve::{Resolution, Resolver},
|
||||
ty::AdtDef,
|
||||
type_ref::{TypeBound, TypeRef},
|
||||
BuiltinType, Const, Enum, EnumVariant, Function, HirDatabase, ModuleDef, Path, Static, Struct,
|
||||
StructField, Trait, TypeAlias, Union,
|
||||
BuiltinType, Const, Enum, EnumVariant, Function, ModuleDef, Path, Static, Struct, StructField,
|
||||
Trait, TypeAlias, Union,
|
||||
};
|
||||
|
||||
impl Ty {
|
||||
|
|
|
@ -9,6 +9,7 @@ use rustc_hash::FxHashMap;
|
|||
|
||||
use super::{autoderef, lower, Canonical, InEnvironment, TraitEnvironment, TraitRef};
|
||||
use crate::{
|
||||
db::HirDatabase,
|
||||
generics::HasGenericParams,
|
||||
impl_block::{ImplBlock, ImplId, ImplItem},
|
||||
nameres::CrateModuleId,
|
||||
|
@ -16,7 +17,7 @@ use crate::{
|
|||
traits::TraitItem,
|
||||
ty::primitive::{FloatBitness, UncertainFloatTy, UncertainIntTy},
|
||||
ty::{Ty, TypeCtor},
|
||||
Crate, Function, HirDatabase, Module, Name, Trait,
|
||||
Crate, Function, Module, Name, Trait,
|
||||
};
|
||||
|
||||
/// This is used as a key for indexing impls.
|
||||
|
|
Loading…
Reference in a new issue