From 1834bae5b86c54ed9dece26e82436919d59e6cb7 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 4 Jul 2019 23:05:17 +0300 Subject: 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 --- crates/ra_hir/src/ty/autoderef.rs | 4 ++-- crates/ra_hir/src/ty/infer.rs | 39 +++++++++++++++---------------- crates/ra_hir/src/ty/infer/unify.rs | 4 ++-- crates/ra_hir/src/ty/lower.rs | 21 ++++++++--------- crates/ra_hir/src/ty/method_resolution.rs | 12 +++++----- crates/ra_hir/src/ty/op.rs | 4 ++-- crates/ra_hir/src/ty/tests.rs | 15 ++++++------ crates/ra_hir/src/ty/traits.rs | 12 +++++----- crates/ra_hir/src/ty/traits/chalk.rs | 19 +++++++++------ 9 files changed, 67 insertions(+), 63 deletions(-) (limited to 'crates/ra_hir/src/ty') 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; 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; 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 @@ 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 { 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 @@ //! 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> 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 @@ //! - 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 { 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; 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)] 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 @@ -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 { 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 @@ -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, }; 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 @@ //! 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; 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; 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 chalk_ir::{ + cast::Cast, Identifier, ImplId, Parameter, PlaceholderIndex, TypeId, TypeKindId, TypeName, + UniverseIndex, +}; +use chalk_rust_ir::{AssociatedTyDatum, ImplDatum, StructDatum, TraitDatum}; -use test_utils::tested_by; use ra_db::salsa::{InternId, InternKey}; +use test_utils::tested_by; +use super::ChalkContext; use crate::{ - Trait, HasGenericParams, ImplBlock, Crate, db::HirDatabase, - ty::{TraitRef, Ty, ApplicationTy, TypeCtor, Substs, GenericPredicate, CallableDef, ProjectionTy}, + generics::GenericDef, ty::display::HirDisplay, - generics::GenericDef, TypeAlias, ImplItem, + ty::{ + ApplicationTy, CallableDef, GenericPredicate, ProjectionTy, Substs, TraitRef, Ty, TypeCtor, + }, + Crate, HasGenericParams, ImplBlock, ImplItem, Trait, TypeAlias, }; -use super::ChalkContext; /// This represents a trait whose name we could not resolve. const UNKNOWN_TRAIT: chalk_ir::TraitId = -- cgit v1.2.3