1
1
//! Error reporting machinery for lifetime errors.
2
2
3
3
use rustc_data_structures:: fx:: FxIndexSet ;
4
- use rustc_errors:: { Applicability , DiagnosticBuilder , MultiSpan } ;
4
+ use rustc_errors:: { Applicability , DiagnosticBuilder , ErrorGuaranteed , MultiSpan } ;
5
5
use rustc_hir as hir;
6
6
use rustc_hir:: def:: Res :: Def ;
7
7
use rustc_hir:: def_id:: DefId ;
@@ -73,7 +73,7 @@ impl<'tcx> ConstraintDescription for ConstraintCategory<'tcx> {
73
73
///
74
74
/// Usually we expect this to either be empty or contain a small number of items, so we can avoid
75
75
/// 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 > ) ;
77
77
78
78
impl < ' tcx > RegionErrors < ' tcx > {
79
79
pub fn new ( tcx : TyCtxt < ' tcx > ) -> Self {
@@ -82,15 +82,18 @@ impl<'tcx> RegionErrors<'tcx> {
82
82
#[ track_caller]
83
83
pub fn push ( & mut self , val : impl Into < RegionErrorKind < ' tcx > > ) {
84
84
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 ) ) ;
87
87
}
88
88
pub fn is_empty ( & self ) -> bool {
89
89
self . 0 . is_empty ( )
90
90
}
91
- pub fn into_iter ( self ) -> impl Iterator < Item = RegionErrorKind < ' tcx > > {
91
+ pub fn into_iter ( self ) -> impl Iterator < Item = ( RegionErrorKind < ' tcx > , ErrorGuaranteed ) > {
92
92
self . 0 . into_iter ( )
93
93
}
94
+ pub fn has_errors ( & self ) -> Option < ErrorGuaranteed > {
95
+ self . 0 . get ( 0 ) . map ( |x| x. 1 )
96
+ }
94
97
}
95
98
96
99
impl std:: fmt:: Debug for RegionErrors < ' _ > {
@@ -304,10 +307,11 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
304
307
let mut last_unexpected_hidden_region: Option < ( Span , Ty < ' _ > , ty:: OpaqueTypeKey < ' tcx > ) > =
305
308
None ;
306
309
307
- for nll_error in nll_errors. into_iter ( ) {
310
+ for ( nll_error, _ ) in nll_errors. into_iter ( ) {
308
311
match nll_error {
309
312
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.
311
315
let lower_bound_region = self . to_error_region ( type_test. lower_bound ) ;
312
316
313
317
let type_test_span = type_test. span ;
0 commit comments