]> git.lizzy.rs Git - rust.git/commitdiff
Overhaul `RegionKind` and `Region`.
authorNicholas Nethercote <n.nethercote@gmail.com>
Fri, 28 Jan 2022 00:25:15 +0000 (11:25 +1100)
committerNicholas Nethercote <n.nethercote@gmail.com>
Tue, 15 Feb 2022 05:08:52 +0000 (16:08 +1100)
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.

src/abi/mod.rs

index 72ebc84c1a3443d56f5a8c0a5d27658ac2bc6411..a0550860fa54531be5476ad9298b7333f4edfa72 100644 (file)
@@ -544,7 +544,7 @@ pub(crate) fn codegen_drop<'tcx>(
                 let arg_value = drop_place.place_ref(
                     fx,
                     fx.layout_of(fx.tcx.mk_ref(
-                        &ty::RegionKind::ReErased,
+                        fx.tcx.lifetimes.re_erased,
                         TypeAndMut { ty, mutbl: crate::rustc_hir::Mutability::Mut },
                     )),
                 );