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
|
@ -139,7 +139,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
|||
|
||||
/// Returns `true` if a closure is inferred to be an `FnMut` closure.
|
||||
fn is_closure_fn_mut(&self, fr: RegionVid) -> bool {
|
||||
if let Some(ty::ReFree(free_region)) = self.to_error_region(fr) {
|
||||
if let Some(ty::ReFree(free_region)) = self.to_error_region(fr).as_deref() {
|
||||
if let ty::BoundRegionKind::BrEnv = free_region.bound_region {
|
||||
if let DefiningTy::Closure(_, substs) =
|
||||
self.regioncx.universal_regions().defining_ty
|
||||
|
@ -628,8 +628,8 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
|||
fr_name: RegionName,
|
||||
outlived_fr: RegionVid,
|
||||
) {
|
||||
if let (Some(f), Some(ty::RegionKind::ReStatic)) =
|
||||
(self.to_error_region(fr), self.to_error_region(outlived_fr))
|
||||
if let (Some(f), Some(ty::ReStatic)) =
|
||||
(self.to_error_region(fr), self.to_error_region(outlived_fr).as_deref())
|
||||
{
|
||||
if let Some(&ty::Opaque(did, substs)) = self
|
||||
.infcx
|
||||
|
@ -652,7 +652,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
|||
bound.kind().skip_binder()
|
||||
{
|
||||
let r = r.subst(self.infcx.tcx, substs);
|
||||
if let ty::RegionKind::ReStatic = r {
|
||||
if r.is_static() {
|
||||
found = true;
|
||||
break;
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue