diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2022-01-28 11:25:15 +1100 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2022-02-15 16:08:52 +1100 |
| commit | 7024dc523ac712249bb78833dab80c5087e1de36 (patch) | |
| tree | 298dd2afffe0308db1f69202ee272ae2daec9563 /compiler/rustc_mir_transform/src | |
| parent | 925ec0d3c77601ebfa32b148393a5192943c2ff1 (diff) | |
| download | rust-7024dc523ac712249bb78833dab80c5087e1de36.tar.gz rust-7024dc523ac712249bb78833dab80c5087e1de36.zip | |
Overhaul `RegionKind` and `Region`.
Specifically, change `Region` from this: ``` pub type Region<'tcx> = &'tcx RegionKind; ``` to this: ``` pub struct Region<'tcx>(&'tcx Interned<RegionKind>); ``` This now matches `Ty` and `Predicate` more closely. Things to note - Regions have always been interned, but we haven't been using pointer-based `Eq` and `Hash`. This is now happening. - I chose to impl `Deref` for `Region` because it makes pattern matching a lot nicer, and `Region` can be viewed as just a smart wrapper for `RegionKind`. - Various methods are moved from `RegionKind` to `Region`. - There is a lot of tedious sigil changes. - A couple of types like `HighlightBuilder`, `RegionHighlightMode` now have a `'tcx` lifetime because they hold a `Ty<'tcx>`, so they can call `mk_region`. - A couple of test outputs change slightly, I'm not sure why, but the new outputs are a little better.
Diffstat (limited to 'compiler/rustc_mir_transform/src')
| -rw-r--r-- | compiler/rustc_mir_transform/src/normalize_array_len.rs | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/compiler/rustc_mir_transform/src/normalize_array_len.rs b/compiler/rustc_mir_transform/src/normalize_array_len.rs index e4ac57ac925..0392c5a5468 100644 --- a/compiler/rustc_mir_transform/src/normalize_array_len.rs +++ b/compiler/rustc_mir_transform/src/normalize_array_len.rs @@ -3,10 +3,11 @@ use crate::MirPass; use rustc_data_structures::fx::FxIndexMap; +use rustc_data_structures::intern::Interned; use rustc_index::bit_set::BitSet; use rustc_index::vec::IndexVec; use rustc_middle::mir::*; -use rustc_middle::ty::{self, TyCtxt}; +use rustc_middle::ty::{self, ReErased, Region, TyCtxt}; const MAX_NUM_BLOCKS: usize = 800; const MAX_NUM_LOCALS: usize = 3000; @@ -231,11 +232,15 @@ fn normalize_array_len_call<'tcx>( // current way of patching doesn't allow to work with `mut` ( ty::Ref( - ty::RegionKind::ReErased, + Region(Interned(ReErased, _)), operand_ty, Mutability::Not, ), - ty::Ref(ty::RegionKind::ReErased, cast_ty, Mutability::Not), + ty::Ref( + Region(Interned(ReErased, _)), + cast_ty, + Mutability::Not, + ), ) => { match (operand_ty.kind(), cast_ty.kind()) { // current way of patching doesn't allow to work with `mut` |
