Skip to content

Commit dded90a

Browse files
committed
Formatting
1 parent 6787f12 commit dded90a

File tree

12 files changed

+98
-53
lines changed

12 files changed

+98
-53
lines changed

crates/ra_hir/src/code_model.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,9 @@ use hir_def::{
1010
per_ns::PerNs,
1111
resolver::HasResolver,
1212
type_ref::{Mutability, TypeRef},
13-
AdtId, ConstId, DefWithBodyId, EnumId, FunctionId, HasModule, ImplId, LocalEnumVariantId,
14-
LocalModuleId, LocalStructFieldId, Lookup, ModuleId, StaticId, StructId, TraitId, TypeAliasId,
15-
TypeParamId, UnionId,
16-
GenericDefId
13+
AdtId, ConstId, DefWithBodyId, EnumId, FunctionId, GenericDefId, HasModule, ImplId,
14+
LocalEnumVariantId, LocalModuleId, LocalStructFieldId, Lookup, ModuleId, StaticId, StructId,
15+
TraitId, TypeAliasId, TypeParamId, UnionId,
1716
};
1817
use hir_expand::{
1918
diagnostics::DiagnosticSink,
@@ -22,8 +21,7 @@ use hir_expand::{
2221
};
2322
use hir_ty::{
2423
autoderef, display::HirFormatter, expr::ExprValidator, method_resolution, ApplicationTy,
25-
Canonical, InEnvironment, TraitEnvironment, Ty, TyDefId, TypeCtor,
26-
Substs
24+
Canonical, InEnvironment, Substs, TraitEnvironment, Ty, TyDefId, TypeCtor,
2725
};
2826
use ra_db::{CrateId, Edition, FileId};
2927
use ra_prof::profile;

crates/ra_hir_def/src/generics.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ pub struct WherePredicate {
6161
pub enum WherePredicateTarget {
6262
TypeRef(TypeRef),
6363
/// For desugared where predicates that can directly refer to a type param.
64-
TypeParam(LocalTypeParamId)
64+
TypeParam(LocalTypeParamId),
6565
}
6666

6767
type SourceMap = ArenaMap<LocalTypeParamId, Either<ast::TraitDef, ast::TypeParam>>;
@@ -197,7 +197,8 @@ impl GenericParams {
197197
return;
198198
}
199199
let bound = TypeBound::from_ast(bound);
200-
self.where_predicates.push(WherePredicate { target: WherePredicateTarget::TypeRef(type_ref), bound });
200+
self.where_predicates
201+
.push(WherePredicate { target: WherePredicateTarget::TypeRef(type_ref), bound });
201202
}
202203

203204
fn fill_implicit_impl_trait_args(&mut self, type_ref: &TypeRef) {
@@ -212,7 +213,7 @@ impl GenericParams {
212213
for bound in bounds {
213214
self.where_predicates.push(WherePredicate {
214215
target: WherePredicateTarget::TypeParam(param_id),
215-
bound: bound.clone()
216+
bound: bound.clone(),
216217
});
217218
}
218219
}
@@ -226,9 +227,13 @@ impl GenericParams {
226227
}
227228

228229
pub fn find_trait_self_param(&self) -> Option<LocalTypeParamId> {
229-
self.types
230-
.iter()
231-
.find_map(|(id, p)| if p.provenance == TypeParamProvenance::TraitSelf { Some(id) } else { None })
230+
self.types.iter().find_map(|(id, p)| {
231+
if p.provenance == TypeParamProvenance::TraitSelf {
232+
Some(id)
233+
} else {
234+
None
235+
}
236+
})
232237
}
233238
}
234239

crates/ra_hir_def/src/type_ref.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,7 @@ impl TypeRef {
131131
fn go(type_ref: &TypeRef, f: &mut impl FnMut(&TypeRef)) {
132132
f(type_ref);
133133
match type_ref {
134-
TypeRef::Fn(types) | TypeRef::Tuple(types) => {
135-
types.iter().for_each(|t| go(t, f))
136-
}
134+
TypeRef::Fn(types) | TypeRef::Tuple(types) => types.iter().for_each(|t| go(t, f)),
137135
TypeRef::RawPtr(type_ref, _)
138136
| TypeRef::Reference(type_ref, _)
139137
| TypeRef::Array(type_ref)

crates/ra_hir_ty/src/db.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
use std::sync::Arc;
44

55
use hir_def::{
6-
db::DefDatabase, DefWithBodyId, GenericDefId, ImplId, LocalStructFieldId, TraitId, VariantId, TypeParamId,
6+
db::DefDatabase, DefWithBodyId, GenericDefId, ImplId, LocalStructFieldId, TraitId, TypeParamId,
7+
VariantId,
78
};
89
use ra_arena::map::ArenaMap;
910
use ra_db::{impl_intern_key, salsa, CrateId};
@@ -12,8 +13,8 @@ use ra_prof::profile;
1213
use crate::{
1314
method_resolution::CrateImplBlocks,
1415
traits::{chalk, AssocTyValue, Impl},
15-
CallableDef, PolyFnSig, GenericPredicate, InferenceResult, Substs, TraitRef, Ty, TyDefId, TypeCtor,
16-
ValueTyDefId, Binders,
16+
Binders, CallableDef, GenericPredicate, InferenceResult, PolyFnSig, Substs, TraitRef, Ty,
17+
TyDefId, TypeCtor, ValueTyDefId,
1718
};
1819

1920
#[salsa::query_group(HirDatabaseStorage)]

crates/ra_hir_ty/src/infer.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,8 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
278278
impl_trait_mode: ImplTraitLoweringMode,
279279
) -> Ty {
280280
// FIXME use right resolver for block
281-
let ctx = crate::lower::TyLoweringContext::new(self.db, &self.resolver).with_impl_trait_mode(impl_trait_mode);
281+
let ctx = crate::lower::TyLoweringContext::new(self.db, &self.resolver)
282+
.with_impl_trait_mode(impl_trait_mode);
282283
let ty = Ty::from_hir(&ctx, type_ref);
283284
let ty = self.insert_type_vars(ty);
284285
self.normalize_associated_types_in(ty)
@@ -455,8 +456,10 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
455456

456457
fn collect_fn(&mut self, data: &FunctionData) {
457458
let body = Arc::clone(&self.body); // avoid borrow checker problem
458-
let ctx = crate::lower::TyLoweringContext::new(self.db, &self.resolver).with_impl_trait_mode(ImplTraitLoweringMode::Param);
459-
let param_tys = data.params.iter().map(|type_ref| Ty::from_hir(&ctx, type_ref)).collect::<Vec<_>>();
459+
let ctx = crate::lower::TyLoweringContext::new(self.db, &self.resolver)
460+
.with_impl_trait_mode(ImplTraitLoweringMode::Param);
461+
let param_tys =
462+
data.params.iter().map(|type_ref| Ty::from_hir(&ctx, type_ref)).collect::<Vec<_>>();
460463
for (ty, pat) in param_tys.into_iter().zip(body.params.iter()) {
461464
let ty = self.insert_type_vars(ty);
462465
let ty = self.normalize_associated_types_in(ty);

crates/ra_hir_ty/src/infer/coerce.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
6666
// This works for smart-pointer-like coercion, which covers all impls from std.
6767
st1.iter().zip(st2.iter()).enumerate().find_map(|(i, (ty1, ty2))| {
6868
match (ty1, ty2) {
69-
(Ty::Bound(idx1), Ty::Bound(idx2))
70-
if idx1 != idx2 =>
71-
{
69+
(Ty::Bound(idx1), Ty::Bound(idx2)) if idx1 != idx2 => {
7270
Some(((*ctor1, *ctor2), i))
7371
}
7472
_ => None,
@@ -277,9 +275,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
277275
let mut multiple_used = false;
278276
fields.for_each(|(field_id, _data)| {
279277
field_tys[field_id].value.walk(&mut |ty| match ty {
280-
&Ty::Bound(idx) if idx == unsize_generic_index => {
281-
multiple_used = true
282-
}
278+
&Ty::Bound(idx) if idx == unsize_generic_index => multiple_used = true,
283279
_ => {}
284280
})
285281
});

crates/ra_hir_ty/src/infer/expr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ use crate::{
1919
method_resolution, op,
2020
traits::InEnvironment,
2121
utils::{generics, variant_data, Generics},
22-
ApplicationTy, CallableDef, InferTy, IntTy, Mutability, Obligation, Substs, TraitRef, Ty,
23-
TypeCtor, Uncertain, Binders,
22+
ApplicationTy, Binders, CallableDef, InferTy, IntTy, Mutability, Obligation, Substs, TraitRef,
23+
Ty, TypeCtor, Uncertain,
2424
};
2525

2626
use super::{BindingMode, Expectation, InferenceContext, InferenceDiagnostic, TypeMismatch};

crates/ra_hir_ty/src/infer/path.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,7 @@ use hir_def::{
99
};
1010
use hir_expand::name::Name;
1111

12-
use crate::{
13-
db::HirDatabase, method_resolution, Substs, Ty,
14-
ValueTyDefId
15-
};
12+
use crate::{db::HirDatabase, method_resolution, Substs, Ty, ValueTyDefId};
1613

1714
use super::{ExprOrPatId, InferenceContext, TraitRef};
1815

crates/ra_hir_ty/src/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1033,7 +1033,10 @@ impl HirDisplay for Ty {
10331033
write!(f, "impl ")?;
10341034
let bounds = f.db.generic_predicates_for_param(*id);
10351035
let substs = Substs::type_params_for_generics(&generics);
1036-
write_bounds_like_dyn_trait(&bounds.iter().map(|b| b.clone().subst(&substs)).collect::<Vec<_>>(), f)?;
1036+
write_bounds_like_dyn_trait(
1037+
&bounds.iter().map(|b| b.clone().subst(&substs)).collect::<Vec<_>>(),
1038+
f,
1039+
)?;
10371040
}
10381041
}
10391042
}

crates/ra_hir_ty/src/lower.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,15 +276,19 @@ impl Ty {
276276
TypeNs::SelfType(impl_id) => {
277277
let generics = generics(ctx.db, impl_id.into());
278278
let substs = match ctx.type_param_mode {
279-
TypeParamLoweringMode::Placeholder => Substs::type_params_for_generics(&generics),
279+
TypeParamLoweringMode::Placeholder => {
280+
Substs::type_params_for_generics(&generics)
281+
}
280282
TypeParamLoweringMode::Variable => Substs::bound_vars(&generics),
281283
};
282284
ctx.db.impl_self_ty(impl_id).subst(&substs)
283285
}
284286
TypeNs::AdtSelfType(adt) => {
285287
let generics = generics(ctx.db, adt.into());
286288
let substs = match ctx.type_param_mode {
287-
TypeParamLoweringMode::Placeholder => Substs::type_params_for_generics(&generics),
289+
TypeParamLoweringMode::Placeholder => {
290+
Substs::type_params_for_generics(&generics)
291+
}
288292
TypeParamLoweringMode::Variable => Substs::bound_vars(&generics),
289293
};
290294
ctx.db.ty(adt.into()).subst(&substs)

0 commit comments

Comments
 (0)