Skip to content

Commit e41920a

Browse files
committed
rustfmt coherence::builtin
1 parent 243e45a commit e41920a

File tree

1 file changed

+26
-28
lines changed

1 file changed

+26
-28
lines changed

src/librustc_typeck/coherence/builtin.rs

+26-28
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,13 @@ use rustc::hir::{self, ItemImpl};
2828

2929
pub fn check<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
3030
if let Some(drop_trait) = tcx.lang_items.drop_trait() {
31-
tcx.lookup_trait_def(drop_trait).for_each_impl(tcx, |impl_did| {
32-
visit_implementation_of_drop(tcx, impl_did)
33-
});
31+
tcx.lookup_trait_def(drop_trait)
32+
.for_each_impl(tcx, |impl_did| visit_implementation_of_drop(tcx, impl_did));
3433
}
3534

3635
if let Some(copy_trait) = tcx.lang_items.copy_trait() {
37-
tcx.lookup_trait_def(copy_trait).for_each_impl(tcx, |impl_did| {
38-
visit_implementation_of_copy(tcx, impl_did)
39-
});
36+
tcx.lookup_trait_def(copy_trait)
37+
.for_each_impl(tcx, |impl_did| visit_implementation_of_copy(tcx, impl_did));
4038
}
4139

4240
if let Some(coerce_unsized_trait) = tcx.lang_items.coerce_unsized_trait() {
@@ -48,8 +46,10 @@ pub fn check<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
4846
};
4947

5048
tcx.lookup_trait_def(coerce_unsized_trait).for_each_impl(tcx, |impl_did| {
51-
visit_implementation_of_coerce_unsized(tcx, impl_did,
52-
unsize_trait, coerce_unsized_trait)
49+
visit_implementation_of_coerce_unsized(tcx,
50+
impl_did,
51+
unsize_trait,
52+
coerce_unsized_trait)
5353
});
5454
}
5555
}
@@ -81,8 +81,7 @@ fn visit_implementation_of_drop<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, impl_did:
8181
E0120,
8282
"the Drop trait may only be implemented on \
8383
structures")
84-
.span_label(span,
85-
&format!("implementing Drop requires a struct"))
84+
.span_label(span, &format!("implementing Drop requires a struct"))
8685
.emit();
8786
}
8887
_ => {
@@ -173,10 +172,10 @@ fn visit_implementation_of_copy<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, impl_did:
173172
}
174173
}
175174

176-
fn visit_implementation_of_coerce_unsized<'a, 'tcx>(
177-
tcx: TyCtxt<'a, 'tcx, 'tcx>, impl_did: DefId,
178-
unsize_trait: DefId, coerce_unsized_trait: DefId)
179-
{
175+
fn visit_implementation_of_coerce_unsized<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
176+
impl_did: DefId,
177+
unsize_trait: DefId,
178+
coerce_unsized_trait: DefId) {
180179
debug!("visit_implementation_of_coerce_unsized: impl_did={:?}",
181180
impl_did);
182181

@@ -212,10 +211,10 @@ fn visit_implementation_of_coerce_unsized<'a, 'tcx>(
212211
mk_ptr: &Fn(Ty<'tcx>) -> Ty<'tcx>| {
213212
if (mt_a.mutbl, mt_b.mutbl) == (hir::MutImmutable, hir::MutMutable) {
214213
infcx.report_mismatched_types(&cause,
215-
mk_ptr(mt_b.ty),
216-
target,
217-
ty::error::TypeError::Mutability)
218-
.emit();
214+
mk_ptr(mt_b.ty),
215+
target,
216+
ty::error::TypeError::Mutability)
217+
.emit();
219218
}
220219
(mt_a.ty, mt_b.ty, unsize_trait, None)
221220
};
@@ -232,8 +231,8 @@ fn visit_implementation_of_coerce_unsized<'a, 'tcx>(
232231
check_mutbl(mt_a, mt_b, &|ty| tcx.mk_imm_ptr(ty))
233232
}
234233

235-
(&ty::TyAdt(def_a, substs_a), &ty::TyAdt(def_b, substs_b))
236-
if def_a.is_struct() && def_b.is_struct() => {
234+
(&ty::TyAdt(def_a, substs_a), &ty::TyAdt(def_b, substs_b)) if def_a.is_struct() &&
235+
def_b.is_struct() => {
237236
if def_a != def_b {
238237
let source_path = tcx.item_path_str(def_a.did);
239238
let target_path = tcx.item_path_str(def_b.did);
@@ -299,11 +298,11 @@ fn visit_implementation_of_coerce_unsized<'a, 'tcx>(
299298
err.note(&format!("currently, {} fields need coercions: {}",
300299
diff_fields.len(),
301300
diff_fields.iter()
302-
.map(|&(i, a, b)| {
303-
format!("{} ({} to {})", fields[i].name, a, b)
304-
})
305-
.collect::<Vec<_>>()
306-
.join(", ")));
301+
.map(|&(i, a, b)| {
302+
format!("{} ({} to {})", fields[i].name, a, b)
303+
})
304+
.collect::<Vec<_>>()
305+
.join(", ")));
307306
err.span_label(span, &format!("requires multiple coercions"));
308307
err.emit();
309308
return;
@@ -328,8 +327,7 @@ fn visit_implementation_of_coerce_unsized<'a, 'tcx>(
328327

329328
// Register an obligation for `A: Trait<B>`.
330329
let cause = traits::ObligationCause::misc(span, impl_node_id);
331-
let predicate =
332-
tcx.predicate_for_trait_def(cause, trait_def_id, 0, source, &[target]);
330+
let predicate = tcx.predicate_for_trait_def(cause, trait_def_id, 0, source, &[target]);
333331
fulfill_cx.register_predicate_obligation(&infcx, predicate);
334332

335333
// Check that all transitive obligations are satisfied.
@@ -340,7 +338,7 @@ fn visit_implementation_of_coerce_unsized<'a, 'tcx>(
340338
// Finally, resolve all regions.
341339
let mut free_regions = FreeRegionMap::new();
342340
free_regions.relate_free_regions_from_predicates(&infcx.parameter_environment
343-
.caller_bounds);
341+
.caller_bounds);
344342
infcx.resolve_regions_and_report_errors(&free_regions, impl_node_id);
345343

346344
if let Some(kind) = kind {

0 commit comments

Comments
 (0)