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_ty_utils/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_ty_utils/src')
| -rw-r--r-- | compiler/rustc_ty_utils/src/instance.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_ty_utils/src/ty.rs | 2 |
2 files changed, 3 insertions, 3 deletions
diff --git a/compiler/rustc_ty_utils/src/instance.rs b/compiler/rustc_ty_utils/src/instance.rs index e7cc0f69e9f..91c4398c178 100644 --- a/compiler/rustc_ty_utils/src/instance.rs +++ b/compiler/rustc_ty_utils/src/instance.rs @@ -90,8 +90,8 @@ impl<'tcx> TypeVisitor<'tcx> for BoundVarsCollector<'tcx> { } fn visit_region(&mut self, r: ty::Region<'tcx>) -> ControlFlow<Self::BreakTy> { - match r { - ty::ReLateBound(index, br) if *index == self.binder_index => { + match *r { + ty::ReLateBound(index, br) if index == self.binder_index => { match self.vars.entry(br.var.as_u32()) { Entry::Vacant(entry) => { entry.insert(ty::BoundVariableKind::Region(br.kind)); diff --git a/compiler/rustc_ty_utils/src/ty.rs b/compiler/rustc_ty_utils/src/ty.rs index 04a62ed2e46..e44f80d5ac3 100644 --- a/compiler/rustc_ty_utils/src/ty.rs +++ b/compiler/rustc_ty_utils/src/ty.rs @@ -410,7 +410,7 @@ fn issue33140_self_ty(tcx: TyCtxt<'_>, def_id: DefId) -> Option<Ty<'_>> { let self_ty = trait_ref.self_ty(); let self_ty_matches = match self_ty.kind() { - ty::Dynamic(ref data, ty::ReStatic) => data.principal().is_none(), + ty::Dynamic(ref data, re) if re.is_static() => data.principal().is_none(), _ => false, }; |
