File tree Expand file tree Collapse file tree 2 files changed +19
-3
lines changed
compiler/rustc_borrowck/src Expand file tree Collapse file tree 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;
2222use rustc_middle:: ty:: TypeVisitor ;
2323use rustc_middle:: ty:: { self , RegionVid , Ty } ;
2424use rustc_span:: symbol:: { kw, Ident } ;
25- use rustc_span:: Span ;
25+ use rustc_span:: { Span , DUMMY_SP } ;
2626
2727use crate :: borrowck_errors;
2828use crate :: session_diagnostics:: {
@@ -70,7 +70,23 @@ impl<'tcx> ConstraintDescription for ConstraintCategory<'tcx> {
7070///
7171/// Usually we expect this to either be empty or contain a small number of items, so we can avoid
7272/// 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+ }
7490
7591#[ derive( Clone , Debug ) ]
7692pub ( crate ) enum RegionErrorKind < ' tcx > {
Original file line number Diff line number Diff line change @@ -562,7 +562,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
562562 let mir_def_id = body. source . def_id ( ) ;
563563 self . propagate_constraints ( body) ;
564564
565- let mut errors_buffer = RegionErrors :: new ( ) ;
565+ let mut errors_buffer = RegionErrors :: default ( ) ;
566566
567567 // If this is a closure, we can propagate unsatisfied
568568 // `outlives_requirements` to our creator, so create a vector
You can’t perform that action at this time.
0 commit comments