File tree 2 files changed +19
-3
lines changed
compiler/rustc_borrowck/src
2 files changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ use rustc_middle::ty::Region;
22
22
use rustc_middle:: ty:: TypeVisitor ;
23
23
use rustc_middle:: ty:: { self , RegionVid , Ty } ;
24
24
use rustc_span:: symbol:: { kw, Ident } ;
25
- use rustc_span:: Span ;
25
+ use rustc_span:: { Span , DUMMY_SP } ;
26
26
27
27
use crate :: borrowck_errors;
28
28
use crate :: session_diagnostics:: {
@@ -70,7 +70,23 @@ impl<'tcx> ConstraintDescription for ConstraintCategory<'tcx> {
70
70
///
71
71
/// Usually we expect this to either be empty or contain a small number of items, so we can avoid
72
72
/// allocation most of the time.
73
- pub ( crate ) type RegionErrors < ' tcx > = Vec < RegionErrorKind < ' tcx > > ;
73
+ #[ derive( Default ) ]
74
+ pub ( crate ) struct RegionErrors < ' tcx > ( Vec < RegionErrorKind < ' tcx > > ) ;
75
+
76
+ impl < ' tcx > RegionErrors < ' tcx > {
77
+ #[ track_caller]
78
+ pub fn push ( & mut self , val : impl Into < RegionErrorKind < ' tcx > > ) {
79
+ let val = val. into ( ) ;
80
+ ty:: tls:: with ( |tcx| tcx. sess . delay_span_bug ( DUMMY_SP , "{val:?}" ) ) ;
81
+ self . 0 . push ( val) ;
82
+ }
83
+ pub fn is_empty ( & self ) -> bool {
84
+ self . 0 . is_empty ( )
85
+ }
86
+ pub fn into_iter ( self ) -> impl Iterator < Item = RegionErrorKind < ' tcx > > {
87
+ self . 0 . into_iter ( )
88
+ }
89
+ }
74
90
75
91
#[ derive( Clone , Debug ) ]
76
92
pub ( crate ) enum RegionErrorKind < ' tcx > {
Original file line number Diff line number Diff line change @@ -562,7 +562,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
562
562
let mir_def_id = body. source . def_id ( ) ;
563
563
self . propagate_constraints ( body) ;
564
564
565
- let mut errors_buffer = RegionErrors :: new ( ) ;
565
+ let mut errors_buffer = RegionErrors :: default ( ) ;
566
566
567
567
// If this is a closure, we can propagate unsatisfied
568
568
// `outlives_requirements` to our creator, so create a vector
You can’t perform that action at this time.
0 commit comments