@@ -339,10 +339,9 @@ pub(super) fn specialization_graph_provider<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx
339
339
for opt_overlap in opt_overlaps {
340
340
overlaps. push ( ( impl_def_id, opt_overlap) ) ;
341
341
}
342
- } ,
343
- _ => { } ,
342
+ }
343
+ _ => { }
344
344
} ;
345
-
346
345
} else {
347
346
let parent = tcx. impl_parent ( impl_def_id) . unwrap_or ( trait_id) ;
348
347
sg. record_impl_from_cstore ( tcx, parent, impl_def_id)
@@ -353,47 +352,55 @@ pub(super) fn specialization_graph_provider<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx
353
352
// Build the graph only if there is at least an overlap
354
353
let ( graph, nodes_idx) = sg. build_graph ( ) ;
355
354
for ( impl_def_id, overlap) in overlaps {
356
- if !sg. check_overlap ( & graph, & nodes_idx, impl_def_id, overlap. with_impl ) {
357
-
358
- let msg = format ! ( "conflicting implementations of trait `{}`{}:{}" ,
355
+ if !sg. check_overlap ( & graph, & nodes_idx, impl_def_id, overlap. with_impl , tcx ) {
356
+ let msg = format ! (
357
+ "conflicting implementations of trait `{}`{}:{}" ,
359
358
overlap. trait_desc,
360
- overlap. self_desc. clone( ) . map_or(
361
- String :: new( ) , |ty| {
362
- format!( " for type `{}`" , ty)
363
- } ) ,
364
- if overlap. used_to_be_allowed { " (E0119)" } else { "" }
365
- ) ;
366
- let impl_span = tcx. sess . codemap ( ) . def_span (
367
- tcx. span_of_impl ( impl_def_id) . unwrap ( )
359
+ overlap
360
+ . self_desc
361
+ . clone( )
362
+ . map_or( String :: new( ) , |ty| format!( " for type `{}`" , ty) ) ,
363
+ if overlap. used_to_be_allowed {
364
+ " (E0119)"
365
+ } else {
366
+ ""
367
+ }
368
368
) ;
369
+ let impl_span = tcx. sess
370
+ . codemap ( )
371
+ . def_span ( tcx. span_of_impl ( impl_def_id) . unwrap ( ) ) ;
369
372
let mut err = if overlap. used_to_be_allowed {
370
373
tcx. struct_span_lint_node (
371
374
lint:: builtin:: INCOHERENT_FUNDAMENTAL_IMPLS ,
372
375
tcx. hir . as_local_node_id ( impl_def_id) . unwrap ( ) ,
373
376
impl_span,
374
- & msg)
377
+ & msg,
378
+ )
375
379
} else {
376
- struct_span_err ! ( tcx. sess,
377
- impl_span,
378
- E0119 ,
379
- "{}" ,
380
- msg)
380
+ struct_span_err ! ( tcx. sess, impl_span, E0119 , "{}" , msg)
381
381
} ;
382
382
383
383
match tcx. span_of_impl ( overlap. with_impl ) {
384
384
Ok ( span) => {
385
- err. span_label ( tcx. sess . codemap ( ) . def_span ( span) ,
386
- format ! ( "first implementation here" ) ) ;
387
- err. span_label ( impl_span,
388
- format ! ( "conflicting implementation{}" ,
389
- overlap. self_desc
390
- . map_or( String :: new( ) ,
391
- |ty| format!( " for `{}`" , ty) ) ) ) ;
385
+ err. span_label (
386
+ tcx. sess . codemap ( ) . def_span ( span) ,
387
+ format ! ( "first implementation here" ) ,
388
+ ) ;
389
+ err. span_label (
390
+ impl_span,
391
+ format ! (
392
+ "conflicting implementation{}" ,
393
+ overlap
394
+ . self_desc
395
+ . map_or( String :: new( ) , |ty| format!( " for `{}`" , ty) )
396
+ ) ,
397
+ ) ;
392
398
}
393
399
Err ( cname) => {
394
400
let msg = match to_pretty_impl_header ( tcx, overlap. with_impl ) {
395
- Some ( s) => format ! (
396
- "conflicting implementation in crate `{}`:\n - {}" , cname, s) ,
401
+ Some ( s) => {
402
+ format ! ( "conflicting implementation in crate `{}`:\n - {}" , cname, s)
403
+ }
397
404
None => format ! ( "conflicting implementation in crate `{}`" , cname) ,
398
405
} ;
399
406
err. note ( & msg) ;
0 commit comments