diff options
| author | Esteban Küber <esteban@kuber.com.ar> | 2023-02-07 15:11:04 +0000 |
|---|---|---|
| committer | Esteban Küber <esteban@kuber.com.ar> | 2023-02-09 10:26:50 +0000 |
| commit | ed8651c7b8f9a179b584124cde3994bb93433bb0 (patch) | |
| tree | e2fbcb1a40a1691cd43dfce37872f9ae94884db6 | |
| parent | 861f4512353e83dbc67de34992058f44fc1b4648 (diff) | |
| download | rust-ed8651c7b8f9a179b584124cde3994bb93433bb0.tar.gz rust-ed8651c7b8f9a179b584124cde3994bb93433bb0.zip | |
Use 'static RegionVid for ReError
| -rw-r--r-- | compiler/rustc_borrowck/src/universal_regions.rs | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/compiler/rustc_borrowck/src/universal_regions.rs b/compiler/rustc_borrowck/src/universal_regions.rs index e813ff837ff..56930c89b2c 100644 --- a/compiler/rustc_borrowck/src/universal_regions.rs +++ b/compiler/rustc_borrowck/src/universal_regions.rs @@ -167,6 +167,9 @@ struct UniversalRegionIndices<'tcx> { /// contains an entry for `ReStatic` -- it might be nice to just /// use a substs, and then handle `ReStatic` another way. indices: FxHashMap<ty::Region<'tcx>, RegionVid>, + + /// The vid assigned to `'static`. Used only for diagnostics. + pub fr_static: RegionVid, } #[derive(Debug, PartialEq)] @@ -609,7 +612,7 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> { let subst_mapping = iter::zip(identity_substs.regions(), fr_substs.regions().map(|r| r.to_region_vid())); - UniversalRegionIndices { indices: global_mapping.chain(subst_mapping).collect() } + UniversalRegionIndices { indices: global_mapping.chain(subst_mapping).collect(), fr_static } } fn compute_inputs_and_output( @@ -821,8 +824,11 @@ impl<'tcx> UniversalRegionIndices<'tcx> { pub fn to_region_vid(&self, r: ty::Region<'tcx>) -> RegionVid { if let ty::ReVar(..) = *r { r.to_region_vid() - } else if let ty::ReError(_) = *r { - RegionVid::new(0) + } else if r.is_error() { + // We use the `'static` `RegionVid` because `ReError` doesn't actually exist in the + // `UniversalRegionIndices`. This is fine because 1) it is a fallback only used if + // errors are being emitted and 2) it leaves the happy path unaffected. + self.fr_static } else { *self .indices |
