mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 13:51:31 +00:00
allow rustfmt to reorder imports
This wasn't a right decision in the first place, the feature flag was broken in the last rustfmt release, and syntax highlighting of imports is more important anyway
This commit is contained in:
parent
2b2cd829b0
commit
1834bae5b8
166 changed files with 798 additions and 814 deletions
|
@ -3,16 +3,15 @@
|
|||
|
||||
use std::sync::Arc;
|
||||
|
||||
use ra_arena::{RawId, Arena, impl_arena_id};
|
||||
use ra_arena::{impl_arena_id, Arena, RawId};
|
||||
use ra_syntax::{
|
||||
ast::{self, NameOwner, StructKind, TypeAscriptionOwner},
|
||||
TreeArc,
|
||||
ast::{self, NameOwner, StructKind, TypeAscriptionOwner}
|
||||
};
|
||||
|
||||
use crate::{
|
||||
Name, AsName, Struct, Union, Enum, EnumVariant, Crate, AstDatabase,
|
||||
HirDatabase, StructField, FieldSource, Source, HasSource,
|
||||
type_ref::TypeRef, DefDatabase,
|
||||
type_ref::TypeRef, AsName, AstDatabase, Crate, DefDatabase, Enum, EnumVariant, FieldSource,
|
||||
HasSource, HirDatabase, Name, Source, Struct, StructField, Union,
|
||||
};
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
||||
|
|
|
@ -3,24 +3,32 @@ pub(crate) mod docs;
|
|||
|
||||
use std::sync::Arc;
|
||||
|
||||
use ra_db::{CrateId, SourceRootId, Edition, FileId};
|
||||
use ra_syntax::{ast::{self, NameOwner, TypeAscriptionOwner}, TreeArc};
|
||||
use ra_db::{CrateId, Edition, FileId, SourceRootId};
|
||||
use ra_syntax::{
|
||||
ast::{self, NameOwner, TypeAscriptionOwner},
|
||||
TreeArc,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
Name, AsName, AstId, Ty, Either, KnownName, HasSource,
|
||||
HirDatabase, DefDatabase, AstDatabase,
|
||||
type_ref::TypeRef,
|
||||
nameres::{ModuleScope, Namespace, ImportId, CrateModuleId},
|
||||
expr::{Body, BodySourceMap, validation::ExprValidator},
|
||||
ty::{TraitRef, InferenceResult, primitive::{IntTy, FloatTy, Signedness, IntBitness, FloatBitness}},
|
||||
adt::{EnumVariantId, StructFieldId, VariantDef},
|
||||
diagnostics::DiagnosticSink,
|
||||
expr::{validation::ExprValidator, Body, BodySourceMap},
|
||||
generics::HasGenericParams,
|
||||
ids::{FunctionId, StructId, EnumId, AstItemDef, ConstId, StaticId, TraitId, TypeAliasId, MacroDefId},
|
||||
ids::{
|
||||
AstItemDef, ConstId, EnumId, FunctionId, MacroDefId, StaticId, StructId, TraitId,
|
||||
TypeAliasId,
|
||||
},
|
||||
impl_block::ImplBlock,
|
||||
nameres::{CrateModuleId, ImportId, ModuleScope, Namespace},
|
||||
resolve::Resolver,
|
||||
diagnostics::{DiagnosticSink},
|
||||
traits::{TraitItem, TraitData},
|
||||
traits::{TraitData, TraitItem},
|
||||
ty::{
|
||||
primitive::{FloatBitness, FloatTy, IntBitness, IntTy, Signedness},
|
||||
InferenceResult, TraitRef,
|
||||
},
|
||||
type_ref::Mutability,
|
||||
type_ref::TypeRef,
|
||||
AsName, AstDatabase, AstId, DefDatabase, Either, HasSource, HirDatabase, KnownName, Name, Ty,
|
||||
};
|
||||
|
||||
/// hir::Crate describes a single crate. It's the main interface with which
|
||||
|
|
|
@ -3,8 +3,8 @@ use std::sync::Arc;
|
|||
use ra_syntax::ast;
|
||||
|
||||
use crate::{
|
||||
HirDatabase, DefDatabase, AstDatabase, HasSource,
|
||||
Module, StructField, Struct, Enum, EnumVariant, Static, Const, Function, Union, Trait, TypeAlias, FieldSource, MacroDef,
|
||||
AstDatabase, Const, DefDatabase, Enum, EnumVariant, FieldSource, Function, HasSource,
|
||||
HirDatabase, MacroDef, Module, Static, Struct, StructField, Trait, TypeAlias, Union,
|
||||
};
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
use ra_syntax::{TreeArc, ast};
|
||||
use ra_syntax::{ast, TreeArc};
|
||||
|
||||
use crate::{
|
||||
HirFileId, DefDatabase, AstDatabase, Module, ModuleSource,
|
||||
StructField, Struct, Enum, Union, EnumVariant, Function, Static, Trait, Const, TypeAlias,
|
||||
FieldSource, MacroDef, ids::AstItemDef,
|
||||
ids::AstItemDef, AstDatabase, Const, DefDatabase, Enum, EnumVariant, FieldSource, Function,
|
||||
HirFileId, MacroDef, Module, ModuleSource, Static, Struct, StructField, Trait, TypeAlias,
|
||||
Union,
|
||||
};
|
||||
|
||||
pub struct Source<T> {
|
||||
|
|
|
@ -1,23 +1,25 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use parking_lot::Mutex;
|
||||
use ra_syntax::{SyntaxNode, TreeArc, SmolStr, ast};
|
||||
use ra_db::{SourceDatabase, salsa};
|
||||
use ra_db::{salsa, SourceDatabase};
|
||||
use ra_syntax::{ast, SmolStr, SyntaxNode, TreeArc};
|
||||
|
||||
use crate::{
|
||||
HirFileId, MacroDefId, AstIdMap, ErasedFileAstId, Crate, Module, MacroCallLoc,
|
||||
Function, FnData, ExprScopes, TypeAlias,
|
||||
Struct, Enum, StructField,
|
||||
Const, ConstData, Static,
|
||||
DefWithBody, Trait,
|
||||
adt::{EnumData, StructData},
|
||||
generics::{GenericDef, GenericParams},
|
||||
ids,
|
||||
nameres::{Namespace, ImportSourceMap, RawItems, CrateDefMap},
|
||||
ty::{InferenceResult, Ty, method_resolution::CrateImplBlocks, TypableDef, CallableDef, FnSig, TypeCtor, GenericPredicate, Substs},
|
||||
adt::{StructData, EnumData},
|
||||
impl_block::{ModuleImplBlocks, ImplSourceMap, ImplBlock},
|
||||
generics::{GenericParams, GenericDef},
|
||||
impl_block::{ImplBlock, ImplSourceMap, ModuleImplBlocks},
|
||||
lang_item::{LangItemTarget, LangItems},
|
||||
nameres::{CrateDefMap, ImportSourceMap, Namespace, RawItems},
|
||||
traits::TraitData,
|
||||
lang_item::{LangItems, LangItemTarget}, type_alias::TypeAliasData,
|
||||
ty::{
|
||||
method_resolution::CrateImplBlocks, CallableDef, FnSig, GenericPredicate, InferenceResult,
|
||||
Substs, Ty, TypableDef, TypeCtor,
|
||||
},
|
||||
type_alias::TypeAliasData,
|
||||
AstIdMap, Const, ConstData, Crate, DefWithBody, Enum, ErasedFileAstId, ExprScopes, FnData,
|
||||
Function, HirFileId, MacroCallLoc, MacroDefId, Module, Static, Struct, StructField, Trait,
|
||||
TypeAlias,
|
||||
};
|
||||
|
||||
/// We store all interned things in the single QueryGroup.
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
use std::{fmt, any::Any};
|
||||
use std::{any::Any, fmt};
|
||||
|
||||
use ra_syntax::{SyntaxNodePtr, TreeArc, AstPtr, TextRange, ast, SyntaxNode};
|
||||
use ra_syntax::{ast, AstPtr, SyntaxNode, SyntaxNodePtr, TextRange, TreeArc};
|
||||
use relative_path::RelativePathBuf;
|
||||
|
||||
use crate::{HirFileId, HirDatabase, Name};
|
||||
use crate::{HirDatabase, HirFileId, Name};
|
||||
|
||||
/// Diagnostic defines hir API for errors and warnings.
|
||||
///
|
||||
|
|
|
@ -3,19 +3,25 @@ use std::sync::Arc;
|
|||
|
||||
use rustc_hash::FxHashMap;
|
||||
|
||||
use ra_arena::{Arena, RawId, impl_arena_id, map::ArenaMap};
|
||||
use ra_arena::{impl_arena_id, map::ArenaMap, Arena, RawId};
|
||||
use ra_syntax::{
|
||||
SyntaxNodePtr, AstPtr, AstNode,
|
||||
ast::{self, TryBlockBodyOwner, LoopBodyOwner, ArgListOwner, NameOwner, LiteralKind,ArrayExprKind, TypeAscriptionOwner},
|
||||
ast::{
|
||||
self, ArgListOwner, ArrayExprKind, LiteralKind, LoopBodyOwner, NameOwner,
|
||||
TryBlockBodyOwner, TypeAscriptionOwner,
|
||||
},
|
||||
AstNode, AstPtr, SyntaxNodePtr,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
Path, Name, HirDatabase, Resolver,DefWithBody, Either, HirFileId, MacroCallLoc, MacroFileKind,
|
||||
HasSource,
|
||||
name::AsName,
|
||||
type_ref::{Mutability, TypeRef},
|
||||
DefWithBody, Either, HasSource, HirDatabase, HirFileId, MacroCallLoc, MacroFileKind, Name,
|
||||
Path, Resolver,
|
||||
};
|
||||
use crate::{
|
||||
path::GenericArgs,
|
||||
ty::primitive::{FloatTy, IntTy, UncertainFloatTy, UncertainIntTy},
|
||||
};
|
||||
use crate::{path::GenericArgs, ty::primitive::{IntTy, UncertainIntTy, FloatTy, UncertainFloatTy}};
|
||||
|
||||
pub use self::scope::ExprScopes;
|
||||
|
||||
|
@ -249,8 +255,8 @@ pub enum Expr {
|
|||
Literal(Literal),
|
||||
}
|
||||
|
||||
pub use ra_syntax::ast::PrefixOp as UnaryOp;
|
||||
pub use ra_syntax::ast::BinOp as BinaryOp;
|
||||
pub use ra_syntax::ast::PrefixOp as UnaryOp;
|
||||
#[derive(Debug, Clone, Eq, PartialEq)]
|
||||
pub enum Array {
|
||||
ElementList(Vec<ExprId>),
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use ra_arena::{impl_arena_id, Arena, RawId};
|
||||
use rustc_hash::FxHashMap;
|
||||
use ra_arena::{Arena, RawId, impl_arena_id};
|
||||
|
||||
use crate::{
|
||||
Name, DefWithBody,
|
||||
expr::{PatId, ExprId, Pat, Expr, Body, Statement},
|
||||
HirDatabase,
|
||||
expr::{Body, Expr, ExprId, Pat, PatId, Statement},
|
||||
DefWithBody, HirDatabase, Name,
|
||||
};
|
||||
|
||||
#[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
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use ra_db::SourceDatabase;
|
||||
use ra_syntax::{algo::find_node_at_offset, AstNode, SyntaxNodePtr, ast};
|
||||
use test_utils::{extract_offset, assert_eq_text};
|
||||
use ra_syntax::{algo::find_node_at_offset, ast, AstNode, SyntaxNodePtr};
|
||||
use test_utils::{assert_eq_text, extract_offset};
|
||||
|
||||
use crate::{source_binder::SourceAnalyzer, mock::MockDatabase};
|
||||
use crate::{mock::MockDatabase, source_binder::SourceAnalyzer};
|
||||
|
||||
fn do_check(code: &str, expected: &[&str]) {
|
||||
let (off, code) = extract_offset(code);
|
||||
|
|
|
@ -1,17 +1,16 @@
|
|||
use std::sync::Arc;
|
||||
use rustc_hash::FxHashSet;
|
||||
use std::sync::Arc;
|
||||
|
||||
use ra_syntax::ast::{AstNode, StructLit};
|
||||
|
||||
use super::{Expr, ExprId, StructLitField};
|
||||
use crate::{
|
||||
expr::AstPtr,
|
||||
HirDatabase, Function, Name, HasSource,
|
||||
diagnostics::{DiagnosticSink, MissingFields},
|
||||
adt::AdtDef,
|
||||
Path,
|
||||
diagnostics::{DiagnosticSink, MissingFields},
|
||||
expr::AstPtr,
|
||||
ty::InferenceResult,
|
||||
Function, HasSource, HirDatabase, Name, Path,
|
||||
};
|
||||
use super::{Expr, StructLitField, ExprId};
|
||||
|
||||
pub(crate) struct ExprValidator<'a, 'b: 'a> {
|
||||
func: Function,
|
||||
|
|
|
@ -5,13 +5,14 @@
|
|||
|
||||
use std::sync::Arc;
|
||||
|
||||
use ra_syntax::ast::{self, NameOwner, TypeParamsOwner, TypeBoundsOwner, DefaultTypeParamOwner};
|
||||
use ra_syntax::ast::{self, DefaultTypeParamOwner, NameOwner, TypeBoundsOwner, TypeParamsOwner};
|
||||
|
||||
use crate::{
|
||||
HasSource,
|
||||
Name, AsName, Function, Struct, Union, Enum, Trait, TypeAlias, ImplBlock, Container, AdtDef,
|
||||
db::{HirDatabase, DefDatabase, AstDatabase},
|
||||
path::Path, type_ref::TypeRef,
|
||||
db::{AstDatabase, DefDatabase, HirDatabase},
|
||||
path::Path,
|
||||
type_ref::TypeRef,
|
||||
AdtDef, AsName, Container, Enum, Function, HasSource, ImplBlock, Name, Struct, Trait,
|
||||
TypeAlias, Union,
|
||||
};
|
||||
|
||||
/// Data about a generic parameter (to a function, struct, impl, ...).
|
||||
|
|
|
@ -3,14 +3,12 @@ use std::{
|
|||
sync::Arc,
|
||||
};
|
||||
|
||||
use ra_db::{FileId, salsa};
|
||||
use ra_syntax::{TreeArc, AstNode, ast, SyntaxNode};
|
||||
use ra_prof::profile;
|
||||
use mbe::MacroRules;
|
||||
use ra_db::{salsa, FileId};
|
||||
use ra_prof::profile;
|
||||
use ra_syntax::{ast, AstNode, SyntaxNode, TreeArc};
|
||||
|
||||
use crate::{
|
||||
Module, DefDatabase, AstId, FileAstId, AstDatabase, Source, InternDatabase,
|
||||
};
|
||||
use crate::{AstDatabase, AstId, DefDatabase, FileAstId, InternDatabase, 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
|
||||
|
|
|
@ -1,21 +1,21 @@
|
|||
use std::sync::Arc;
|
||||
use rustc_hash::FxHashMap;
|
||||
use std::sync::Arc;
|
||||
|
||||
use ra_arena::{Arena, RawId, impl_arena_id, map::ArenaMap};
|
||||
use ra_arena::{impl_arena_id, map::ArenaMap, Arena, RawId};
|
||||
use ra_syntax::{
|
||||
ast::{self, AstNode},
|
||||
AstPtr, SourceFile, TreeArc,
|
||||
ast::{self, AstNode}
|
||||
};
|
||||
|
||||
use crate::{
|
||||
Const, TypeAlias, Function, HirFileId, AstDatabase, HasSource, Source,
|
||||
HirDatabase, DefDatabase, TraitRef,
|
||||
type_ref::TypeRef,
|
||||
code_model::{Module, ModuleSource},
|
||||
generics::HasGenericParams,
|
||||
ids::LocationCtx,
|
||||
resolve::Resolver,
|
||||
ty::Ty,
|
||||
generics::HasGenericParams,
|
||||
code_model::{Module, ModuleSource}
|
||||
type_ref::TypeRef,
|
||||
AstDatabase, Const, DefDatabase, Function, HasSource, HirDatabase, HirFileId, Source, TraitRef,
|
||||
TypeAlias,
|
||||
};
|
||||
|
||||
#[derive(Debug, Default, PartialEq, Eq)]
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
use std::sync::Arc;
|
||||
use rustc_hash::FxHashMap;
|
||||
use std::sync::Arc;
|
||||
|
||||
use ra_syntax::{SmolStr, TreeArc, ast::AttrsOwner};
|
||||
use ra_syntax::{ast::AttrsOwner, SmolStr, TreeArc};
|
||||
|
||||
use crate::{
|
||||
Crate, DefDatabase, Enum, Function, HirDatabase, ImplBlock, Module,
|
||||
Static, Struct, Trait, ModuleDef, AstDatabase, HasSource
|
||||
AstDatabase, Crate, DefDatabase, Enum, Function, HasSource, HirDatabase, ImplBlock, Module,
|
||||
ModuleDef, Static, Struct, Trait,
|
||||
};
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
|
|
|
@ -47,39 +47,33 @@ mod code_model;
|
|||
mod marks;
|
||||
|
||||
use crate::{
|
||||
db::{InternDatabase, AstDatabase, DefDatabase, HirDatabase},
|
||||
name::{AsName, KnownName},
|
||||
source_id::{FileAstId, AstId},
|
||||
resolve::Resolver,
|
||||
db::{AstDatabase, DefDatabase, HirDatabase, InternDatabase},
|
||||
ids::MacroFileKind,
|
||||
name::{AsName, KnownName},
|
||||
resolve::Resolver,
|
||||
source_id::{AstId, FileAstId},
|
||||
};
|
||||
|
||||
pub use self::{
|
||||
either::Either,
|
||||
path::{Path, PathKind},
|
||||
name::Name,
|
||||
source_id::{AstIdMap, ErasedFileAstId},
|
||||
ids::{HirFileId, MacroDefId, MacroCallId, MacroCallLoc, MacroFile},
|
||||
nameres::{PerNs, Namespace, ImportId},
|
||||
ty::{Ty, ApplicationTy, TypeCtor, TraitRef, Substs, display::HirDisplay, CallableDef},
|
||||
impl_block::{ImplBlock, ImplItem},
|
||||
adt::AdtDef,
|
||||
either::Either,
|
||||
expr::ExprScopes,
|
||||
generics::{GenericParam, GenericParams, HasGenericParams},
|
||||
ids::{HirFileId, MacroCallId, MacroCallLoc, MacroDefId, MacroFile},
|
||||
impl_block::{ImplBlock, ImplItem},
|
||||
name::Name,
|
||||
nameres::{ImportId, Namespace, PerNs},
|
||||
path::{Path, PathKind},
|
||||
resolve::Resolution,
|
||||
generics::{GenericParams, GenericParam, HasGenericParams},
|
||||
source_binder::{SourceAnalyzer, PathResolution, ScopeEntryWithSyntax},
|
||||
source_binder::{PathResolution, ScopeEntryWithSyntax, SourceAnalyzer},
|
||||
source_id::{AstIdMap, ErasedFileAstId},
|
||||
ty::{display::HirDisplay, ApplicationTy, CallableDef, Substs, TraitRef, Ty, TypeCtor},
|
||||
};
|
||||
|
||||
pub use self::code_model::{
|
||||
Crate, CrateDependency,
|
||||
DefWithBody,
|
||||
Module, ModuleDef, ModuleSource,
|
||||
Struct, Union, Enum, EnumVariant,
|
||||
Function, FnData,
|
||||
StructField, FieldSource,
|
||||
Static, Const, ConstData,
|
||||
Trait, TypeAlias, MacroDef, Container,
|
||||
BuiltinType,
|
||||
src::{Source, HasSource},
|
||||
docs::{Docs, Documentation, DocDef},
|
||||
docs::{DocDef, Docs, Documentation},
|
||||
src::{HasSource, Source},
|
||||
BuiltinType, Const, ConstData, Container, Crate, CrateDependency, DefWithBody, Enum,
|
||||
EnumVariant, FieldSource, FnData, Function, MacroDef, Module, ModuleDef, ModuleSource, Static,
|
||||
Struct, StructField, Trait, TypeAlias, Union,
|
||||
};
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
use std::{sync::Arc, panic};
|
||||
use std::{panic, sync::Arc};
|
||||
|
||||
use parking_lot::Mutex;
|
||||
use ra_db::{
|
||||
FilePosition, FileId, CrateGraph, SourceRoot, SourceRootId, SourceDatabase, salsa,
|
||||
Edition,
|
||||
salsa, CrateGraph, Edition, FileId, FilePosition, SourceDatabase, SourceRoot, SourceRootId,
|
||||
};
|
||||
use relative_path::RelativePathBuf;
|
||||
use test_utils::{parse_fixture, CURSOR_MARKER, extract_offset};
|
||||
use rustc_hash::FxHashMap;
|
||||
use test_utils::{extract_offset, parse_fixture, CURSOR_MARKER};
|
||||
|
||||
use crate::{db, diagnostics::DiagnosticSink};
|
||||
|
||||
|
|
|
@ -55,28 +55,24 @@ mod tests;
|
|||
|
||||
use std::sync::Arc;
|
||||
|
||||
use rustc_hash::{FxHashMap, FxHashSet};
|
||||
use ra_arena::{Arena, RawId, impl_arena_id};
|
||||
use ra_db::{FileId, Edition};
|
||||
use test_utils::tested_by;
|
||||
use ra_syntax::ast;
|
||||
use ra_prof::profile;
|
||||
use once_cell::sync::Lazy;
|
||||
use ra_arena::{impl_arena_id, Arena, RawId};
|
||||
use ra_db::{Edition, FileId};
|
||||
use ra_prof::profile;
|
||||
use ra_syntax::ast;
|
||||
use rustc_hash::{FxHashMap, FxHashSet};
|
||||
use test_utils::tested_by;
|
||||
|
||||
use crate::{
|
||||
ModuleDef, Name, Crate, Module, MacroDef, AsName, BuiltinType, AstDatabase,
|
||||
DefDatabase, Path, PathKind, HirFileId, Trait,
|
||||
ids::MacroDefId,
|
||||
diagnostics::DiagnosticSink,
|
||||
nameres::diagnostics::DefDiagnostic,
|
||||
either::Either,
|
||||
AstId,
|
||||
diagnostics::DiagnosticSink, either::Either, ids::MacroDefId,
|
||||
nameres::diagnostics::DefDiagnostic, AsName, AstDatabase, AstId, BuiltinType, Crate,
|
||||
DefDatabase, HirFileId, MacroDef, Module, ModuleDef, Name, Path, PathKind, Trait,
|
||||
};
|
||||
|
||||
pub(crate) use self::raw::{RawItems, ImportSourceMap};
|
||||
pub(crate) use self::raw::{ImportSourceMap, RawItems};
|
||||
|
||||
pub use self::{
|
||||
per_ns::{PerNs, Namespace},
|
||||
per_ns::{Namespace, PerNs},
|
||||
raw::ImportId,
|
||||
};
|
||||
|
||||
|
@ -512,14 +508,14 @@ impl CrateDefMap {
|
|||
}
|
||||
|
||||
mod diagnostics {
|
||||
use ra_syntax::{ast, AstPtr};
|
||||
use relative_path::RelativePathBuf;
|
||||
use ra_syntax::{AstPtr, ast};
|
||||
|
||||
use crate::{
|
||||
AstId, DefDatabase, AstDatabase,
|
||||
diagnostics::{DiagnosticSink, UnresolvedModule},
|
||||
nameres::CrateModuleId,
|
||||
diagnostics::{DiagnosticSink, UnresolvedModule}
|
||||
};
|
||||
AstDatabase, AstId, DefDatabase,
|
||||
};
|
||||
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub(super) enum DefDiagnostic {
|
||||
|
|
|
@ -1,22 +1,19 @@
|
|||
use arrayvec::ArrayVec;
|
||||
use rustc_hash::FxHashMap;
|
||||
use relative_path::RelativePathBuf;
|
||||
use test_utils::tested_by;
|
||||
use ra_db::FileId;
|
||||
use ra_syntax::ast;
|
||||
use relative_path::RelativePathBuf;
|
||||
use rustc_hash::FxHashMap;
|
||||
use test_utils::tested_by;
|
||||
|
||||
use crate::{
|
||||
Function, Module, Struct, Union, Enum, Const, Static, Trait, TypeAlias, MacroDef,
|
||||
DefDatabase, HirFileId, Name, Path,
|
||||
KnownName, AstId,
|
||||
nameres::{
|
||||
Resolution, PerNs, ModuleDef, ReachedFixedPoint, ResolveMode,
|
||||
CrateDefMap, CrateModuleId, ModuleData, ItemOrMacro,
|
||||
diagnostics::DefDiagnostic,
|
||||
raw,
|
||||
},
|
||||
ids::{AstItemDef, LocationCtx, MacroCallLoc, MacroCallId, MacroDefId, MacroFileKind},
|
||||
either::Either,
|
||||
ids::{AstItemDef, LocationCtx, MacroCallId, MacroCallLoc, MacroDefId, MacroFileKind},
|
||||
nameres::{
|
||||
diagnostics::DefDiagnostic, raw, CrateDefMap, CrateModuleId, ItemOrMacro, ModuleData,
|
||||
ModuleDef, PerNs, ReachedFixedPoint, Resolution, ResolveMode,
|
||||
},
|
||||
AstId, Const, DefDatabase, Enum, Function, HirFileId, KnownName, MacroDef, Module, Name, Path,
|
||||
Static, Struct, Trait, TypeAlias, Union,
|
||||
};
|
||||
|
||||
pub(super) fn collect_defs(db: &impl DefDatabase, mut def_map: CrateDefMap) -> CrateDefMap {
|
||||
|
@ -666,9 +663,9 @@ fn resolve_submodule(
|
|||
mod tests {
|
||||
use ra_db::SourceDatabase;
|
||||
|
||||
use crate::{Crate, mock::MockDatabase, DefDatabase};
|
||||
use ra_arena::{Arena};
|
||||
use super::*;
|
||||
use crate::{mock::MockDatabase, Crate, DefDatabase};
|
||||
use ra_arena::Arena;
|
||||
use rustc_hash::FxHashSet;
|
||||
|
||||
fn do_collect_defs(
|
||||
|
|
|
@ -1,13 +1,16 @@
|
|||
use std::{sync::Arc, ops::Index};
|
||||
use std::{ops::Index, sync::Arc};
|
||||
|
||||
use test_utils::tested_by;
|
||||
use ra_arena::{Arena, impl_arena_id, RawId, map::ArenaMap};
|
||||
use ra_arena::{impl_arena_id, map::ArenaMap, Arena, RawId};
|
||||
use ra_syntax::{
|
||||
AstNode, SourceFile, AstPtr, TreeArc,
|
||||
ast::{self, NameOwner, AttrsOwner},
|
||||
ast::{self, AttrsOwner, NameOwner},
|
||||
AstNode, AstPtr, SourceFile, TreeArc,
|
||||
};
|
||||
use test_utils::tested_by;
|
||||
|
||||
use crate::{DefDatabase, Name, AsName, Path, HirFileId, ModuleSource, AstIdMap, FileAstId, Either, AstDatabase};
|
||||
use crate::{
|
||||
AsName, AstDatabase, AstIdMap, DefDatabase, Either, FileAstId, HirFileId, ModuleSource, Name,
|
||||
Path,
|
||||
};
|
||||
|
||||
/// `RawItems` is a set of top-level items in a file (except for impls).
|
||||
///
|
||||
|
|
|
@ -5,14 +5,14 @@ mod primitives;
|
|||
|
||||
use std::sync::Arc;
|
||||
|
||||
use insta::assert_snapshot_matches;
|
||||
use ra_db::SourceDatabase;
|
||||
use test_utils::covers;
|
||||
use insta::assert_snapshot_matches;
|
||||
|
||||
use crate::{
|
||||
Crate, Either,
|
||||
mock::{MockDatabase, CrateGraphFixture},
|
||||
mock::{CrateGraphFixture, MockDatabase},
|
||||
nameres::Resolution,
|
||||
Crate, Either,
|
||||
};
|
||||
|
||||
use super::*;
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use ra_syntax::{ast::{self, NameOwner}, AstNode};
|
||||
use ra_syntax::{
|
||||
ast::{self, NameOwner},
|
||||
AstNode,
|
||||
};
|
||||
|
||||
use crate::{Name, AsName, type_ref::TypeRef};
|
||||
use crate::{type_ref::TypeRef, AsName, Name};
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub struct Path {
|
||||
|
|
|
@ -4,16 +4,19 @@ use std::sync::Arc;
|
|||
use rustc_hash::{FxHashMap, FxHashSet};
|
||||
|
||||
use crate::{
|
||||
ModuleDef, Trait, MacroDef,
|
||||
code_model::Crate,
|
||||
db::HirDatabase,
|
||||
name::{Name, KnownName},
|
||||
nameres::{PerNs, CrateDefMap, CrateModuleId},
|
||||
generics::GenericParams,
|
||||
expr::{scope::{ExprScopes, ScopeId}, PatId},
|
||||
impl_block::ImplBlock,
|
||||
path::Path,
|
||||
either::Either,
|
||||
expr::{
|
||||
scope::{ExprScopes, ScopeId},
|
||||
PatId,
|
||||
},
|
||||
generics::GenericParams,
|
||||
impl_block::ImplBlock,
|
||||
name::{KnownName, Name},
|
||||
nameres::{CrateDefMap, CrateModuleId, PerNs},
|
||||
path::Path,
|
||||
MacroDef, ModuleDef, Trait,
|
||||
};
|
||||
|
||||
#[derive(Debug, Clone, Default)]
|
||||
|
|
|
@ -7,21 +7,25 @@
|
|||
/// purely for "IDE needs".
|
||||
use std::sync::Arc;
|
||||
|
||||
use rustc_hash::{FxHashSet, FxHashMap};
|
||||
use ra_db::{FileId, FilePosition};
|
||||
use ra_syntax::{
|
||||
SyntaxNode, AstPtr, TextUnit, SyntaxNodePtr, TextRange,
|
||||
ast::{self, AstNode, NameOwner},
|
||||
algo::find_node_at_offset,
|
||||
ast::{self, AstNode, NameOwner},
|
||||
AstPtr,
|
||||
SyntaxKind::*,
|
||||
SyntaxNode, SyntaxNodePtr, TextRange, TextUnit,
|
||||
};
|
||||
use rustc_hash::{FxHashMap, FxHashSet};
|
||||
|
||||
use crate::{
|
||||
HirDatabase, Function, Struct, Enum, Const, Static, Either, DefWithBody, PerNs, Name,
|
||||
AsName, Module, HirFileId, Crate, Trait, Resolver, Ty, Path, MacroDef,
|
||||
expr::{BodySourceMap, scope::{ScopeId, ExprScopes}},
|
||||
expr,
|
||||
expr::{
|
||||
scope::{ExprScopes, ScopeId},
|
||||
BodySourceMap,
|
||||
},
|
||||
ids::LocationCtx,
|
||||
expr, AstId,
|
||||
AsName, AstId, Const, Crate, DefWithBody, Either, Enum, Function, HirDatabase, HirFileId,
|
||||
MacroDef, Module, Name, Path, PerNs, Resolver, Static, Struct, Trait, Ty,
|
||||
};
|
||||
|
||||
/// Locates the module by `FileId`. Picks topmost module in the file.
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
use std::{marker::PhantomData, sync::Arc, hash::{Hash, Hasher}};
|
||||
use std::{
|
||||
hash::{Hash, Hasher},
|
||||
marker::PhantomData,
|
||||
sync::Arc,
|
||||
};
|
||||
|
||||
use ra_arena::{Arena, RawId, impl_arena_id};
|
||||
use ra_syntax::{SyntaxNodePtr, TreeArc, SyntaxNode, AstNode, ast};
|
||||
use ra_arena::{impl_arena_id, Arena, RawId};
|
||||
use ra_syntax::{ast, AstNode, SyntaxNode, SyntaxNodePtr, TreeArc};
|
||||
|
||||
use crate::{HirFileId, AstDatabase};
|
||||
use crate::{AstDatabase, HirFileId};
|
||||
|
||||
/// `AstId` points to an AST node in any file.
|
||||
///
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
//! HIR for trait definitions.
|
||||
|
||||
use std::sync::Arc;
|
||||
use rustc_hash::FxHashMap;
|
||||
use std::sync::Arc;
|
||||
|
||||
use ra_syntax::ast::{self, NameOwner};
|
||||
|
||||
use crate::{
|
||||
Function, Const, TypeAlias, Name, DefDatabase, Trait, AstDatabase, Module, HasSource,
|
||||
ids::LocationCtx, name::AsName,
|
||||
ids::LocationCtx, name::AsName, AstDatabase, Const, DefDatabase, Function, HasSource, Module,
|
||||
Name, Trait, TypeAlias,
|
||||
};
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
|
|
|
@ -12,17 +12,20 @@ mod lower;
|
|||
mod infer;
|
||||
pub(crate) mod display;
|
||||
|
||||
use std::sync::Arc;
|
||||
use std::ops::Deref;
|
||||
use std::sync::Arc;
|
||||
use std::{fmt, mem};
|
||||
|
||||
use crate::{Name, AdtDef, type_ref::Mutability, db::HirDatabase, Trait, GenericParams, TypeAlias};
|
||||
use crate::{db::HirDatabase, type_ref::Mutability, AdtDef, GenericParams, Name, Trait, TypeAlias};
|
||||
use display::{HirDisplay, HirFormatter};
|
||||
|
||||
pub(crate) use lower::{TypableDef, type_for_def, type_for_field, callable_item_sig, generic_predicates, generic_defaults};
|
||||
pub(crate) use infer::{infer_query, InferenceResult, InferTy};
|
||||
pub use lower::CallableDef;
|
||||
pub(crate) use autoderef::autoderef;
|
||||
pub(crate) use infer::{infer_query, InferTy, InferenceResult};
|
||||
pub use lower::CallableDef;
|
||||
pub(crate) use lower::{
|
||||
callable_item_sig, generic_defaults, generic_predicates, type_for_def, type_for_field,
|
||||
TypableDef,
|
||||
};
|
||||
pub(crate) use traits::ProjectionPredicate;
|
||||
|
||||
/// A type constructor or type name: this might be something like the primitive
|
||||
|
|
|
@ -7,8 +7,8 @@ use std::iter::successors;
|
|||
|
||||
use log::{info, warn};
|
||||
|
||||
use crate::{HirDatabase, Name, Resolver, HasGenericParams};
|
||||
use super::{traits::Solution, Ty, Canonical};
|
||||
use super::{traits::Solution, Canonical, Ty};
|
||||
use crate::{HasGenericParams, HirDatabase, Name, Resolver};
|
||||
|
||||
const AUTODEREF_RECURSION_LIMIT: usize = 10;
|
||||
|
||||
|
|
|
@ -15,38 +15,37 @@
|
|||
|
||||
use std::borrow::Cow;
|
||||
use std::iter::repeat;
|
||||
use std::mem;
|
||||
use std::ops::Index;
|
||||
use std::sync::Arc;
|
||||
use std::mem;
|
||||
|
||||
use ena::unify::{InPlaceUnificationTable, UnifyKey, UnifyValue, NoError};
|
||||
use ena::unify::{InPlaceUnificationTable, NoError, UnifyKey, UnifyValue};
|
||||
use rustc_hash::FxHashMap;
|
||||
|
||||
use ra_arena::map::ArenaMap;
|
||||
use ra_prof::profile;
|
||||
use test_utils::tested_by;
|
||||
|
||||
use super::{
|
||||
autoderef, method_resolution, op, primitive,
|
||||
traits::{Guidance, Obligation, Solution},
|
||||
ApplicationTy, CallableDef, Substs, TraitRef, Ty, TypableDef, TypeCtor,
|
||||
};
|
||||
use crate::{
|
||||
Function, StructField, Path, Name, FnData, AdtDef, ConstData, HirDatabase,
|
||||
DefWithBody, ImplItem,
|
||||
type_ref::{TypeRef, Mutability},
|
||||
adt::VariantDef,
|
||||
diagnostics::DiagnosticSink,
|
||||
expr::{
|
||||
Body, Expr, BindingAnnotation, Literal, ExprId, Pat, PatId, UnaryOp, BinaryOp, Statement,
|
||||
FieldPat, Array, self,
|
||||
self, Array, BinaryOp, BindingAnnotation, Body, Expr, ExprId, FieldPat, Literal, Pat,
|
||||
PatId, Statement, UnaryOp,
|
||||
},
|
||||
generics::{GenericParams, HasGenericParams},
|
||||
path::{GenericArgs, GenericArg},
|
||||
ModuleDef,
|
||||
adt::VariantDef,
|
||||
resolve::{Resolver, Resolution},
|
||||
nameres::Namespace,
|
||||
path::{GenericArg, GenericArgs},
|
||||
resolve::{Resolution, Resolver},
|
||||
ty::infer::diagnostics::InferenceDiagnostic,
|
||||
diagnostics::DiagnosticSink,
|
||||
};
|
||||
use super::{
|
||||
Ty, TypableDef, Substs, primitive, op, ApplicationTy, TypeCtor, CallableDef, TraitRef,
|
||||
traits::{Solution, Obligation, Guidance},
|
||||
method_resolution, autoderef,
|
||||
type_ref::{Mutability, TypeRef},
|
||||
AdtDef, ConstData, DefWithBody, FnData, Function, HirDatabase, ImplItem, ModuleDef, Name, Path,
|
||||
StructField,
|
||||
};
|
||||
|
||||
mod unify;
|
||||
|
@ -1415,10 +1414,10 @@ impl Expectation {
|
|||
|
||||
mod diagnostics {
|
||||
use crate::{
|
||||
expr::ExprId,
|
||||
diagnostics::{DiagnosticSink, NoSuchField},
|
||||
HirDatabase, Function, HasSource,
|
||||
};
|
||||
expr::ExprId,
|
||||
Function, HasSource, HirDatabase,
|
||||
};
|
||||
|
||||
#[derive(Debug, PartialEq, Eq, Clone)]
|
||||
pub(super) enum InferenceDiagnostic {
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
//! Unification and canonicalization logic.
|
||||
|
||||
use crate::db::HirDatabase;
|
||||
use crate::ty::{Ty, Canonical, TraitRef, InferTy};
|
||||
use super::InferenceContext;
|
||||
use crate::db::HirDatabase;
|
||||
use crate::ty::{Canonical, InferTy, TraitRef, Ty};
|
||||
|
||||
impl<'a, D: HirDatabase> InferenceContext<'a, D> {
|
||||
pub(super) fn canonicalizer<'b>(&'b mut self) -> Canonicalizer<'a, 'b, D>
|
||||
|
|
|
@ -5,23 +5,22 @@
|
|||
//! - Building the type for an item: This happens through the `type_for_def` query.
|
||||
//!
|
||||
//! This usually involves resolving names, collecting generic arguments etc.
|
||||
use std::sync::Arc;
|
||||
use std::iter;
|
||||
use std::sync::Arc;
|
||||
|
||||
use super::{FnSig, GenericPredicate, Substs, TraitRef, Ty, TypeCtor};
|
||||
use crate::{
|
||||
Function, Struct, Union, StructField, Enum, EnumVariant, Path, ModuleDef, TypeAlias, Const, Static,
|
||||
HirDatabase, BuiltinType,
|
||||
type_ref::TypeRef,
|
||||
nameres::Namespace,
|
||||
resolve::{Resolver, Resolution},
|
||||
path::{PathSegment, GenericArg},
|
||||
generics::{HasGenericParams},
|
||||
adt::VariantDef,
|
||||
Trait,
|
||||
generics::{WherePredicate, GenericDef},
|
||||
generics::HasGenericParams,
|
||||
generics::{GenericDef, WherePredicate},
|
||||
nameres::Namespace,
|
||||
path::{GenericArg, PathSegment},
|
||||
resolve::{Resolution, Resolver},
|
||||
ty::AdtDef,
|
||||
type_ref::TypeRef,
|
||||
BuiltinType, Const, Enum, EnumVariant, Function, HirDatabase, ModuleDef, Path, Static, Struct,
|
||||
StructField, Trait, TypeAlias, Union,
|
||||
};
|
||||
use super::{Ty, FnSig, Substs, TypeCtor, TraitRef, GenericPredicate};
|
||||
|
||||
impl Ty {
|
||||
pub(crate) fn from_hir(db: &impl HirDatabase, resolver: &Resolver, type_ref: &TypeRef) -> Self {
|
||||
|
|
|
@ -7,17 +7,17 @@ use std::sync::Arc;
|
|||
use arrayvec::ArrayVec;
|
||||
use rustc_hash::FxHashMap;
|
||||
|
||||
use super::{autoderef, Canonical, TraitRef};
|
||||
use crate::{
|
||||
HirDatabase, Module, Crate, Name, Function, Trait,
|
||||
impl_block::{ImplId, ImplBlock, ImplItem},
|
||||
ty::{Ty, TypeCtor},
|
||||
generics::HasGenericParams,
|
||||
impl_block::{ImplBlock, ImplId, ImplItem},
|
||||
nameres::CrateModuleId,
|
||||
resolve::Resolver,
|
||||
traits::TraitItem,
|
||||
generics::HasGenericParams,
|
||||
ty::primitive::{UncertainIntTy, UncertainFloatTy}
|
||||
ty::primitive::{UncertainFloatTy, UncertainIntTy},
|
||||
ty::{Ty, TypeCtor},
|
||||
Crate, Function, HirDatabase, Module, Name, Trait,
|
||||
};
|
||||
use super::{TraitRef, Canonical, autoderef};
|
||||
|
||||
/// This is used as a key for indexing impls.
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use crate::{ ty::ApplicationTy, expr::BinaryOp};
|
||||
use super::{Ty, TypeCtor, InferTy};
|
||||
use super::{InferTy, Ty, TypeCtor};
|
||||
use crate::{expr::BinaryOp, ty::ApplicationTy};
|
||||
|
||||
pub(super) fn binary_op_return_ty(op: BinaryOp, rhs_ty: Ty) -> Ty {
|
||||
match op {
|
||||
|
|
|
@ -1,17 +1,18 @@
|
|||
use std::sync::Arc;
|
||||
use std::fmt::Write;
|
||||
use std::sync::Arc;
|
||||
|
||||
use insta::assert_snapshot_matches;
|
||||
|
||||
use ra_db::{SourceDatabase, salsa::Database, FilePosition};
|
||||
use ra_syntax::{algo, ast::{self, AstNode}, SyntaxKind::*};
|
||||
use ra_db::{salsa::Database, FilePosition, SourceDatabase};
|
||||
use ra_syntax::{
|
||||
algo,
|
||||
ast::{self, AstNode},
|
||||
SyntaxKind::*,
|
||||
};
|
||||
use test_utils::covers;
|
||||
|
||||
use crate::{
|
||||
mock::MockDatabase,
|
||||
ty::display::HirDisplay,
|
||||
ty::InferenceResult,
|
||||
expr::BodySourceMap,
|
||||
expr::BodySourceMap, mock::MockDatabase, ty::display::HirDisplay, ty::InferenceResult,
|
||||
SourceAnalyzer,
|
||||
};
|
||||
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
//! Trait solving using Chalk.
|
||||
use std::sync::Arc;
|
||||
|
||||
use parking_lot::Mutex;
|
||||
use rustc_hash::FxHashSet;
|
||||
use log::debug;
|
||||
use chalk_ir::cast::Cast;
|
||||
use log::debug;
|
||||
use parking_lot::Mutex;
|
||||
use ra_prof::profile;
|
||||
use rustc_hash::FxHashSet;
|
||||
|
||||
use crate::{Crate, Trait, db::HirDatabase, ImplBlock};
|
||||
use super::{TraitRef, Ty, Canonical, ProjectionTy};
|
||||
use super::{Canonical, ProjectionTy, TraitRef, Ty};
|
||||
use crate::{db::HirDatabase, Crate, ImplBlock, Trait};
|
||||
|
||||
use self::chalk::{ToChalk, from_chalk};
|
||||
use self::chalk::{from_chalk, ToChalk};
|
||||
|
||||
pub(crate) mod chalk;
|
||||
|
||||
|
|
|
@ -3,20 +3,25 @@ use std::sync::Arc;
|
|||
|
||||
use log::debug;
|
||||
|
||||
use chalk_ir::{TypeId, ImplId, TypeKindId, Parameter, Identifier, cast::Cast, PlaceholderIndex, UniverseIndex, TypeName};
|
||||
use chalk_rust_ir::{AssociatedTyDatum, TraitDatum, StructDatum, ImplDatum};
|
||||
|
||||
use test_utils::tested_by;
|
||||
use ra_db::salsa::{InternId, InternKey};
|
||||
|
||||
use crate::{
|
||||
Trait, HasGenericParams, ImplBlock, Crate,
|
||||
db::HirDatabase,
|
||||
ty::{TraitRef, Ty, ApplicationTy, TypeCtor, Substs, GenericPredicate, CallableDef, ProjectionTy},
|
||||
ty::display::HirDisplay,
|
||||
generics::GenericDef, TypeAlias, ImplItem,
|
||||
use chalk_ir::{
|
||||
cast::Cast, Identifier, ImplId, Parameter, PlaceholderIndex, TypeId, TypeKindId, TypeName,
|
||||
UniverseIndex,
|
||||
};
|
||||
use chalk_rust_ir::{AssociatedTyDatum, ImplDatum, StructDatum, TraitDatum};
|
||||
|
||||
use ra_db::salsa::{InternId, InternKey};
|
||||
use test_utils::tested_by;
|
||||
|
||||
use super::ChalkContext;
|
||||
use crate::{
|
||||
db::HirDatabase,
|
||||
generics::GenericDef,
|
||||
ty::display::HirDisplay,
|
||||
ty::{
|
||||
ApplicationTy, CallableDef, GenericPredicate, ProjectionTy, Substs, TraitRef, Ty, TypeCtor,
|
||||
},
|
||||
Crate, HasGenericParams, ImplBlock, ImplItem, Trait, TypeAlias,
|
||||
};
|
||||
|
||||
/// This represents a trait whose name we could not resolve.
|
||||
const UNKNOWN_TRAIT: chalk_ir::TraitId =
|
||||
|
|
|
@ -4,7 +4,12 @@ use std::sync::Arc;
|
|||
|
||||
use ra_syntax::ast::NameOwner;
|
||||
|
||||
use crate::{TypeAlias, db::{DefDatabase, AstDatabase}, type_ref::TypeRef, name::{Name, AsName}, HasSource};
|
||||
use crate::{
|
||||
db::{AstDatabase, DefDatabase},
|
||||
name::{AsName, Name},
|
||||
type_ref::TypeRef,
|
||||
HasSource, TypeAlias,
|
||||
};
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct TypeAliasData {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue