@@ -146,8 +146,8 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
146
146
let graph = self . construct_graph ( ) ;
147
147
self . expand_givens ( & graph) ;
148
148
self . expansion ( & mut var_data) ;
149
- let captures = self . collect_errors ( & mut var_data, errors) ;
150
- self . collect_var_errors ( & var_data, & graph, errors, captures ) ;
149
+ self . collect_errors ( & mut var_data, errors) ;
150
+ self . collect_var_errors ( & var_data, & graph, errors) ;
151
151
var_data
152
152
}
153
153
@@ -445,16 +445,9 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
445
445
& self ,
446
446
var_data : & mut LexicalRegionResolutions < ' tcx > ,
447
447
errors : & mut Vec < RegionResolutionError < ' tcx > > ,
448
- ) -> Vec < Span > {
449
- let mut captures = vec ! [ ] ;
450
-
448
+ ) {
451
449
for ( constraint, origin) in & self . data . constraints {
452
450
debug ! ( ?constraint, ?origin) ;
453
- if let ( Constraint :: VarSubVar ( _, _) , SubregionOrigin :: DataBorrowed ( _, sp) ) =
454
- ( constraint, origin)
455
- {
456
- captures. push ( * sp) ;
457
- }
458
451
match * constraint {
459
452
Constraint :: RegSubVar ( ..) | Constraint :: VarSubVar ( ..) => {
460
453
// Expansion will ensure that these constraints hold. Ignore.
@@ -524,7 +517,6 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
524
517
sub,
525
518
) ) ;
526
519
}
527
- captures
528
520
}
529
521
530
522
/// Go over the variables that were declared to be error variables
@@ -534,7 +526,6 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
534
526
var_data : & LexicalRegionResolutions < ' tcx > ,
535
527
graph : & RegionGraph < ' tcx > ,
536
528
errors : & mut Vec < RegionResolutionError < ' tcx > > ,
537
- captures : Vec < Span > ,
538
529
) {
539
530
debug ! ( "collect_var_errors, var_data = {:#?}" , var_data. values) ;
540
531
@@ -578,12 +569,27 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
578
569
// if this rule starts to create problems we'll
579
570
// have to revisit this portion of the code and
580
571
// think hard about it. =) -- nikomatsakis
572
+
573
+ // Obtain the spans for all the capture points for
574
+ // richer diagnostics in `static_impl_trait`.
575
+ let captures: Vec < Span > = self
576
+ . data
577
+ . constraints
578
+ . iter ( )
579
+ . filter_map ( |( constraint, origin) | match ( constraint, origin) {
580
+ ( Constraint :: VarSubVar ( _, _) , SubregionOrigin :: DataBorrowed ( _, sp) ) => {
581
+ Some ( * sp)
582
+ }
583
+ _ => None ,
584
+ } )
585
+ . collect ( ) ;
586
+
581
587
self . collect_error_for_expanding_node (
582
588
graph,
583
589
& mut dup_vec,
584
590
node_vid,
585
591
errors,
586
- & captures,
592
+ captures,
587
593
) ;
588
594
}
589
595
}
@@ -638,7 +644,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
638
644
dup_vec : & mut IndexVec < RegionVid , Option < RegionVid > > ,
639
645
node_idx : RegionVid ,
640
646
errors : & mut Vec < RegionResolutionError < ' tcx > > ,
641
- captures : & [ Span ] ,
647
+ captures : Vec < Span > ,
642
648
) {
643
649
// Errors in expanding nodes result from a lower-bound that is
644
650
// not contained by an upper-bound.
@@ -686,18 +692,14 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
686
692
origin, node_idx, lower_bound. region, upper_bound. region
687
693
) ;
688
694
689
- let mut capture_spans: Vec < Span > = captures. iter ( ) . cloned ( ) . collect ( ) ;
690
- // Below, one span expects `&Span` and the other `&mut Span`, hence the dupes.
691
- capture_spans. sort_by_key ( |span| ( span. lo ( ) , span. hi ( ) ) ) ;
692
- capture_spans. dedup_by_key ( |span| ( span. lo ( ) , span. hi ( ) ) ) ;
693
695
errors. push ( RegionResolutionError :: SubSupConflict (
694
696
node_idx,
695
697
origin,
696
698
lower_bound. origin . clone ( ) ,
697
699
lower_bound. region ,
698
700
upper_bound. origin . clone ( ) ,
699
701
upper_bound. region ,
700
- capture_spans ,
702
+ captures ,
701
703
) ) ;
702
704
return ;
703
705
}
0 commit comments