@@ -28,15 +28,13 @@ use rustc::hir::{self, ItemImpl};
28
28
29
29
pub fn check < ' a , ' tcx > ( tcx : TyCtxt < ' a , ' tcx , ' tcx > ) {
30
30
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) ) ;
34
33
}
35
34
36
35
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) ) ;
40
38
}
41
39
42
40
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>) {
48
46
} ;
49
47
50
48
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)
53
53
} ) ;
54
54
}
55
55
}
@@ -81,8 +81,7 @@ fn visit_implementation_of_drop<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, impl_did:
81
81
E0120 ,
82
82
"the Drop trait may only be implemented on \
83
83
structures")
84
- . span_label ( span,
85
- & format ! ( "implementing Drop requires a struct" ) )
84
+ . span_label ( span, & format ! ( "implementing Drop requires a struct" ) )
86
85
. emit ( ) ;
87
86
}
88
87
_ => {
@@ -173,10 +172,10 @@ fn visit_implementation_of_copy<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, impl_did:
173
172
}
174
173
}
175
174
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 ) {
180
179
debug ! ( "visit_implementation_of_coerce_unsized: impl_did={:?}" ,
181
180
impl_did) ;
182
181
@@ -212,10 +211,10 @@ fn visit_implementation_of_coerce_unsized<'a, 'tcx>(
212
211
mk_ptr : & Fn ( Ty < ' tcx > ) -> Ty < ' tcx > | {
213
212
if ( mt_a. mutbl , mt_b. mutbl ) == ( hir:: MutImmutable , hir:: MutMutable ) {
214
213
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 ( ) ;
219
218
}
220
219
( mt_a. ty , mt_b. ty , unsize_trait, None )
221
220
} ;
@@ -232,8 +231,8 @@ fn visit_implementation_of_coerce_unsized<'a, 'tcx>(
232
231
check_mutbl ( mt_a, mt_b, & |ty| tcx. mk_imm_ptr ( ty) )
233
232
}
234
233
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 ( ) => {
237
236
if def_a != def_b {
238
237
let source_path = tcx. item_path_str ( def_a. did ) ;
239
238
let target_path = tcx. item_path_str ( def_b. did ) ;
@@ -299,11 +298,11 @@ fn visit_implementation_of_coerce_unsized<'a, 'tcx>(
299
298
err. note ( & format ! ( "currently, {} fields need coercions: {}" ,
300
299
diff_fields. len( ) ,
301
300
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( ", " ) ) ) ;
307
306
err. span_label ( span, & format ! ( "requires multiple coercions" ) ) ;
308
307
err. emit ( ) ;
309
308
return ;
@@ -328,8 +327,7 @@ fn visit_implementation_of_coerce_unsized<'a, 'tcx>(
328
327
329
328
// Register an obligation for `A: Trait<B>`.
330
329
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] ) ;
333
331
fulfill_cx. register_predicate_obligation ( & infcx, predicate) ;
334
332
335
333
// Check that all transitive obligations are satisfied.
@@ -340,7 +338,7 @@ fn visit_implementation_of_coerce_unsized<'a, 'tcx>(
340
338
// Finally, resolve all regions.
341
339
let mut free_regions = FreeRegionMap :: new ( ) ;
342
340
free_regions. relate_free_regions_from_predicates ( & infcx. parameter_environment
343
- . caller_bounds ) ;
341
+ . caller_bounds ) ;
344
342
infcx. resolve_regions_and_report_errors ( & free_regions, impl_node_id) ;
345
343
346
344
if let Some ( kind) = kind {
0 commit comments