@@ -167,6 +167,9 @@ struct UniversalRegionIndices<'tcx> {
167
167
/// contains an entry for `ReStatic` -- it might be nice to just
168
168
/// use a substs, and then handle `ReStatic` another way.
169
169
indices : FxHashMap < ty:: Region < ' tcx > , RegionVid > ,
170
+
171
+ /// The vid assigned to `'static`. Used only for diagnostics.
172
+ pub fr_static : RegionVid ,
170
173
}
171
174
172
175
#[ derive( Debug , PartialEq ) ]
@@ -609,7 +612,7 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
609
612
let subst_mapping =
610
613
iter:: zip ( identity_substs. regions ( ) , fr_substs. regions ( ) . map ( |r| r. to_region_vid ( ) ) ) ;
611
614
612
- UniversalRegionIndices { indices : global_mapping. chain ( subst_mapping) . collect ( ) }
615
+ UniversalRegionIndices { indices : global_mapping. chain ( subst_mapping) . collect ( ) , fr_static }
613
616
}
614
617
615
618
fn compute_inputs_and_output (
@@ -821,8 +824,11 @@ impl<'tcx> UniversalRegionIndices<'tcx> {
821
824
pub fn to_region_vid ( & self , r : ty:: Region < ' tcx > ) -> RegionVid {
822
825
if let ty:: ReVar ( ..) = * r {
823
826
r. to_region_vid ( )
824
- } else if let ty:: ReError ( _) = * r {
825
- RegionVid :: new ( 0 )
827
+ } else if r. is_error ( ) {
828
+ // We use the `'static` `RegionVid` because `ReError` doesn't actually exist in the
829
+ // `UniversalRegionIndices`. This is fine because 1) it is a fallback only used if
830
+ // errors are being emitted and 2) it leaves the happy path unaffected.
831
+ self . fr_static
826
832
} else {
827
833
* self
828
834
. indices
0 commit comments