@@ -24,7 +24,6 @@ use rustc_traits::{type_op_ascribe_user_type_with_span, type_op_prove_predicate_
2424use tracing:: { debug, instrument} ;
2525
2626use crate :: MirBorrowckCtxt ;
27- use crate :: region_infer:: values:: RegionElement ;
2827use crate :: session_diagnostics:: {
2928 HigherRankedErrorCause , HigherRankedLifetimeError , HigherRankedSubtypeError ,
3029} ;
@@ -54,26 +53,11 @@ impl<'tcx> UniverseInfo<'tcx> {
5453 & self ,
5554 mbcx : & mut MirBorrowckCtxt < ' _ , ' _ , ' tcx > ,
5655 placeholder : ty:: PlaceholderRegion ,
57- error_element : RegionElement ,
5856 cause : ObligationCause < ' tcx > ,
57+ error_element : Option < ty:: PlaceholderRegion > ,
5958 ) {
6059 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) ;
7761 } else {
7862 self . report_generic_error ( mbcx, cause) ;
7963 }
@@ -173,28 +157,6 @@ pub(crate) trait TypeOpInfo<'tcx> {
173157 error_region : Option < ty:: Region < ' tcx > > ,
174158 ) -> Option < Diag < ' infcx > > ;
175159
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-
198160 /// Turn a placeholder region into a Region with its universe adjusted by
199161 /// the base universe.
200162 fn region_with_adjusted_universe (
@@ -217,13 +179,16 @@ pub(crate) trait TypeOpInfo<'tcx> {
217179 )
218180 }
219181
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.
220185 #[ instrument( level = "debug" , skip( self , mbcx) ) ]
221186 fn report_erroneous_element (
222187 & self ,
223188 mbcx : & mut MirBorrowckCtxt < ' _ , ' _ , ' tcx > ,
224189 placeholder : ty:: PlaceholderRegion ,
225- error_element : RegionElement ,
226190 cause : ObligationCause < ' tcx > ,
191+ error_element : Option < ty:: PlaceholderRegion > ,
227192 ) {
228193 let tcx = mbcx. infcx . tcx ;
229194
@@ -234,15 +199,12 @@ pub(crate) trait TypeOpInfo<'tcx> {
234199 // In fact, this function throws away a lot of interesting information that would
235200 // probably allow bypassing lots of logic downstream for a much simpler flow.
236201 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) ) ;
237203
238204 debug ! ( ?placeholder_region) ;
239205
240206 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) ;
246208
247209 debug ! ( ?nice_error) ;
248210 mbcx. buffer_error ( nice_error. unwrap_or_else ( || self . fallback_error ( tcx, span) ) ) ;
0 commit comments