@@ -167,6 +167,9 @@ struct UniversalRegionIndices<'tcx> {
167167 /// contains an entry for `ReStatic` -- it might be nice to just
168168 /// use a substs, and then handle `ReStatic` another way.
169169 indices : FxHashMap < ty:: Region < ' tcx > , RegionVid > ,
170+
171+ /// The vid assigned to `'static`. Used only for diagnostics.
172+ pub fr_static : RegionVid ,
170173}
171174
172175#[ derive( Debug , PartialEq ) ]
@@ -609,7 +612,7 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
609612 let subst_mapping =
610613 iter:: zip ( identity_substs. regions ( ) , fr_substs. regions ( ) . map ( |r| r. to_region_vid ( ) ) ) ;
611614
612- UniversalRegionIndices { indices : global_mapping. chain ( subst_mapping) . collect ( ) }
615+ UniversalRegionIndices { indices : global_mapping. chain ( subst_mapping) . collect ( ) , fr_static }
613616 }
614617
615618 fn compute_inputs_and_output (
@@ -821,8 +824,11 @@ impl<'tcx> UniversalRegionIndices<'tcx> {
821824 pub fn to_region_vid ( & self , r : ty:: Region < ' tcx > ) -> RegionVid {
822825 if let ty:: ReVar ( ..) = * r {
823826 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
826832 } else {
827833 * self
828834 . indices
0 commit comments