@@ -24,7 +24,6 @@ use rustc_traits::{type_op_ascribe_user_type_with_span, type_op_prove_predicate_
24
24
use tracing:: { debug, instrument} ;
25
25
26
26
use crate :: MirBorrowckCtxt ;
27
- use crate :: region_infer:: values:: RegionElement ;
28
27
use crate :: session_diagnostics:: {
29
28
HigherRankedErrorCause , HigherRankedLifetimeError , HigherRankedSubtypeError ,
30
29
} ;
@@ -54,26 +53,11 @@ impl<'tcx> UniverseInfo<'tcx> {
54
53
& self ,
55
54
mbcx : & mut MirBorrowckCtxt < ' _ , ' _ , ' tcx > ,
56
55
placeholder : ty:: PlaceholderRegion ,
57
- error_element : RegionElement ,
58
56
cause : ObligationCause < ' tcx > ,
57
+ error_element : Option < ty:: PlaceholderRegion > ,
59
58
) {
60
59
if let UniverseInfo :: TypeOp ( ref type_op_info) = * self {
61
- type_op_info. report_erroneous_element ( mbcx, placeholder, error_element, cause) ;
62
- } else {
63
- self . report_generic_error ( mbcx, cause) ;
64
- }
65
- }
66
-
67
- /// Report an error where a placeholder erroneously outlives another.
68
- pub ( crate ) fn report_placeholder_mismatch (
69
- & self ,
70
- mbcx : & mut MirBorrowckCtxt < ' _ , ' _ , ' tcx > ,
71
- placeholder_a : ty:: PlaceholderRegion ,
72
- cause : ObligationCause < ' tcx > ,
73
- placeholder_b : ty:: PlaceholderRegion ,
74
- ) {
75
- if let UniverseInfo :: TypeOp ( ref type_op_info) = * self {
76
- type_op_info. report_placeholder_mismatch ( mbcx, placeholder_a, cause, placeholder_b) ;
60
+ type_op_info. report_erroneous_element ( mbcx, placeholder, cause, error_element) ;
77
61
} else {
78
62
self . report_generic_error ( mbcx, cause) ;
79
63
}
@@ -173,28 +157,6 @@ pub(crate) trait TypeOpInfo<'tcx> {
173
157
error_region : Option < ty:: Region < ' tcx > > ,
174
158
) -> Option < Diag < ' infcx > > ;
175
159
176
- #[ instrument( level = "debug" , skip( self , mbcx) ) ]
177
- fn report_placeholder_mismatch (
178
- & self ,
179
- mbcx : & mut MirBorrowckCtxt < ' _ , ' _ , ' tcx > ,
180
- placeholder_a : ty:: PlaceholderRegion ,
181
- cause : ObligationCause < ' tcx > ,
182
- placeholder_b : ty:: PlaceholderRegion ,
183
- ) {
184
- let tcx = mbcx. infcx . tcx ;
185
-
186
- let placeholder_a = self . region_with_adjusted_universe ( placeholder_a, tcx) ;
187
- let placeholder_b = self . region_with_adjusted_universe ( placeholder_b, tcx) ;
188
-
189
- debug ! ( ?placeholder_a, ?placeholder_b) ;
190
-
191
- let span = cause. span ;
192
- // FIXME: see note in `report_erroneous_element()` below!
193
- let nice_error = self . nice_error ( mbcx, cause, placeholder_a, Some ( placeholder_b) ) ;
194
- debug ! ( ?nice_error) ;
195
- mbcx. buffer_error ( nice_error. unwrap_or_else ( || self . fallback_error ( tcx, span) ) ) ;
196
- }
197
-
198
160
/// Turn a placeholder region into a Region with its universe adjusted by
199
161
/// the base universe.
200
162
fn region_with_adjusted_universe (
@@ -217,13 +179,16 @@ pub(crate) trait TypeOpInfo<'tcx> {
217
179
)
218
180
}
219
181
182
+ /// Report an error where an erroneous element reaches `placeholder`.
183
+ /// The erroneous element is either another placeholder that we provide,
184
+ /// or we figure out what happened later.
220
185
#[ instrument( level = "debug" , skip( self , mbcx) ) ]
221
186
fn report_erroneous_element (
222
187
& self ,
223
188
mbcx : & mut MirBorrowckCtxt < ' _ , ' _ , ' tcx > ,
224
189
placeholder : ty:: PlaceholderRegion ,
225
- error_element : RegionElement ,
226
190
cause : ObligationCause < ' tcx > ,
191
+ error_element : Option < ty:: PlaceholderRegion > ,
227
192
) {
228
193
let tcx = mbcx. infcx . tcx ;
229
194
@@ -234,15 +199,12 @@ pub(crate) trait TypeOpInfo<'tcx> {
234
199
// In fact, this function throws away a lot of interesting information that would
235
200
// probably allow bypassing lots of logic downstream for a much simpler flow.
236
201
let placeholder_region = self . region_with_adjusted_universe ( placeholder, tcx) ;
202
+ let error_element = error_element. map ( |e| self . region_with_adjusted_universe ( e, tcx) ) ;
237
203
238
204
debug ! ( ?placeholder_region) ;
239
205
240
206
let span = cause. span ;
241
- // FIXME: it's not good that we have one variant that always sends None,
242
- // and one variant with always sends Some. We should break out these code
243
- // paths -- but the downstream code is complicated and that's not straight-
244
- // forward.
245
- let nice_error = self . nice_error ( mbcx, cause, placeholder_region, None ) ;
207
+ let nice_error = self . nice_error ( mbcx, cause, placeholder_region, error_element) ;
246
208
247
209
debug ! ( ?nice_error) ;
248
210
mbcx. buffer_error ( nice_error. unwrap_or_else ( || self . fallback_error ( tcx, span) ) ) ;
0 commit comments