1
Fork 0

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:
Nicholas Nethercote 2022-01-28 11:25:15 +11:00
parent 925ec0d3c7
commit 7024dc523a
80 changed files with 443 additions and 346 deletions

View file

@ -194,7 +194,7 @@ macro_rules! make_mir_visitor {
}
fn visit_region(&mut self,
region: & $($mutability)? ty::Region<'tcx>,
region: $(& $mutability)? ty::Region<'tcx>,
_: Location) {
self.super_region(region);
}
@ -641,7 +641,7 @@ macro_rules! make_mir_visitor {
Rvalue::ThreadLocalRef(_) => {}
Rvalue::Ref(r, bk, path) => {
self.visit_region(r, location);
self.visit_region($(& $mutability)? *r, location);
let ctx = match bk {
BorrowKind::Shared => PlaceContext::NonMutatingUse(
NonMutatingUseContext::SharedBorrow
@ -900,7 +900,7 @@ macro_rules! make_mir_visitor {
fn super_ty(&mut self, _ty: $(& $mutability)? Ty<'tcx>) {
}
fn super_region(&mut self, _region: & $($mutability)? ty::Region<'tcx>) {
fn super_region(&mut self, _region: $(& $mutability)? ty::Region<'tcx>) {
}
fn super_const(&mut self, _const: & $($mutability)? &'tcx ty::Const<'tcx>) {