11//! Error reporting machinery for lifetime errors.
22
33use rustc_data_structures:: fx:: FxIndexSet ;
4- use rustc_errors:: { Applicability , DiagnosticBuilder , MultiSpan } ;
4+ use rustc_errors:: { Applicability , DiagnosticBuilder , ErrorGuaranteed , MultiSpan } ;
55use rustc_hir as hir;
66use rustc_hir:: def:: Res :: Def ;
77use rustc_hir:: def_id:: DefId ;
@@ -73,7 +73,7 @@ impl<'tcx> ConstraintDescription for ConstraintCategory<'tcx> {
7373///
7474/// Usually we expect this to either be empty or contain a small number of items, so we can avoid
7575/// allocation most of the time.
76- pub ( crate ) struct RegionErrors < ' tcx > ( Vec < RegionErrorKind < ' tcx > > , TyCtxt < ' tcx > ) ;
76+ pub ( crate ) struct RegionErrors < ' tcx > ( Vec < ( RegionErrorKind < ' tcx > , ErrorGuaranteed ) > , TyCtxt < ' tcx > ) ;
7777
7878impl < ' tcx > RegionErrors < ' tcx > {
7979 pub fn new ( tcx : TyCtxt < ' tcx > ) -> Self {
@@ -82,15 +82,18 @@ impl<'tcx> RegionErrors<'tcx> {
8282 #[ track_caller]
8383 pub fn push ( & mut self , val : impl Into < RegionErrorKind < ' tcx > > ) {
8484 let val = val. into ( ) ;
85- self . 1 . sess . dcx ( ) . delayed_bug ( format ! ( "{val:?}" ) ) ;
86- self . 0 . push ( val) ;
85+ let guar = self . 1 . sess . dcx ( ) . delayed_bug ( format ! ( "{val:?}" ) ) ;
86+ self . 0 . push ( ( val, guar ) ) ;
8787 }
8888 pub fn is_empty ( & self ) -> bool {
8989 self . 0 . is_empty ( )
9090 }
91- pub fn into_iter ( self ) -> impl Iterator < Item = RegionErrorKind < ' tcx > > {
91+ pub fn into_iter ( self ) -> impl Iterator < Item = ( RegionErrorKind < ' tcx > , ErrorGuaranteed ) > {
9292 self . 0 . into_iter ( )
9393 }
94+ pub fn has_errors ( & self ) -> Option < ErrorGuaranteed > {
95+ self . 0 . get ( 0 ) . map ( |x| x. 1 )
96+ }
9497}
9598
9699impl std:: fmt:: Debug for RegionErrors < ' _ > {
@@ -304,10 +307,11 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
304307 let mut last_unexpected_hidden_region: Option < ( Span , Ty < ' _ > , ty:: OpaqueTypeKey < ' tcx > ) > =
305308 None ;
306309
307- for nll_error in nll_errors. into_iter ( ) {
310+ for ( nll_error, _ ) in nll_errors. into_iter ( ) {
308311 match nll_error {
309312 RegionErrorKind :: TypeTestError { type_test } => {
310- // Try to convert the lower-bound region into something named we can print for the user.
313+ // Try to convert the lower-bound region into something named we can print for
314+ // the user.
311315 let lower_bound_region = self . to_error_region ( type_test. lower_bound ) ;
312316
313317 let type_test_span = type_test. span ;
0 commit comments