@@ -14,9 +14,16 @@ impl NiceRegionError<'me, 'gcx, 'tcx> {
1414 /// When given a `ConcreteFailure` for a function with arguments containing a named region and
1515 /// an anonymous region, emit an descriptive diagnostic error.
1616 pub ( super ) fn try_report_placeholder_conflict ( & self ) -> Option < ErrorReported > {
17- // Check for the first case: relating two trait-refs, and we
18- // find a conflict between two placeholders.
1917 match & self . error {
18+ ///////////////////////////////////////////////////////////////////////////
19+ // NB. The ordering of cases in this match is very
20+ // sensitive, because we are often matching against
21+ // specific cases and then using an `_` to match all
22+ // others.
23+
24+ ///////////////////////////////////////////////////////////////////////////
25+ // Check for errors from comparing trait failures -- first
26+ // with two placeholders, then with one.
2027 Some ( RegionResolutionError :: SubSupConflict (
2128 vid,
2229 _,
@@ -27,19 +34,19 @@ impl NiceRegionError<'me, 'gcx, 'tcx> {
2734 sub_placeholder @ ty:: RePlaceholder ( _) ,
2835 _,
2936 sup_placeholder @ ty:: RePlaceholder ( _) ,
30- ) ) => if expected. def_id == found. def_id {
31- return Some ( self . try_report_placeholders_trait (
37+ ) )
38+ if expected. def_id == found. def_id =>
39+ {
40+ Some ( self . try_report_placeholders_trait (
3241 Some ( self . tcx . mk_region ( ty:: ReVar ( * vid) ) ) ,
3342 cause,
3443 Some ( sub_placeholder) ,
3544 Some ( sup_placeholder) ,
3645 expected. def_id ,
3746 expected. substs ,
3847 found. substs ,
39- ) ) ;
40- } else {
41- // I actually can't see why this would be the case ever.
42- } ,
48+ ) )
49+ }
4350
4451 Some ( RegionResolutionError :: SubSupConflict (
4552 vid,
@@ -51,19 +58,19 @@ impl NiceRegionError<'me, 'gcx, 'tcx> {
5158 sub_placeholder @ ty:: RePlaceholder ( _) ,
5259 _,
5360 _,
54- ) ) => if expected. def_id == found. def_id {
55- return Some ( self . try_report_placeholders_trait (
61+ ) )
62+ if expected. def_id == found. def_id =>
63+ {
64+ Some ( self . try_report_placeholders_trait (
5665 Some ( self . tcx . mk_region ( ty:: ReVar ( * vid) ) ) ,
5766 cause,
5867 Some ( sub_placeholder) ,
5968 None ,
6069 expected. def_id ,
6170 expected. substs ,
6271 found. substs ,
63- ) ) ;
64- } else {
65- // I actually can't see why this would be the case ever.
66- } ,
72+ ) )
73+ }
6774
6875 Some ( RegionResolutionError :: SubSupConflict (
6976 vid,
@@ -75,48 +82,40 @@ impl NiceRegionError<'me, 'gcx, 'tcx> {
7582 _,
7683 _,
7784 sup_placeholder @ ty:: RePlaceholder ( _) ,
78- ) ) => if expected. def_id == found. def_id {
79- return Some ( self . try_report_placeholders_trait (
85+ ) )
86+ if expected. def_id == found. def_id =>
87+ {
88+ Some ( self . try_report_placeholders_trait (
8089 Some ( self . tcx . mk_region ( ty:: ReVar ( * vid) ) ) ,
8190 cause,
8291 None ,
8392 Some ( * sup_placeholder) ,
8493 expected. def_id ,
8594 expected. substs ,
8695 found. substs ,
87- ) ) ;
88- } else {
89- // I actually can't see why this would be the case ever.
90- } ,
91-
92- Some ( RegionResolutionError :: ConcreteFailure (
93- SubregionOrigin :: Subtype ( TypeTrace { .. } ) ,
94- ty:: RePlaceholder ( _) ,
95- ty:: RePlaceholder ( _) ,
96- ) ) => {
97- // I actually can't see why this would be the case ever.
96+ ) )
9897 }
9998
10099 Some ( RegionResolutionError :: ConcreteFailure (
101100 SubregionOrigin :: Subtype ( TypeTrace {
102101 cause,
103102 values : ValuePairs :: TraitRefs ( ExpectedFound { expected, found } ) ,
104103 } ) ,
105- sub_region,
104+ sub_region @ ty :: RePlaceholder ( _ ) ,
106105 sup_region @ ty:: RePlaceholder ( _) ,
107- ) ) => if expected . def_id == found . def_id {
108- return Some ( self . try_report_placeholders_trait (
109- Some ( sub_region ) ,
110- cause ,
106+ ) )
107+ if expected . def_id == found . def_id =>
108+ {
109+ Some ( self . try_report_placeholders_trait (
111110 None ,
111+ cause,
112+ Some ( * sub_region) ,
112113 Some ( * sup_region) ,
113114 expected. def_id ,
114115 expected. substs ,
115116 found. substs ,
116- ) ) ;
117- } else {
118- // I actually can't see why this would be the case ever.
119- } ,
117+ ) )
118+ }
120119
121120 Some ( RegionResolutionError :: ConcreteFailure (
122121 SubregionOrigin :: Subtype ( TypeTrace {
@@ -125,24 +124,43 @@ impl NiceRegionError<'me, 'gcx, 'tcx> {
125124 } ) ,
126125 sub_region @ ty:: RePlaceholder ( _) ,
127126 sup_region,
128- ) ) => if expected. def_id == found. def_id {
129- return Some ( self . try_report_placeholders_trait (
127+ ) )
128+ if expected. def_id == found. def_id =>
129+ {
130+ Some ( self . try_report_placeholders_trait (
130131 Some ( sup_region) ,
131132 cause,
132- None ,
133133 Some ( * sub_region) ,
134+ None ,
134135 expected. def_id ,
135136 expected. substs ,
136137 found. substs ,
137- ) ) ;
138- } else {
139- // I actually can't see why this would be the case ever.
140- } ,
138+ ) )
139+ }
141140
142- _ => { }
143- }
141+ Some ( RegionResolutionError :: ConcreteFailure (
142+ SubregionOrigin :: Subtype ( TypeTrace {
143+ cause,
144+ values : ValuePairs :: TraitRefs ( ExpectedFound { expected, found } ) ,
145+ } ) ,
146+ sub_region,
147+ sup_region @ ty:: RePlaceholder ( _) ,
148+ ) )
149+ if expected. def_id == found. def_id =>
150+ {
151+ Some ( self . try_report_placeholders_trait (
152+ Some ( sub_region) ,
153+ cause,
154+ None ,
155+ Some ( * sup_region) ,
156+ expected. def_id ,
157+ expected. substs ,
158+ found. substs ,
159+ ) )
160+ }
144161
145- None
162+ _ => None ,
163+ }
146164 }
147165
148166 // error[E0308]: implementation of `Foo` does not apply to enough lifetimes
0 commit comments