Auto merge of #117908 - lcnr:region-kind-rename, r=BoxyUwU

finish `RegionKind` renaming

second step of https://github.com/rust-lang/types-team/issues/95

continues the work from #117876. While working on this and I encountered a bunch of further cleanup which I'll either open a tracking issue for or will do in a separate PR:
- rewrite the `RegionKind` docs, they still talk about `ReEmpty` and are generally out of date
- rename `DescriptionCtx` to `DescriptionCtxt`
- what is `CheckRegions::Bound`?
- `collect_late_bound_regions` et al
- `erase_late_bound_regions` -> `instantiate_bound_regions_with_erased`?
- `EraseEarlyRegions` visitor should be removed, feels duplicate

r? `@BoxyUwU`
This commit is contained in:
bors
2023-11-15 12:55:42 +00:00
61 changed files with 301 additions and 275 deletions
+2 -2
View File
@@ -723,7 +723,7 @@ fn is_fn_trait(&self, path: &Path) -> bool {
fn region_name(region: Region<'_>) -> Option<Symbol> {
match *region {
ty::ReEarlyBound(r) => Some(r.name),
ty::ReEarlyParam(r) => Some(r.name),
_ => None,
}
}
@@ -743,7 +743,7 @@ fn fold_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> {
match *r {
// These are the regions that can be seen in the AST.
ty::ReVar(vid) => self.vid_to_region.get(&vid).cloned().unwrap_or(r),
ty::ReEarlyBound(_) | ty::ReStatic | ty::ReBound(..) | ty::ReError(_) => r,
ty::ReEarlyParam(_) | ty::ReStatic | ty::ReBound(..) | ty::ReError(_) => r,
r => bug!("unexpected region: {r:?}"),
}
}
+5 -5
View File
@@ -287,9 +287,9 @@ pub(crate) fn clean_middle_region<'tcx>(region: ty::Region<'tcx>) -> Option<Life
ty::ReStatic => Some(Lifetime::statik()),
_ if !region.has_name() => None,
ty::ReBound(_, ty::BoundRegion { kind: ty::BrNamed(_, name), .. }) => Some(Lifetime(name)),
ty::ReEarlyBound(ref data) => Some(Lifetime(data.name)),
ty::ReEarlyParam(ref data) => Some(Lifetime(data.name)),
ty::ReBound(..)
| ty::ReFree(..)
| ty::ReLateParam(..)
| ty::ReVar(..)
| ty::ReError(_)
| ty::RePlaceholder(..)
@@ -1928,13 +1928,13 @@ fn clean_trait_object_lifetime_bound<'tcx>(
// latter contrary to `clean_middle_region`.
match *region {
ty::ReStatic => Some(Lifetime::statik()),
ty::ReEarlyBound(region) if region.name != kw::Empty => Some(Lifetime(region.name)),
ty::ReEarlyParam(region) if region.name != kw::Empty => Some(Lifetime(region.name)),
ty::ReBound(_, ty::BoundRegion { kind: ty::BrNamed(_, name), .. }) if name != kw::Empty => {
Some(Lifetime(name))
}
ty::ReEarlyBound(_)
ty::ReEarlyParam(_)
| ty::ReBound(..)
| ty::ReFree(_)
| ty::ReLateParam(_)
| ty::ReVar(_)
| ty::RePlaceholder(_)
| ty::ReErased
@@ -175,7 +175,7 @@ fn check_poly_fn(&mut self, cx: &LateContext<'tcx>, def_id: LocalDefId, decl: &F
},
// Early bound regions on functions are either from the containing item, are bounded by another
// lifetime, or are used as a bound for a type or lifetime.
RegionKind::ReEarlyBound(..) => continue,
RegionKind::ReEarlyParam(..) => continue,
_ => (),
}
+2 -2
View File
@@ -465,9 +465,9 @@ fn check_fn_args<'cx, 'tcx: 'cx>(
.walk()
.filter_map(|arg| {
arg.as_region().and_then(|lifetime| match lifetime.kind() {
ty::ReEarlyBound(r) => Some(r.def_id),
ty::ReEarlyParam(r) => Some(r.def_id),
ty::ReBound(_, r) => r.kind.get_id(),
ty::ReFree(r) => r.bound_region.get_id(),
ty::ReLateParam(r) => r.bound_region.get_id(),
ty::ReStatic
| ty::ReVar(_)
| ty::RePlaceholder(_)