diff options
author | Aleksey Kladov <[email protected]> | 2019-07-04 21:05:17 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-07-04 21:09:09 +0100 |
commit | 1834bae5b86c54ed9dece26e82436919d59e6cb7 (patch) | |
tree | 92c8b984e874b67fa1831613464bbe356c1af3dd /crates/ra_hir/src/ty | |
parent | 2b2cd829b0f95aef338227deb05ec7503dae9b6c (diff) |
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
Diffstat (limited to 'crates/ra_hir/src/ty')
-rw-r--r-- | crates/ra_hir/src/ty/autoderef.rs | 4 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/infer.rs | 39 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/infer/unify.rs | 4 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/lower.rs | 21 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/method_resolution.rs | 12 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/op.rs | 4 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/tests.rs | 15 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/traits.rs | 12 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/traits/chalk.rs | 19 |
9 files changed, 67 insertions, 63 deletions
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 = |