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.
This commit is contained in:
parent
925ec0d3c7
commit
7024dc523a
80 changed files with 443 additions and 346 deletions
|
@ -141,7 +141,7 @@ impl<'tcx> TypeFolder<'tcx> for ReverseMapper<'tcx> {
|
|||
|
||||
#[instrument(skip(self), level = "debug")]
|
||||
fn fold_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> {
|
||||
match r {
|
||||
match *r {
|
||||
// Ignore bound regions and `'static` regions that appear in the
|
||||
// type, we only need to remap regions that reference lifetimes
|
||||
// from the function declaraion.
|
||||
|
|
|
@ -437,7 +437,7 @@ impl<'tcx> AutoTraitFinder<'tcx> {
|
|||
for (new_region, old_region) in
|
||||
iter::zip(new_substs.regions(), old_substs.regions())
|
||||
{
|
||||
match (new_region, old_region) {
|
||||
match (*new_region, *old_region) {
|
||||
// If both predicates have an `ReLateBound` (a HRTB) in the
|
||||
// same spot, we do nothing.
|
||||
(
|
||||
|
@ -880,8 +880,8 @@ impl<'a, 'tcx> TypeFolder<'tcx> for RegionReplacer<'a, 'tcx> {
|
|||
}
|
||||
|
||||
fn fold_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> {
|
||||
(match r {
|
||||
ty::ReVar(vid) => self.vid_to_region.get(vid).cloned(),
|
||||
(match *r {
|
||||
ty::ReVar(vid) => self.vid_to_region.get(&vid).cloned(),
|
||||
_ => None,
|
||||
})
|
||||
.unwrap_or_else(|| r.super_fold_with(self))
|
||||
|
|
|
@ -697,7 +697,7 @@ impl<'tcx> TypeFolder<'tcx> for PlaceholderReplacer<'_, 'tcx> {
|
|||
}
|
||||
|
||||
fn fold_region(&mut self, r0: ty::Region<'tcx>) -> ty::Region<'tcx> {
|
||||
let r1 = match r0 {
|
||||
let r1 = match *r0 {
|
||||
ty::ReVar(_) => self
|
||||
.infcx
|
||||
.inner
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue