@@ -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} ;
@@ -49,11 +48,12 @@ impl<'tcx> UniverseInfo<'tcx> {
4948 UniverseInfo :: RelateTys { expected, found }
5049 }
5150
51+ /// Report an error where an element erroneously made its way into `placeholder`.
5252 pub ( crate ) fn report_erroneous_element (
5353 & self ,
5454 mbcx : & mut MirBorrowckCtxt < ' _ , ' _ , ' tcx > ,
5555 placeholder : ty:: PlaceholderRegion < ' tcx > ,
56- error_element : RegionElement < ' tcx > ,
56+ error_element : Option < ty :: PlaceholderRegion < ' tcx > > ,
5757 cause : ObligationCause < ' tcx > ,
5858 ) {
5959 match * self {
@@ -146,14 +146,14 @@ pub(crate) trait TypeOpInfo<'tcx> {
146146 ) -> Option < Diag < ' infcx > > ;
147147
148148 /// Constraints require that `error_element` appear in the
149- /// values of `placeholder`, but this cannot be proven to
149+ /// values of `placeholder`, but this cannot be proven to
150150 /// hold. Report an error.
151151 #[ instrument( level = "debug" , skip( self , mbcx) ) ]
152152 fn report_erroneous_element (
153153 & self ,
154154 mbcx : & mut MirBorrowckCtxt < ' _ , ' _ , ' tcx > ,
155155 placeholder : ty:: PlaceholderRegion < ' tcx > ,
156- error_element : RegionElement < ' tcx > ,
156+ error_element : Option < ty :: PlaceholderRegion < ' tcx > > ,
157157 cause : ObligationCause < ' tcx > ,
158158 ) {
159159 let tcx = mbcx. infcx . tcx ;
@@ -172,19 +172,17 @@ pub(crate) trait TypeOpInfo<'tcx> {
172172 ty:: PlaceholderRegion :: new ( adjusted_universe. into ( ) , placeholder. bound ) ,
173173 ) ;
174174
175- let error_region =
176- if let RegionElement :: PlaceholderRegion ( error_placeholder) = error_element {
177- let adjusted_universe =
178- error_placeholder. universe . as_u32 ( ) . checked_sub ( base_universe. as_u32 ( ) ) ;
179- adjusted_universe. map ( |adjusted| {
180- ty:: Region :: new_placeholder (
181- tcx,
182- ty:: PlaceholderRegion :: new ( adjusted. into ( ) , error_placeholder. bound ) ,
183- )
184- } )
185- } else {
186- None
187- } ;
175+ // FIXME: one day this should just be error_element,
176+ // and this method shouldn't do anything.
177+ let error_region = error_element. and_then ( |e| {
178+ let adjusted_universe = e. universe . as_u32 ( ) . checked_sub ( base_universe. as_u32 ( ) ) ;
179+ adjusted_universe. map ( |adjusted| {
180+ ty:: Region :: new_placeholder (
181+ tcx,
182+ ty:: PlaceholderRegion :: new ( adjusted. into ( ) , e. bound ) ,
183+ )
184+ } )
185+ } ) ;
188186
189187 debug ! ( ?placeholder_region) ;
190188
0 commit comments