rename ReLateBound to ReBound

other changes:
- `Region::new_late_bound` -> `Region::new_bound`
- `Region::is_late_bound` -> `Region::is_bound`
This commit is contained in:
lcnr 2023-11-13 14:00:05 +00:00
parent 28328c8389
commit 86fa1317a3
80 changed files with 192 additions and 195 deletions

View file

@ -462,7 +462,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
// lifetimes without names with the value `'0`. // lifetimes without names with the value `'0`.
if let ty::Ref(region, ..) = ty.kind() { if let ty::Ref(region, ..) = ty.kind() {
match **region { match **region {
ty::ReLateBound(_, ty::BoundRegion { kind: br, .. }) ty::ReBound(_, ty::BoundRegion { kind: br, .. })
| ty::RePlaceholder(ty::PlaceholderRegion { | ty::RePlaceholder(ty::PlaceholderRegion {
bound: ty::BoundRegion { kind: br, .. }, bound: ty::BoundRegion { kind: br, .. },
.. ..
@ -482,7 +482,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
let region = if let ty::Ref(region, ..) = ty.kind() { let region = if let ty::Ref(region, ..) = ty.kind() {
match **region { match **region {
ty::ReLateBound(_, ty::BoundRegion { kind: br, .. }) ty::ReBound(_, ty::BoundRegion { kind: br, .. })
| ty::RePlaceholder(ty::PlaceholderRegion { | ty::RePlaceholder(ty::PlaceholderRegion {
bound: ty::BoundRegion { kind: br, .. }, bound: ty::BoundRegion { kind: br, .. },
.. ..

View file

@ -357,7 +357,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
ty::BoundRegionKind::BrAnon => None, ty::BoundRegionKind::BrAnon => None,
}, },
ty::ReLateBound(..) ty::ReBound(..)
| ty::ReVar(..) | ty::ReVar(..)
| ty::RePlaceholder(..) | ty::RePlaceholder(..)
| ty::ReErased | ty::ReErased

View file

@ -665,7 +665,7 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
var: ty::BoundVar::from_usize(bound_vars.len() - 1), var: ty::BoundVar::from_usize(bound_vars.len() - 1),
kind: ty::BrEnv, kind: ty::BrEnv,
}; };
let env_region = ty::Region::new_late_bound(tcx, ty::INNERMOST, br); let env_region = ty::Region::new_bound(tcx, ty::INNERMOST, br);
let closure_ty = tcx.closure_env_ty(def_id, args, env_region).unwrap(); let closure_ty = tcx.closure_env_ty(def_id, args, env_region).unwrap();
// The "inputs" of the closure in the // The "inputs" of the closure in the

View file

@ -350,7 +350,7 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
let args = let args =
candidate.skip_binder().args.extend_to(tcx, assoc_item.def_id, |param, _| { candidate.skip_binder().args.extend_to(tcx, assoc_item.def_id, |param, _| {
let subst = match param.kind { let subst = match param.kind {
ty::GenericParamDefKind::Lifetime => ty::Region::new_late_bound( ty::GenericParamDefKind::Lifetime => ty::Region::new_bound(
tcx, tcx,
ty::INNERMOST, ty::INNERMOST,
ty::BoundRegion { ty::BoundRegion {

View file

@ -250,7 +250,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
var: ty::BoundVar::from_u32(index), var: ty::BoundVar::from_u32(index),
kind: ty::BrNamed(def_id, name), kind: ty::BrNamed(def_id, name),
}; };
ty::Region::new_late_bound(tcx, debruijn, br) ty::Region::new_bound(tcx, debruijn, br)
} }
Some(rbv::ResolvedArg::EarlyBound(def_id)) => { Some(rbv::ResolvedArg::EarlyBound(def_id)) => {
@ -1622,7 +1622,9 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
} }
fn fold_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> { fn fold_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> {
if r.is_late_bound() { self.tcx.lifetimes.re_erased } else { r } // FIXME(@lcnr): This is broken, erasing bound regions
// impacts selection as it results in different types.
if r.is_bound() { self.tcx.lifetimes.re_erased } else { r }
} }
fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> { fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {

View file

@ -2345,7 +2345,7 @@ fn param_env_with_gat_bounds<'tcx>(
let kind = ty::BoundRegionKind::BrNamed(param.def_id, param.name); let kind = ty::BoundRegionKind::BrNamed(param.def_id, param.name);
let bound_var = ty::BoundVariableKind::Region(kind); let bound_var = ty::BoundVariableKind::Region(kind);
bound_vars.push(bound_var); bound_vars.push(bound_var);
ty::Region::new_late_bound( ty::Region::new_bound(
tcx, tcx,
ty::INNERMOST, ty::INNERMOST,
ty::BoundRegion { ty::BoundRegion {

View file

@ -143,12 +143,12 @@ pub fn check_intrinsic_type(tcx: TyCtxt<'_>, it: &hir::ForeignItem<'_>) {
]); ]);
let mk_va_list_ty = |mutbl| { let mk_va_list_ty = |mutbl| {
tcx.lang_items().va_list().map(|did| { tcx.lang_items().va_list().map(|did| {
let region = ty::Region::new_late_bound( let region = ty::Region::new_bound(
tcx, tcx,
ty::INNERMOST, ty::INNERMOST,
ty::BoundRegion { var: ty::BoundVar::from_u32(0), kind: ty::BrAnon }, ty::BoundRegion { var: ty::BoundVar::from_u32(0), kind: ty::BrAnon },
); );
let env_region = ty::Region::new_late_bound( let env_region = ty::Region::new_bound(
tcx, tcx,
ty::INNERMOST, ty::INNERMOST,
ty::BoundRegion { var: ty::BoundVar::from_u32(1), kind: ty::BrEnv }, ty::BoundRegion { var: ty::BoundVar::from_u32(1), kind: ty::BrEnv },
@ -411,7 +411,7 @@ pub fn check_intrinsic_type(tcx: TyCtxt<'_>, it: &hir::ForeignItem<'_>) {
1, 1,
vec![Ty::new_imm_ref( vec![Ty::new_imm_ref(
tcx, tcx,
ty::Region::new_late_bound(tcx, ty::INNERMOST, br), ty::Region::new_bound(tcx, ty::INNERMOST, br),
param(0), param(0),
)], )],
Ty::new_projection(tcx, discriminant_def_id, tcx.mk_args(&[param(0).into()])), Ty::new_projection(tcx, discriminant_def_id, tcx.mk_args(&[param(0).into()])),
@ -465,11 +465,8 @@ pub fn check_intrinsic_type(tcx: TyCtxt<'_>, it: &hir::ForeignItem<'_>) {
sym::raw_eq => { sym::raw_eq => {
let br = ty::BoundRegion { var: ty::BoundVar::from_u32(0), kind: ty::BrAnon }; let br = ty::BoundRegion { var: ty::BoundVar::from_u32(0), kind: ty::BrAnon };
let param_ty = Ty::new_imm_ref( let param_ty =
tcx, Ty::new_imm_ref(tcx, ty::Region::new_bound(tcx, ty::INNERMOST, br), param(0));
ty::Region::new_late_bound(tcx, ty::INNERMOST, br),
param(0),
);
(1, vec![param_ty; 2], tcx.types.bool) (1, vec![param_ty; 2], tcx.types.bool)
} }

View file

@ -763,7 +763,7 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for GATSubstCollector<'tcx> {
ty::Alias(ty::Projection, p) if p.def_id == self.gat => { ty::Alias(ty::Projection, p) if p.def_id == self.gat => {
for (idx, subst) in p.args.iter().enumerate() { for (idx, subst) in p.args.iter().enumerate() {
match subst.unpack() { match subst.unpack() {
GenericArgKind::Lifetime(lt) if !lt.is_late_bound() => { GenericArgKind::Lifetime(lt) if !lt.is_bound() => {
self.regions.insert((lt, idx)); self.regions.insert((lt, idx));
} }
GenericArgKind::Type(t) => { GenericArgKind::Type(t) => {

View file

@ -196,6 +196,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for EraseAllBoundRegions<'tcx> {
self.tcx self.tcx
} }
fn fold_region(&mut self, r: Region<'tcx>) -> Region<'tcx> { fn fold_region(&mut self, r: Region<'tcx>) -> Region<'tcx> {
if r.is_late_bound() { self.tcx.lifetimes.re_erased } else { r } // FIXME(@lcnr): only erase escaping bound regions!
if r.is_bound() { self.tcx.lifetimes.re_erased } else { r }
} }
} }

View file

@ -167,8 +167,8 @@ fn is_free_region(region: Region<'_>) -> bool {
// } // }
// //
// The type above might generate a `T: 'b` bound, but we can // The type above might generate a `T: 'b` bound, but we can
// ignore it. We can't put it on the struct header anyway. // ignore it. We can't name this lifetime pn the struct header anyway.
ty::ReLateBound(..) => false, ty::ReBound(..) => false,
ty::ReError(_) => false, ty::ReError(_) => false,

View file

@ -419,9 +419,11 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
ty::ReStatic => {} ty::ReStatic => {}
ty::ReLateBound(..) => { ty::ReBound(..) => {
// Late-bound regions do not get substituted the same // Either a higher-ranked region inside of a type or a
// way early-bound regions do, so we skip them here. // late-bound function parameter.
//
// We do not compute constraints for either of these.
} }
ty::ReError(_) => {} ty::ReError(_) => {}

View file

@ -214,7 +214,7 @@ fn check_panic_info_fn(tcx: TyCtxt<'_>, fn_id: LocalDefId, fn_sig: ty::FnSig<'_>
// build type `for<'a, 'b> fn(&'a PanicInfo<'b>) -> !` // build type `for<'a, 'b> fn(&'a PanicInfo<'b>) -> !`
let panic_info_ty = tcx.type_of(panic_info_did).instantiate( let panic_info_ty = tcx.type_of(panic_info_did).instantiate(
tcx, tcx,
&[ty::GenericArg::from(ty::Region::new_late_bound( &[ty::GenericArg::from(ty::Region::new_bound(
tcx, tcx,
ty::INNERMOST, ty::INNERMOST,
ty::BoundRegion { var: ty::BoundVar::from_u32(1), kind: ty::BrAnon }, ty::BoundRegion { var: ty::BoundVar::from_u32(1), kind: ty::BrAnon },
@ -222,7 +222,7 @@ fn check_panic_info_fn(tcx: TyCtxt<'_>, fn_id: LocalDefId, fn_sig: ty::FnSig<'_>
); );
let panic_info_ref_ty = Ty::new_imm_ref( let panic_info_ref_ty = Ty::new_imm_ref(
tcx, tcx,
ty::Region::new_late_bound( ty::Region::new_bound(
tcx, tcx,
ty::INNERMOST, ty::INNERMOST,
ty::BoundRegion { var: ty::BoundVar::from_u32(0), kind: ty::BrAnon }, ty::BoundRegion { var: ty::BoundVar::from_u32(0), kind: ty::BrAnon },

View file

@ -784,7 +784,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for EraseEarlyRegions<'tcx> {
} }
} }
fn fold_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> { fn fold_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> {
if r.is_late_bound() { r } else { self.tcx.lifetimes.re_erased } if r.is_bound() { r } else { self.tcx.lifetimes.re_erased }
} }
} }
@ -822,7 +822,7 @@ impl<'cx, 'tcx> TypeFolder<TyCtxt<'tcx>> for Resolver<'cx, 'tcx> {
} }
fn fold_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> { fn fold_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> {
debug_assert!(!r.is_late_bound(), "Should not be resolving bound region."); debug_assert!(!r.is_bound(), "Should not be resolving bound region.");
self.fcx.tcx.lifetimes.re_erased self.fcx.tcx.lifetimes.re_erased
} }

View file

@ -73,8 +73,11 @@ impl<'a> DescriptionCtx<'a> {
// ReFree rather than dumping Debug output on the user. // ReFree rather than dumping Debug output on the user.
// //
// We shouldn't really be having unification failures with ReVar // We shouldn't really be having unification failures with ReVar
// and ReLateBound though. // and ReBound though.
ty::ReVar(_) | ty::ReLateBound(..) | ty::ReErased => { //
// FIXME(@lcnr): figure out why we `ReBound` have to handle `ReBound`
// here, this feels somewhat off.
ty::ReVar(_) | ty::ReBound(..) | ty::ReErased => {
(alt_span, "revar", format!("{region:?}")) (alt_span, "revar", format!("{region:?}"))
} }
}; };

View file

@ -232,7 +232,7 @@ impl CanonicalizeMode for CanonicalizeUserTypeAnnotation {
match *r { match *r {
ty::ReEarlyBound(_) | ty::ReFree(_) | ty::ReErased | ty::ReStatic | ty::ReError(_) => r, ty::ReEarlyBound(_) | ty::ReFree(_) | ty::ReErased | ty::ReStatic | ty::ReError(_) => r,
ty::ReVar(_) => canonicalizer.canonical_var_for_region_in_root_universe(r), ty::ReVar(_) => canonicalizer.canonical_var_for_region_in_root_universe(r),
ty::RePlaceholder(..) | ty::ReLateBound(..) => { ty::RePlaceholder(..) | ty::ReBound(..) => {
// We only expect region names that the user can type. // We only expect region names that the user can type.
bug!("unexpected region in query response: `{:?}`", r) bug!("unexpected region in query response: `{:?}`", r)
} }
@ -343,7 +343,7 @@ impl<'cx, 'tcx> TypeFolder<TyCtxt<'tcx>> for Canonicalizer<'cx, 'tcx> {
fn fold_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> { fn fold_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> {
match *r { match *r {
ty::ReLateBound(index, ..) => { ty::ReBound(index, ..) => {
if index >= self.binder_index { if index >= self.binder_index {
bug!("escaping late-bound region during canonicalization"); bug!("escaping late-bound region during canonicalization");
} else { } else {
@ -776,7 +776,7 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
) -> ty::Region<'tcx> { ) -> ty::Region<'tcx> {
let var = self.canonical_var(info, r.into()); let var = self.canonical_var(info, r.into());
let br = ty::BoundRegion { var, kind: ty::BrAnon }; let br = ty::BoundRegion { var, kind: ty::BrAnon };
ty::Region::new_late_bound(self.interner(), self.binder_index, br) ty::Region::new_bound(self.interner(), self.binder_index, br)
} }
/// Given a type variable `ty_var` of the given kind, first check /// Given a type variable `ty_var` of the given kind, first check

View file

@ -460,7 +460,7 @@ impl<'tcx> InferCtxt<'tcx> {
} }
GenericArgKind::Lifetime(result_value) => { GenericArgKind::Lifetime(result_value) => {
// e.g., here `result_value` might be `'?1` in the example above... // e.g., here `result_value` might be `'?1` in the example above...
if let ty::ReLateBound(debruijn, br) = *result_value { if let ty::ReBound(debruijn, br) = *result_value {
// ... in which case we would set `canonical_vars[0]` to `Some('static)`. // ... in which case we would set `canonical_vars[0]` to `Some('static)`.
// We only allow a `ty::INNERMOST` index in substitutions. // We only allow a `ty::INNERMOST` index in substitutions.

View file

@ -175,10 +175,10 @@ pub(super) fn note_and_explain_region<'tcx>(
ty::ReError(_) => return, ty::ReError(_) => return,
// We shouldn't really be having unification failures with ReVar // We shouldn't really be having unification failures with ReVar
// and ReLateBound though. // and ReBound though.
ty::ReVar(_) | ty::ReLateBound(..) | ty::ReErased => { //
(format!("lifetime `{region}`"), alt_span) // FIXME(@lcnr): Figure out whether this is reachable and if so, why.
} ty::ReVar(_) | ty::ReBound(..) | ty::ReErased => (format!("lifetime `{region}`"), alt_span),
}; };
emit_msg_span(err, prefix, description, span, suffix); emit_msg_span(err, prefix, description, span, suffix);
@ -1285,7 +1285,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
if lifetimes.0 != lifetimes.1 { if lifetimes.0 != lifetimes.1 {
values.0.push_highlighted(l1); values.0.push_highlighted(l1);
values.1.push_highlighted(l2); values.1.push_highlighted(l2);
} else if lifetimes.0.is_late_bound() { } else if lifetimes.0.is_bound() {
values.0.push_normal(l1); values.0.push_normal(l1);
values.1.push_normal(l2); values.1.push_normal(l2);
} else { } else {

View file

@ -572,8 +572,8 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
if let ty::Ref(expected_region, _, _) = expected.kind() if let ty::Ref(expected_region, _, _) = expected.kind()
&& let ty::Ref(found_region, _, _) = found.kind() && let ty::Ref(found_region, _, _) = found.kind()
&& expected_region.is_late_bound() && expected_region.is_bound()
&& !found_region.is_late_bound() && !found_region.is_bound()
&& let hir::TyKind::Infer = arg_hir.kind && let hir::TyKind::Infer = arg_hir.kind
{ {
// If the expected region is late bound, the found region is not, and users are asking compiler // If the expected region is late bound, the found region is not, and users are asking compiler

View file

@ -110,7 +110,7 @@ impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for TypeFreshener<'a, 'tcx> {
fn fold_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> { fn fold_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> {
match *r { match *r {
ty::ReLateBound(..) => { ty::ReBound(..) => {
// leave bound regions alone // leave bound regions alone
r r
} }

View file

@ -327,7 +327,7 @@ where
match *r { match *r {
// Never make variables for regions bound within the type itself, // Never make variables for regions bound within the type itself,
// nor for erased regions. // nor for erased regions.
ty::ReLateBound(..) | ty::ReErased => { ty::ReBound(..) | ty::ReErased => {
return Ok(r); return Ok(r);
} }

View file

@ -16,8 +16,8 @@ use rustc_data_structures::intern::Interned;
use rustc_index::{IndexSlice, IndexVec}; use rustc_index::{IndexSlice, IndexVec};
use rustc_middle::ty::fold::TypeFoldable; use rustc_middle::ty::fold::TypeFoldable;
use rustc_middle::ty::{self, Ty, TyCtxt}; use rustc_middle::ty::{self, Ty, TyCtxt};
use rustc_middle::ty::{ReBound, RePlaceholder, ReVar};
use rustc_middle::ty::{ReEarlyBound, ReErased, ReError, ReFree, ReStatic}; use rustc_middle::ty::{ReEarlyBound, ReErased, ReError, ReFree, ReStatic};
use rustc_middle::ty::{ReLateBound, RePlaceholder, ReVar};
use rustc_middle::ty::{Region, RegionVid}; use rustc_middle::ty::{Region, RegionVid};
use rustc_span::Span; use rustc_span::Span;
use std::fmt; use std::fmt;
@ -378,7 +378,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
// so it doesn't really matter if it's shorter or longer than an empty region // so it doesn't really matter if it's shorter or longer than an empty region
ReError(_) => false, ReError(_) => false,
ReLateBound(..) | ReErased => { ReBound(..) | ReErased => {
bug!("cannot relate region: {:?}", a); bug!("cannot relate region: {:?}", a);
} }
@ -411,7 +411,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
// so it doesn't really matter if it's shorter or longer than an empty region // so it doesn't really matter if it's shorter or longer than an empty region
ReError(_) => false, ReError(_) => false,
ReLateBound(..) | ReErased => { ReBound(..) | ReErased => {
bug!("cannot relate region: {:?}", b); bug!("cannot relate region: {:?}", b);
} }
@ -478,7 +478,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
#[instrument(level = "trace", skip(self), ret)] #[instrument(level = "trace", skip(self), ret)]
fn lub_concrete_regions(&self, a: Region<'tcx>, b: Region<'tcx>) -> Region<'tcx> { fn lub_concrete_regions(&self, a: Region<'tcx>, b: Region<'tcx>) -> Region<'tcx> {
match (*a, *b) { match (*a, *b) {
(ReLateBound(..), _) | (_, ReLateBound(..)) | (ReErased, _) | (_, ReErased) => { (ReBound(..), _) | (_, ReBound(..)) | (ReErased, _) | (_, ReErased) => {
bug!("cannot relate region: LUB({:?}, {:?})", a, b); bug!("cannot relate region: LUB({:?}, {:?})", a, b);
} }

View file

@ -432,7 +432,7 @@ where
fn visit_region(&mut self, r: ty::Region<'tcx>) -> ControlFlow<Self::BreakTy> { fn visit_region(&mut self, r: ty::Region<'tcx>) -> ControlFlow<Self::BreakTy> {
match *r { match *r {
// ignore bound regions, keep visiting // ignore bound regions, keep visiting
ty::ReLateBound(_, _) => ControlFlow::Continue(()), ty::ReBound(_, _) => ControlFlow::Continue(()),
_ => { _ => {
(self.op)(r); (self.op)(r);
ControlFlow::Continue(()) ControlFlow::Continue(())

View file

@ -213,8 +213,8 @@ pub(super) fn compute_alias_components_recursive<'tcx>(
compute_components(tcx, ty, out, visited); compute_components(tcx, ty, out, visited);
} }
GenericArgKind::Lifetime(lt) => { GenericArgKind::Lifetime(lt) => {
// Ignore late-bound regions. // Ignore higher ranked regions.
if !lt.is_late_bound() { if !lt.is_bound() {
out.push(Component::Region(lt)); out.push(Component::Region(lt));
} }
} }
@ -241,8 +241,8 @@ fn compute_components_recursive<'tcx>(
compute_components(tcx, ty, out, visited); compute_components(tcx, ty, out, visited);
} }
GenericArgKind::Lifetime(lt) => { GenericArgKind::Lifetime(lt) => {
// Ignore late-bound regions. // Ignore higher ranked regions.
if !lt.is_late_bound() { if !lt.is_bound() {
out.push(Component::Region(lt)); out.push(Component::Region(lt));
} }
} }

View file

@ -37,7 +37,7 @@ where
fn visit_region(&mut self, r: ty::Region<'tcx>) -> ControlFlow<Self::BreakTy> { fn visit_region(&mut self, r: ty::Region<'tcx>) -> ControlFlow<Self::BreakTy> {
match *r { match *r {
// ignore bound regions, keep visiting // ignore bound regions, keep visiting
ty::ReLateBound(_, _) => ControlFlow::Continue(()), ty::ReBound(_, _) => ControlFlow::Continue(()),
_ => { _ => {
(self.op)(r); (self.op)(r);
ControlFlow::Continue(()) ControlFlow::Continue(())

View file

@ -48,7 +48,7 @@ pub fn extract_verify_if_eq<'tcx>(
let verify_if_eq = verify_if_eq_b.skip_binder(); let verify_if_eq = verify_if_eq_b.skip_binder();
m.relate(verify_if_eq.ty, test_ty).ok()?; m.relate(verify_if_eq.ty, test_ty).ok()?;
if let ty::RegionKind::ReLateBound(depth, br) = verify_if_eq.bound.kind() { if let ty::RegionKind::ReBound(depth, br) = verify_if_eq.bound.kind() {
assert!(depth == ty::INNERMOST); assert!(depth == ty::INNERMOST);
match m.map.get(&br) { match m.map.get(&br) {
Some(&r) => Some(r), Some(&r) => Some(r),
@ -177,7 +177,7 @@ impl<'tcx> TypeRelation<'tcx> for MatchAgainstHigherRankedOutlives<'tcx> {
value: ty::Region<'tcx>, value: ty::Region<'tcx>,
) -> RelateResult<'tcx, ty::Region<'tcx>> { ) -> RelateResult<'tcx, ty::Region<'tcx>> {
debug!("self.pattern_depth = {:?}", self.pattern_depth); debug!("self.pattern_depth = {:?}", self.pattern_depth);
if let ty::RegionKind::ReLateBound(depth, br) = pattern.kind() if let ty::RegionKind::ReBound(depth, br) = pattern.kind()
&& depth == self.pattern_depth && depth == self.pattern_depth
{ {
self.bind(br, value) self.bind(br, value)

View file

@ -16,7 +16,7 @@ use rustc_index::IndexVec;
use rustc_middle::infer::unify_key::{RegionVidKey, UnifiedRegion}; use rustc_middle::infer::unify_key::{RegionVidKey, UnifiedRegion};
use rustc_middle::ty::ReStatic; use rustc_middle::ty::ReStatic;
use rustc_middle::ty::{self, Ty, TyCtxt}; use rustc_middle::ty::{self, Ty, TyCtxt};
use rustc_middle::ty::{ReLateBound, ReVar}; use rustc_middle::ty::{ReBound, ReVar};
use rustc_middle::ty::{Region, RegionVid}; use rustc_middle::ty::{Region, RegionVid};
use rustc_span::Span; use rustc_span::Span;
@ -531,7 +531,7 @@ impl<'tcx> RegionConstraintCollector<'_, 'tcx> {
debug!("origin = {:#?}", origin); debug!("origin = {:#?}", origin);
match (*sub, *sup) { match (*sub, *sup) {
(ReLateBound(..), _) | (_, ReLateBound(..)) => { (ReBound(..), _) | (_, ReBound(..)) => {
span_bug!(origin.span(), "cannot relate bound region: {:?} <= {:?}", sub, sup); span_bug!(origin.span(), "cannot relate bound region: {:?} <= {:?}", sub, sup);
} }
(_, ReStatic) => { (_, ReStatic) => {
@ -667,7 +667,7 @@ impl<'tcx> RegionConstraintCollector<'_, 'tcx> {
| ty::ReError(_) => ty::UniverseIndex::ROOT, | ty::ReError(_) => ty::UniverseIndex::ROOT,
ty::RePlaceholder(placeholder) => placeholder.universe, ty::RePlaceholder(placeholder) => placeholder.universe,
ty::ReVar(vid) => self.var_universe(vid), ty::ReVar(vid) => self.var_universe(vid),
ty::ReLateBound(..) => bug!("universe(): encountered bound region {:?}", region), ty::ReBound(..) => bug!("universe(): encountered bound region {:?}", region),
} }
} }

View file

@ -340,7 +340,7 @@ impl<'tcx, O: Elaboratable<'tcx>> Elaborator<'tcx, O> {
// consider this as evidence that `T: 'static`, but // consider this as evidence that `T: 'static`, but
// I'm a bit wary of such constructions and so for now // I'm a bit wary of such constructions and so for now
// I want to be conservative. --nmatsakis // I want to be conservative. --nmatsakis
if r_min.is_late_bound() { if r_min.is_bound() {
return; return;
} }
@ -351,7 +351,7 @@ impl<'tcx, O: Elaboratable<'tcx>> Elaborator<'tcx, O> {
.into_iter() .into_iter()
.filter_map(|component| match component { .filter_map(|component| match component {
Component::Region(r) => { Component::Region(r) => {
if r.is_late_bound() { if r.is_bound() {
None None
} else { } else {
Some(ty::ClauseKind::RegionOutlives(ty::OutlivesPredicate( Some(ty::ClauseKind::RegionOutlives(ty::OutlivesPredicate(

View file

@ -63,7 +63,7 @@ impl CanonicalVarValues<'_> {
pub fn is_identity(&self) -> bool { pub fn is_identity(&self) -> bool {
self.var_values.iter().enumerate().all(|(bv, arg)| match arg.unpack() { self.var_values.iter().enumerate().all(|(bv, arg)| match arg.unpack() {
ty::GenericArgKind::Lifetime(r) => { ty::GenericArgKind::Lifetime(r) => {
matches!(*r, ty::ReLateBound(ty::INNERMOST, br) if br.var.as_usize() == bv) matches!(*r, ty::ReBound(ty::INNERMOST, br) if br.var.as_usize() == bv)
} }
ty::GenericArgKind::Type(ty) => { ty::GenericArgKind::Type(ty) => {
matches!(*ty.kind(), ty::Bound(ty::INNERMOST, bt) if bt.var.as_usize() == bv) matches!(*ty.kind(), ty::Bound(ty::INNERMOST, bt) if bt.var.as_usize() == bv)
@ -79,7 +79,7 @@ impl CanonicalVarValues<'_> {
for arg in self.var_values { for arg in self.var_values {
match arg.unpack() { match arg.unpack() {
ty::GenericArgKind::Lifetime(r) => { ty::GenericArgKind::Lifetime(r) => {
if let ty::ReLateBound(ty::INNERMOST, br) = *r if let ty::ReBound(ty::INNERMOST, br) = *r
&& var == br.var && var == br.var
{ {
var = var + 1; var = var + 1;
@ -389,7 +389,7 @@ impl<'tcx> CanonicalVarValues<'tcx> {
var: ty::BoundVar::from_usize(i), var: ty::BoundVar::from_usize(i),
kind: ty::BrAnon, kind: ty::BrAnon,
}; };
ty::Region::new_late_bound(tcx, ty::INNERMOST, br).into() ty::Region::new_bound(tcx, ty::INNERMOST, br).into()
} }
CanonicalVarKind::Effect => ty::Const::new_bound( CanonicalVarKind::Effect => ty::Const::new_bound(
tcx, tcx,

View file

@ -58,8 +58,7 @@ impl<'tcx> UnifyValue for UnifiedRegion<'tcx> {
fn unify_values(value1: &Self, value2: &Self) -> Result<Self, NoError> { fn unify_values(value1: &Self, value2: &Self) -> Result<Self, NoError> {
// We pick the value of the least universe because it is compatible with more variables. // We pick the value of the least universe because it is compatible with more variables.
// This is *not* necessary for soundness, but it allows more region variables to be // This is *not* necessary for completeness.
// resolved to the said value.
#[cold] #[cold]
fn min_universe<'tcx>(r1: Region<'tcx>, r2: Region<'tcx>) -> Region<'tcx> { fn min_universe<'tcx>(r1: Region<'tcx>, r2: Region<'tcx>) -> Region<'tcx> {
cmp::min_by_key(r1, r2, |r| match r.kind() { cmp::min_by_key(r1, r2, |r| match r.kind() {
@ -69,7 +68,7 @@ impl<'tcx> UnifyValue for UnifiedRegion<'tcx> {
| ty::ReEarlyBound(..) | ty::ReEarlyBound(..)
| ty::ReError(_) => ty::UniverseIndex::ROOT, | ty::ReError(_) => ty::UniverseIndex::ROOT,
ty::RePlaceholder(placeholder) => placeholder.universe, ty::RePlaceholder(placeholder) => placeholder.universe,
ty::ReVar(..) | ty::ReLateBound(..) => bug!("not a universal region"), ty::ReVar(..) | ty::ReBound(..) => bug!("not a universal region"),
}) })
} }

View file

@ -416,7 +416,7 @@ impl<'tcx> ClosureOutlivesSubjectTy<'tcx> {
let inner = tcx.fold_regions(ty, |r, depth| match r.kind() { let inner = tcx.fold_regions(ty, |r, depth| match r.kind() {
ty::ReVar(vid) => { ty::ReVar(vid) => {
let br = ty::BoundRegion { var: ty::BoundVar::new(vid.index()), kind: ty::BrAnon }; let br = ty::BoundRegion { var: ty::BoundVar::new(vid.index()), kind: ty::BrAnon };
ty::Region::new_late_bound(tcx, depth, br) ty::Region::new_bound(tcx, depth, br)
} }
_ => bug!("unexpected region in ClosureOutlivesSubjectTy: {r:?}"), _ => bug!("unexpected region in ClosureOutlivesSubjectTy: {r:?}"),
}); });
@ -430,7 +430,7 @@ impl<'tcx> ClosureOutlivesSubjectTy<'tcx> {
mut map: impl FnMut(ty::RegionVid) -> ty::Region<'tcx>, mut map: impl FnMut(ty::RegionVid) -> ty::Region<'tcx>,
) -> Ty<'tcx> { ) -> Ty<'tcx> {
tcx.fold_regions(self.inner, |r, depth| match r.kind() { tcx.fold_regions(self.inner, |r, depth| match r.kind() {
ty::ReLateBound(debruijn, br) => { ty::ReBound(debruijn, br) => {
debug_assert_eq!(debruijn, depth); debug_assert_eq!(debruijn, depth);
map(ty::RegionVid::new(br.var.index())) map(ty::RegionVid::new(br.var.index()))
} }

View file

@ -327,7 +327,7 @@ pub struct CommonLifetimes<'tcx> {
pub re_vars: Vec<Region<'tcx>>, pub re_vars: Vec<Region<'tcx>>,
/// Pre-interned values of the form: /// Pre-interned values of the form:
/// `ReLateBound(DebruijnIndex(i), BoundRegion { var: v, kind: BrAnon })` /// `ReBound(DebruijnIndex(i), BoundRegion { var: v, kind: BrAnon })`
/// for small values of `i` and `v`. /// for small values of `i` and `v`.
pub re_late_bounds: Vec<Vec<Region<'tcx>>>, pub re_late_bounds: Vec<Vec<Region<'tcx>>>,
} }
@ -402,7 +402,7 @@ impl<'tcx> CommonLifetimes<'tcx> {
.map(|i| { .map(|i| {
(0..NUM_PREINTERNED_RE_LATE_BOUNDS_V) (0..NUM_PREINTERNED_RE_LATE_BOUNDS_V)
.map(|v| { .map(|v| {
mk(ty::ReLateBound( mk(ty::ReBound(
ty::DebruijnIndex::from(i), ty::DebruijnIndex::from(i),
ty::BoundRegion { var: ty::BoundVar::from(v), kind: ty::BrAnon }, ty::BoundRegion { var: ty::BoundVar::from(v), kind: ty::BrAnon },
)) ))

View file

@ -53,16 +53,11 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for RegionEraserVisitor<'tcx> {
} }
fn fold_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> { fn fold_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> {
// because late-bound regions affect subtyping, we can't // We must not erase bound regions. `for<'a> fn(&'a ())` and
// erase the bound/free distinction, but we can replace // `fn(&'free ())` are different types: they may implement different
// all free regions with 'erased. // traits and have a different `TypeId`.
//
// Note that we *CAN* replace early-bound regions -- the
// type system never "sees" those, they get substituted
// away. In codegen, they will always be erased to 'erased
// whenever a substitution occurs.
match *r { match *r {
ty::ReLateBound(..) => r, ty::ReBound(..) => r,
_ => self.tcx.lifetimes.re_erased, _ => self.tcx.lifetimes.re_erased,
} }
} }

View file

@ -294,7 +294,7 @@ impl FlagComputation {
fn add_region(&mut self, r: ty::Region<'_>) { fn add_region(&mut self, r: ty::Region<'_>) {
self.add_flags(r.type_flags()); self.add_flags(r.type_flags());
if let ty::ReLateBound(debruijn, _) = *r { if let ty::ReBound(debruijn, _) = *r {
self.add_bound_var(debruijn); self.add_bound_var(debruijn);
} }
} }

View file

@ -68,12 +68,10 @@ impl<'tcx> TyCtxt<'tcx> {
/// Folds over the substructure of a type, visiting its component /// Folds over the substructure of a type, visiting its component
/// types and all regions that occur *free* within it. /// types and all regions that occur *free* within it.
/// ///
/// That is, `Ty` can contain function or method types that bind /// That is, function pointer types and trait object can introduce
/// regions at the call site (`ReLateBound`), and occurrences of /// new bound regions which are not visited by this visitors as
/// regions (aka "lifetimes") that are bound within a type are not /// they are not free; only regions that occur free will be
/// visited by this folder; only regions that occur free will be
/// visited by `fld_r`. /// visited by `fld_r`.
pub struct RegionFolder<'a, 'tcx> { pub struct RegionFolder<'a, 'tcx> {
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
@ -117,7 +115,7 @@ impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for RegionFolder<'a, 'tcx> {
#[instrument(skip(self), level = "debug", ret)] #[instrument(skip(self), level = "debug", ret)]
fn fold_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> { fn fold_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> {
match *r { match *r {
ty::ReLateBound(debruijn, _) if debruijn < self.current_index => { ty::ReBound(debruijn, _) if debruijn < self.current_index => {
debug!(?self.current_index, "skipped bound region"); debug!(?self.current_index, "skipped bound region");
r r
} }
@ -205,15 +203,15 @@ where
fn fold_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> { fn fold_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> {
match *r { match *r {
ty::ReLateBound(debruijn, br) if debruijn == self.current_index => { ty::ReBound(debruijn, br) if debruijn == self.current_index => {
let region = self.delegate.replace_region(br); let region = self.delegate.replace_region(br);
if let ty::ReLateBound(debruijn1, br) = *region { if let ty::ReBound(debruijn1, br) = *region {
// If the callback returns a late-bound region, // If the callback returns a bound region,
// that region should always use the INNERMOST // that region should always use the INNERMOST
// debruijn index. Then we adjust it to the // debruijn index. Then we adjust it to the
// correct depth. // correct depth.
assert_eq!(debruijn1, ty::INNERMOST); assert_eq!(debruijn1, ty::INNERMOST);
ty::Region::new_late_bound(self.tcx, debruijn, br) ty::Region::new_bound(self.tcx, debruijn, br)
} else { } else {
region region
} }
@ -341,7 +339,7 @@ impl<'tcx> TyCtxt<'tcx> {
value, value,
FnMutDelegate { FnMutDelegate {
regions: &mut |r: ty::BoundRegion| { regions: &mut |r: ty::BoundRegion| {
ty::Region::new_late_bound( ty::Region::new_bound(
self, self,
ty::INNERMOST, ty::INNERMOST,
ty::BoundRegion { var: shift_bv(r.var), kind: r.kind }, ty::BoundRegion { var: shift_bv(r.var), kind: r.kind },
@ -388,7 +386,7 @@ impl<'tcx> TyCtxt<'tcx> {
.or_insert_with(|| ty::BoundVariableKind::Region(ty::BrAnon)) .or_insert_with(|| ty::BoundVariableKind::Region(ty::BrAnon))
.expect_region(); .expect_region();
let br = ty::BoundRegion { var, kind }; let br = ty::BoundRegion { var, kind };
ty::Region::new_late_bound(self.tcx, ty::INNERMOST, br) ty::Region::new_bound(self.tcx, ty::INNERMOST, br)
} }
fn replace_ty(&mut self, bt: ty::BoundTy) -> Ty<'tcx> { fn replace_ty(&mut self, bt: ty::BoundTy) -> Ty<'tcx> {
let entry = self.map.entry(bt.var); let entry = self.map.entry(bt.var);
@ -454,9 +452,9 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for Shifter<'tcx> {
fn fold_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> { fn fold_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> {
match *r { match *r {
ty::ReLateBound(debruijn, br) if debruijn >= self.current_index => { ty::ReBound(debruijn, br) if debruijn >= self.current_index => {
let debruijn = debruijn.shifted_in(self.amount); let debruijn = debruijn.shifted_in(self.amount);
ty::Region::new_late_bound(self.tcx, debruijn, br) ty::Region::new_bound(self.tcx, debruijn, br)
} }
_ => r, _ => r,
} }
@ -496,8 +494,8 @@ pub fn shift_region<'tcx>(
amount: u32, amount: u32,
) -> ty::Region<'tcx> { ) -> ty::Region<'tcx> {
match *region { match *region {
ty::ReLateBound(debruijn, br) if amount > 0 => { ty::ReBound(debruijn, br) if amount > 0 => {
ty::Region::new_late_bound(tcx, debruijn.shifted_in(amount), br) ty::Region::new_bound(tcx, debruijn.shifted_in(amount), br)
} }
_ => region, _ => region,
} }

View file

@ -843,7 +843,7 @@ impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for ArgFolder<'a, 'tcx> {
None => region_param_out_of_range(data, self.args), None => region_param_out_of_range(data, self.args),
} }
} }
ty::ReLateBound(..) ty::ReBound(..)
| ty::ReFree(_) | ty::ReFree(_)
| ty::ReStatic | ty::ReStatic
| ty::RePlaceholder(_) | ty::RePlaceholder(_)

View file

@ -102,8 +102,9 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ReverseMapper<'tcx> {
// Ignore bound regions and `'static` regions that appear in the // Ignore bound regions and `'static` regions that appear in the
// type, we only need to remap regions that reference lifetimes // type, we only need to remap regions that reference lifetimes
// from the function declaration. // from the function declaration.
// This would ignore `'r` in a type like `for<'r> fn(&'r u32)`. //
ty::ReLateBound(..) | ty::ReStatic => return r, // E.g. We ignore `'r` in a type like `for<'r> fn(&'r u32)`.
ty::ReBound(..) | ty::ReStatic => return r,
// If regions have been erased (by writeback), don't try to unerase // If regions have been erased (by writeback), don't try to unerase
// them. // them.

View file

@ -2160,7 +2160,7 @@ impl<'tcx> PrettyPrinter<'tcx> for FmtPrinter<'_, 'tcx> {
match *region { match *region {
ty::ReEarlyBound(ref data) => data.has_name(), ty::ReEarlyBound(ref data) => data.has_name(),
ty::ReLateBound(_, ty::BoundRegion { kind: br, .. }) ty::ReBound(_, ty::BoundRegion { kind: br, .. })
| ty::ReFree(ty::FreeRegion { bound_region: br, .. }) | ty::ReFree(ty::FreeRegion { bound_region: br, .. })
| ty::RePlaceholder(ty::Placeholder { | ty::RePlaceholder(ty::Placeholder {
bound: ty::BoundRegion { kind: br, .. }, .. bound: ty::BoundRegion { kind: br, .. }, ..
@ -2234,7 +2234,7 @@ impl<'tcx> FmtPrinter<'_, 'tcx> {
return Ok(()); return Ok(());
} }
} }
ty::ReLateBound(_, ty::BoundRegion { kind: br, .. }) ty::ReBound(_, ty::BoundRegion { kind: br, .. })
| ty::ReFree(ty::FreeRegion { bound_region: br, .. }) | ty::ReFree(ty::FreeRegion { bound_region: br, .. })
| ty::RePlaceholder(ty::Placeholder { | ty::RePlaceholder(ty::Placeholder {
bound: ty::BoundRegion { kind: br, .. }, .. bound: ty::BoundRegion { kind: br, .. }, ..
@ -2315,7 +2315,7 @@ impl<'a, 'tcx> ty::TypeFolder<TyCtxt<'tcx>> for RegionFolder<'a, 'tcx> {
fn fold_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> { fn fold_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> {
let name = &mut self.name; let name = &mut self.name;
let region = match *r { let region = match *r {
ty::ReLateBound(db, br) if db >= self.current_index => { ty::ReBound(db, br) if db >= self.current_index => {
*self.region_map.entry(br).or_insert_with(|| name(Some(db), self.current_index, br)) *self.region_map.entry(br).or_insert_with(|| name(Some(db), self.current_index, br))
} }
ty::RePlaceholder(ty::PlaceholderRegion { ty::RePlaceholder(ty::PlaceholderRegion {
@ -2338,9 +2338,9 @@ impl<'a, 'tcx> ty::TypeFolder<TyCtxt<'tcx>> for RegionFolder<'a, 'tcx> {
} }
_ => return r, _ => return r,
}; };
if let ty::ReLateBound(debruijn1, br) = *region { if let ty::ReBound(debruijn1, br) = *region {
assert_eq!(debruijn1, ty::INNERMOST); assert_eq!(debruijn1, ty::INNERMOST);
ty::Region::new_late_bound(self.tcx, self.current_index, br) ty::Region::new_bound(self.tcx, self.current_index, br)
} else { } else {
region region
} }
@ -2450,7 +2450,7 @@ impl<'tcx> FmtPrinter<'_, 'tcx> {
if let Some(lt_idx) = lifetime_idx { if let Some(lt_idx) = lifetime_idx {
if lt_idx > binder_level_idx { if lt_idx > binder_level_idx {
let kind = ty::BrNamed(CRATE_DEF_ID.to_def_id(), name); let kind = ty::BrNamed(CRATE_DEF_ID.to_def_id(), name);
return ty::Region::new_late_bound( return ty::Region::new_bound(
tcx, tcx,
ty::INNERMOST, ty::INNERMOST,
ty::BoundRegion { var: br.var, kind }, ty::BoundRegion { var: br.var, kind },
@ -2466,7 +2466,7 @@ impl<'tcx> FmtPrinter<'_, 'tcx> {
if let Some(lt_idx) = lifetime_idx { if let Some(lt_idx) = lifetime_idx {
if lt_idx > binder_level_idx { if lt_idx > binder_level_idx {
let kind = ty::BrNamed(def_id, name); let kind = ty::BrNamed(def_id, name);
return ty::Region::new_late_bound( return ty::Region::new_bound(
tcx, tcx,
ty::INNERMOST, ty::INNERMOST,
ty::BoundRegion { var: br.var, kind }, ty::BoundRegion { var: br.var, kind },
@ -2480,7 +2480,7 @@ impl<'tcx> FmtPrinter<'_, 'tcx> {
if let Some(lt_idx) = lifetime_idx { if let Some(lt_idx) = lifetime_idx {
if lt_idx > binder_level_idx { if lt_idx > binder_level_idx {
let kind = br.kind; let kind = br.kind;
return ty::Region::new_late_bound( return ty::Region::new_bound(
tcx, tcx,
ty::INNERMOST, ty::INNERMOST,
ty::BoundRegion { var: br.var, kind }, ty::BoundRegion { var: br.var, kind },
@ -2496,11 +2496,7 @@ impl<'tcx> FmtPrinter<'_, 'tcx> {
start_or_continue(self, "for<", ", "); start_or_continue(self, "for<", ", ");
do_continue(self, name); do_continue(self, name);
} }
ty::Region::new_late_bound( ty::Region::new_bound(tcx, ty::INNERMOST, ty::BoundRegion { var: br.var, kind })
tcx,
ty::INNERMOST,
ty::BoundRegion { var: br.var, kind },
)
}; };
let mut folder = RegionFolder { let mut folder = RegionFolder {
tcx, tcx,

View file

@ -1476,7 +1476,7 @@ impl<'tcx> Region<'tcx> {
} }
#[inline] #[inline]
pub fn new_late_bound( pub fn new_bound(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
debruijn: ty::DebruijnIndex, debruijn: ty::DebruijnIndex,
bound_region: ty::BoundRegion, bound_region: ty::BoundRegion,
@ -1488,7 +1488,7 @@ impl<'tcx> Region<'tcx> {
{ {
re re
} else { } else {
tcx.intern_region(ty::ReLateBound(debruijn, bound_region)) tcx.intern_region(ty::ReBound(debruijn, bound_region))
} }
} }
@ -1550,7 +1550,7 @@ impl<'tcx> Region<'tcx> {
pub fn new_from_kind(tcx: TyCtxt<'tcx>, kind: RegionKind<'tcx>) -> Region<'tcx> { pub fn new_from_kind(tcx: TyCtxt<'tcx>, kind: RegionKind<'tcx>) -> Region<'tcx> {
match kind { match kind {
ty::ReEarlyBound(region) => Region::new_early_bound(tcx, region), ty::ReEarlyBound(region) => Region::new_early_bound(tcx, region),
ty::ReLateBound(debruijn, region) => Region::new_late_bound(tcx, debruijn, region), ty::ReBound(debruijn, region) => Region::new_bound(tcx, debruijn, region),
ty::ReFree(ty::FreeRegion { scope, bound_region }) => { ty::ReFree(ty::FreeRegion { scope, bound_region }) => {
Region::new_free(tcx, scope, bound_region) Region::new_free(tcx, scope, bound_region)
} }
@ -1723,7 +1723,7 @@ impl<'tcx> Region<'tcx> {
if self.has_name() { if self.has_name() {
match *self { match *self {
ty::ReEarlyBound(ebr) => Some(ebr.name), ty::ReEarlyBound(ebr) => Some(ebr.name),
ty::ReLateBound(_, br) => br.kind.get_name(), ty::ReBound(_, br) => br.kind.get_name(),
ty::ReFree(fr) => fr.bound_region.get_name(), ty::ReFree(fr) => fr.bound_region.get_name(),
ty::ReStatic => Some(kw::StaticLifetime), ty::ReStatic => Some(kw::StaticLifetime),
ty::RePlaceholder(placeholder) => placeholder.bound.kind.get_name(), ty::RePlaceholder(placeholder) => placeholder.bound.kind.get_name(),
@ -1745,7 +1745,7 @@ impl<'tcx> Region<'tcx> {
pub fn has_name(self) -> bool { pub fn has_name(self) -> bool {
match *self { match *self {
ty::ReEarlyBound(ebr) => ebr.has_name(), ty::ReEarlyBound(ebr) => ebr.has_name(),
ty::ReLateBound(_, br) => br.kind.is_named(), ty::ReBound(_, br) => br.kind.is_named(),
ty::ReFree(fr) => fr.bound_region.is_named(), ty::ReFree(fr) => fr.bound_region.is_named(),
ty::ReStatic => true, ty::ReStatic => true,
ty::ReVar(..) => false, ty::ReVar(..) => false,
@ -1771,8 +1771,8 @@ impl<'tcx> Region<'tcx> {
} }
#[inline] #[inline]
pub fn is_late_bound(self) -> bool { pub fn is_bound(self) -> bool {
matches!(*self, ty::ReLateBound(..)) matches!(*self, ty::ReBound(..))
} }
#[inline] #[inline]
@ -1783,7 +1783,7 @@ impl<'tcx> Region<'tcx> {
#[inline] #[inline]
pub fn bound_at_or_above_binder(self, index: ty::DebruijnIndex) -> bool { pub fn bound_at_or_above_binder(self, index: ty::DebruijnIndex) -> bool {
match *self { match *self {
ty::ReLateBound(debruijn, _) => debruijn >= index, ty::ReBound(debruijn, _) => debruijn >= index,
_ => false, _ => false,
} }
} }
@ -1814,7 +1814,7 @@ impl<'tcx> Region<'tcx> {
ty::ReStatic => { ty::ReStatic => {
flags = flags | TypeFlags::HAS_FREE_REGIONS; flags = flags | TypeFlags::HAS_FREE_REGIONS;
} }
ty::ReLateBound(..) => { ty::ReBound(..) => {
flags = flags | TypeFlags::HAS_RE_LATE_BOUND; flags = flags | TypeFlags::HAS_RE_LATE_BOUND;
} }
ty::ReErased => { ty::ReErased => {

View file

@ -638,7 +638,7 @@ impl<'tcx> IsIdentity for CanonicalUserType<'tcx> {
}, },
GenericArgKind::Lifetime(r) => match *r { GenericArgKind::Lifetime(r) => match *r {
ty::ReLateBound(debruijn, br) => { ty::ReBound(debruijn, br) => {
// We only allow a `ty::INNERMOST` index in substitutions. // We only allow a `ty::INNERMOST` index in substitutions.
assert_eq!(debruijn, ty::INNERMOST); assert_eq!(debruijn, ty::INNERMOST);
cvar == br.var cvar == br.var

View file

@ -468,7 +468,7 @@ impl<'tcx> TyCtxt<'tcx> {
for arg in args { for arg in args {
match arg.unpack() { match arg.unpack() {
GenericArgKind::Lifetime(lt) => match (ignore_regions, lt.kind()) { GenericArgKind::Lifetime(lt) => match (ignore_regions, lt.kind()) {
(CheckRegions::Bound, ty::ReLateBound(di, reg)) => { (CheckRegions::Bound, ty::ReBound(di, reg)) => {
if !seen_late.insert((di, reg)) { if !seen_late.insert((di, reg)) {
return Err(NotUniqueParam::DuplicateParam(lt.into())); return Err(NotUniqueParam::DuplicateParam(lt.into()));
} }

View file

@ -204,7 +204,7 @@ impl<'tcx> TyCtxt<'tcx> {
fn visit_region(&mut self, r: ty::Region<'tcx>) -> ControlFlow<Self::BreakTy> { fn visit_region(&mut self, r: ty::Region<'tcx>) -> ControlFlow<Self::BreakTy> {
match *r { match *r {
ty::ReLateBound(debruijn, _) if debruijn < self.outer_index => { ty::ReBound(debruijn, _) if debruijn < self.outer_index => {
ControlFlow::Continue(()) ControlFlow::Continue(())
} }
_ => { _ => {
@ -337,7 +337,7 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for ValidateBoundVars<'tcx> {
fn visit_region(&mut self, r: ty::Region<'tcx>) -> ControlFlow<Self::BreakTy> { fn visit_region(&mut self, r: ty::Region<'tcx>) -> ControlFlow<Self::BreakTy> {
match *r { match *r {
ty::ReLateBound(index, br) if index == self.binder_index => { ty::ReBound(index, br) if index == self.binder_index => {
if self.bound_vars.len() <= br.var.as_usize() { if self.bound_vars.len() <= br.var.as_usize() {
bug!("Not enough bound vars: {:?} not found in {:?}", br, self.bound_vars); bug!("Not enough bound vars: {:?} not found in {:?}", br, self.bound_vars);
} }
@ -613,7 +613,7 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for LateBoundRegionsCollector {
} }
fn visit_region(&mut self, r: ty::Region<'tcx>) -> ControlFlow<Self::BreakTy> { fn visit_region(&mut self, r: ty::Region<'tcx>) -> ControlFlow<Self::BreakTy> {
if let ty::ReLateBound(debruijn, br) = *r { if let ty::ReBound(debruijn, br) = *r {
if debruijn == self.current_index { if debruijn == self.current_index {
self.regions.insert(br.kind); self.regions.insert(br.kind);
} }

View file

@ -132,7 +132,7 @@ impl<'tcx> Cx<'tcx> {
var: ty::BoundVar::from_usize(bound_vars.len() - 1), var: ty::BoundVar::from_usize(bound_vars.len() - 1),
kind: ty::BrEnv, kind: ty::BrEnv,
}; };
let env_region = ty::Region::new_late_bound(self.tcx, ty::INNERMOST, br); let env_region = ty::Region::new_bound(self.tcx, ty::INNERMOST, br);
let closure_env_ty = let closure_env_ty =
self.tcx.closure_env_ty(closure_def_id, closure_args, env_region).unwrap(); self.tcx.closure_env_ty(closure_def_id, closure_args, env_region).unwrap();
let liberated_closure_env_ty = self.tcx.erase_late_bound_regions( let liberated_closure_env_ty = self.tcx.erase_late_bound_regions(

View file

@ -1696,7 +1696,7 @@ impl<'tcx> Stable<'tcx> for ty::RegionKind<'tcx> {
index: early_reg.index, index: early_reg.index,
name: early_reg.name.to_string(), name: early_reg.name.to_string(),
}), }),
ty::ReLateBound(db_index, bound_reg) => RegionKind::ReLateBound( ty::ReBound(db_index, bound_reg) => RegionKind::ReBound(
db_index.as_u32(), db_index.as_u32(),
BoundRegion { var: bound_reg.var.as_u32(), kind: bound_reg.kind.stable(tables) }, BoundRegion { var: bound_reg.var.as_u32(), kind: bound_reg.kind.stable(tables) },
), ),

View file

@ -270,7 +270,7 @@ fn encode_region<'tcx>(
// u6region[I[<region-disambiguator>][<region-index>]E] as vendor extended type // u6region[I[<region-disambiguator>][<region-index>]E] as vendor extended type
let mut s = String::new(); let mut s = String::new();
match region.kind() { match region.kind() {
RegionKind::ReLateBound(debruijn, r) => { RegionKind::ReBound(debruijn, r) => {
s.push_str("u6regionI"); s.push_str("u6regionI");
// Debruijn index, which identifies the binder, as region disambiguator // Debruijn index, which identifies the binder, as region disambiguator
let num = debruijn.index() as u64; let num = debruijn.index() as u64;
@ -282,6 +282,7 @@ fn encode_region<'tcx>(
s.push('E'); s.push('E');
compress(dict, DictKey::Region(region), &mut s); compress(dict, DictKey::Region(region), &mut s);
} }
// FIXME(@lcnr): Why is `ReEarlyBound` reachable here.
RegionKind::ReEarlyBound(..) | RegionKind::ReErased => { RegionKind::ReEarlyBound(..) | RegionKind::ReErased => {
s.push_str("u6region"); s.push_str("u6region");
compress(dict, DictKey::Region(region), &mut s); compress(dict, DictKey::Region(region), &mut s);

View file

@ -319,9 +319,9 @@ impl<'tcx> Printer<'tcx> for SymbolMangler<'tcx> {
// shorter mangling of `L_`. // shorter mangling of `L_`.
ty::ReErased => 0, ty::ReErased => 0,
// Late-bound lifetimes use indices starting at 1, // Bound lifetimes use indices starting at 1,
// see `BinderLevel` for more details. // see `BinderLevel` for more details.
ty::ReLateBound(debruijn, ty::BoundRegion { var, kind: ty::BrAnon }) => { ty::ReBound(debruijn, ty::BoundRegion { var, kind: ty::BrAnon }) => {
let binder = &self.binders[self.binders.len() - 1 - debruijn.index()]; let binder = &self.binders[self.binders.len() - 1 - debruijn.index()];
let depth = binder.lifetime_depths.start + var.as_u32(); let depth = binder.lifetime_depths.start + var.as_u32();

View file

@ -97,7 +97,7 @@ pub(in crate::solve) fn replace_erased_lifetimes_with_bound_vars<'tcx>(
ty::ReErased => { ty::ReErased => {
let br = ty::BoundRegion { var: ty::BoundVar::from_u32(counter), kind: ty::BrAnon }; let br = ty::BoundRegion { var: ty::BoundVar::from_u32(counter), kind: ty::BrAnon };
counter += 1; counter += 1;
ty::Region::new_late_bound(tcx, current_depth, br) ty::Region::new_bound(tcx, current_depth, br)
} }
// All free regions should be erased here. // All free regions should be erased here.
r => bug!("unexpected region: {r:?}"), r => bug!("unexpected region: {r:?}"),

View file

@ -222,7 +222,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for Canonicalizer<'_, 'tcx> {
} }
let kind = match *r { let kind = match *r {
ty::ReLateBound(..) => return r, ty::ReBound(..) => return r,
// We may encounter `ReStatic` in item signatures or the hidden type // We may encounter `ReStatic` in item signatures or the hidden type
// of an opaque. `ReErased` should only be encountered in the hidden // of an opaque. `ReErased` should only be encountered in the hidden
@ -278,7 +278,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for Canonicalizer<'_, 'tcx> {
var var
}); });
let br = ty::BoundRegion { var, kind: BrAnon }; let br = ty::BoundRegion { var, kind: BrAnon };
ty::Region::new_late_bound(self.interner(), self.binder_index, br) ty::Region::new_bound(self.interner(), self.binder_index, br)
} }
fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> { fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> {

View file

@ -262,7 +262,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
} }
} }
GenericArgKind::Lifetime(r) => { GenericArgKind::Lifetime(r) => {
if let ty::ReLateBound(debruijn, br) = *r { if let ty::ReBound(debruijn, br) = *r {
assert_eq!(debruijn, ty::INNERMOST); assert_eq!(debruijn, ty::INNERMOST);
opt_values[br.var] = Some(*original_value); opt_values[br.var] = Some(*original_value);
} }

View file

@ -410,11 +410,11 @@ impl<'tcx> AutoTraitFinder<'tcx> {
iter::zip(new_args.regions(), old_args.regions()) iter::zip(new_args.regions(), old_args.regions())
{ {
match (*new_region, *old_region) { match (*new_region, *old_region) {
// If both predicates have an `ReLateBound` (a HRTB) in the // If both predicates have an `ReBound` (a HRTB) in the
// same spot, we do nothing. // same spot, we do nothing.
(ty::ReLateBound(_, _), ty::ReLateBound(_, _)) => {} (ty::ReBound(_, _), ty::ReBound(_, _)) => {}
(ty::ReLateBound(_, _), _) | (_, ty::ReVar(_)) => { (ty::ReBound(_, _), _) | (_, ty::ReVar(_)) => {
// One of these is true: // One of these is true:
// The new predicate has a HRTB in a spot where the old // The new predicate has a HRTB in a spot where the old
// predicate does not (if they both had a HRTB, the previous // predicate does not (if they both had a HRTB, the previous
@ -440,7 +440,7 @@ impl<'tcx> AutoTraitFinder<'tcx> {
// `user_computed_preds`. // `user_computed_preds`.
return false; return false;
} }
(_, ty::ReLateBound(_, _)) | (ty::ReVar(_), _) => { (_, ty::ReBound(_, _)) | (ty::ReVar(_), _) => {
// This is the opposite situation as the previous arm. // This is the opposite situation as the previous arm.
// One of these is true: // One of these is true:
// //

View file

@ -740,7 +740,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
} }
// We `erase_late_bound_regions` here because `make_subregion` does not handle // We `erase_late_bound_regions` here because `make_subregion` does not handle
// `ReLateBound`, and we don't particularly care about the regions. // `ReBound`, and we don't particularly care about the regions.
let real_ty = self.tcx.erase_late_bound_regions(real_trait_pred.self_ty()); let real_ty = self.tcx.erase_late_bound_regions(real_trait_pred.self_ty());
if !self.can_eq(obligation.param_env, real_ty, arg_ty) { if !self.can_eq(obligation.param_env, real_ty, arg_ty) {
continue; continue;

View file

@ -894,16 +894,16 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for BoundVarReplacer<'_, 'tcx> {
fn fold_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> { fn fold_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> {
match *r { match *r {
ty::ReLateBound(debruijn, _) ty::ReBound(debruijn, _)
if debruijn.as_usize() + 1 if debruijn.as_usize()
> self.current_index.as_usize() + self.universe_indices.len() => >= self.current_index.as_usize() + self.universe_indices.len() =>
{ {
bug!( bug!(
"Bound vars {r:#?} outside of `self.universe_indices`: {:#?}", "Bound vars {r:#?} outside of `self.universe_indices`: {:#?}",
self.universe_indices self.universe_indices
); );
} }
ty::ReLateBound(debruijn, br) if debruijn >= self.current_index => { ty::ReBound(debruijn, br) if debruijn >= self.current_index => {
let universe = self.universe_for(debruijn); let universe = self.universe_for(debruijn);
let p = ty::PlaceholderRegion { universe, bound: br }; let p = ty::PlaceholderRegion { universe, bound: br };
self.mapped_regions.insert(p, br); self.mapped_regions.insert(p, br);
@ -1034,7 +1034,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for PlaceholderReplacer<'_, 'tcx> {
let db = ty::DebruijnIndex::from_usize( let db = ty::DebruijnIndex::from_usize(
self.universe_indices.len() - index + self.current_index.as_usize() - 1, self.universe_indices.len() - index + self.current_index.as_usize() - 1,
); );
ty::Region::new_late_bound(self.interner(), db, *replace_var) ty::Region::new_bound(self.interner(), db, *replace_var)
} }
None => r1, None => r1,
} }

View file

@ -150,7 +150,7 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for MaxEscapingBoundVarVisitor {
#[inline] #[inline]
fn visit_region(&mut self, r: ty::Region<'tcx>) -> ControlFlow<Self::BreakTy> { fn visit_region(&mut self, r: ty::Region<'tcx>) -> ControlFlow<Self::BreakTy> {
match *r { match *r {
ty::ReLateBound(debruijn, _) if debruijn > self.outer_index => { ty::ReBound(debruijn, _) if debruijn > self.outer_index => {
self.escaping = self.escaping =
self.escaping.max(debruijn.as_usize() - self.outer_index.as_usize()); self.escaping.max(debruijn.as_usize() - self.outer_index.as_usize());
} }

View file

@ -592,7 +592,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
let kind = ty::BoundRegionKind::BrNamed(param.def_id, param.name); let kind = ty::BoundRegionKind::BrNamed(param.def_id, param.name);
let bound_var = ty::BoundVariableKind::Region(kind); let bound_var = ty::BoundVariableKind::Region(kind);
bound_vars.push(bound_var); bound_vars.push(bound_var);
ty::Region::new_late_bound( ty::Region::new_bound(
tcx, tcx,
ty::INNERMOST, ty::INNERMOST,
ty::BoundRegion { ty::BoundRegion {

View file

@ -3103,7 +3103,7 @@ fn bind_coroutine_hidden_types_above<'tcx>(
kind: ty::BrAnon, kind: ty::BrAnon,
}; };
counter += 1; counter += 1;
ty::Region::new_late_bound(tcx, current_depth, br) ty::Region::new_bound(tcx, current_depth, br)
} }
r => bug!("unexpected region: {r:?}"), r => bug!("unexpected region: {r:?}"),
}) })

View file

@ -82,7 +82,7 @@ fn fn_sig_for_fn_abi<'tcx>(
var: ty::BoundVar::from_usize(bound_vars.len() - 1), var: ty::BoundVar::from_usize(bound_vars.len() - 1),
kind: ty::BoundRegionKind::BrEnv, kind: ty::BoundRegionKind::BrEnv,
}; };
let env_region = ty::Region::new_late_bound(tcx, ty::INNERMOST, br); let env_region = ty::Region::new_bound(tcx, ty::INNERMOST, br);
let env_ty = tcx.closure_env_ty(def_id, args, env_region).unwrap(); let env_ty = tcx.closure_env_ty(def_id, args, env_region).unwrap();
let sig = sig.skip_binder(); let sig = sig.skip_binder();
@ -107,8 +107,7 @@ fn fn_sig_for_fn_abi<'tcx>(
var: ty::BoundVar::from_usize(bound_vars.len() - 1), var: ty::BoundVar::from_usize(bound_vars.len() - 1),
kind: ty::BoundRegionKind::BrEnv, kind: ty::BoundRegionKind::BrEnv,
}; };
let env_ty = let env_ty = Ty::new_mut_ref(tcx, ty::Region::new_bound(tcx, ty::INNERMOST, br), ty);
Ty::new_mut_ref(tcx, ty::Region::new_late_bound(tcx, ty::INNERMOST, br), ty);
let pin_did = tcx.require_lang_item(LangItem::Pin, None); let pin_did = tcx.require_lang_item(LangItem::Pin, None);
let pin_adt_ref = tcx.adt_def(pin_did); let pin_adt_ref = tcx.adt_def(pin_did);

View file

@ -195,7 +195,7 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for ImplTraitInTraitFinder<'_, 'tcx> {
// bounds of the RPITIT. Shift these binders back out when // bounds of the RPITIT. Shift these binders back out when
// constructing the top-level projection predicate. // constructing the top-level projection predicate.
let shifted_alias_ty = self.tcx.fold_regions(unshifted_alias_ty, |re, depth| { let shifted_alias_ty = self.tcx.fold_regions(unshifted_alias_ty, |re, depth| {
if let ty::ReLateBound(index, bv) = re.kind() { if let ty::ReBound(index, bv) = re.kind() {
if depth != ty::INNERMOST { if depth != ty::INNERMOST {
return ty::Region::new_error_with_message( return ty::Region::new_error_with_message(
self.tcx, self.tcx,
@ -203,7 +203,7 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for ImplTraitInTraitFinder<'_, 'tcx> {
"we shouldn't walk non-predicate binders with `impl Trait`...", "we shouldn't walk non-predicate binders with `impl Trait`...",
); );
} }
ty::Region::new_late_bound( ty::Region::new_bound(
self.tcx, self.tcx,
index.shifted_out_to_binder(self.depth), index.shifted_out_to_binder(self.depth),
bv, bv,

View file

@ -85,10 +85,10 @@ bitflags! {
const HAS_ERROR = 1 << 14; const HAS_ERROR = 1 << 14;
/// Does this have any region that "appears free" in the type? /// Does this have any region that "appears free" in the type?
/// Basically anything but `ReLateBound` and `ReErased`. /// Basically anything but `ReBound` and `ReErased`.
const HAS_FREE_REGIONS = 1 << 15; const HAS_FREE_REGIONS = 1 << 15;
/// Does this have any `ReLateBound` regions? /// Does this have any `ReBound` regions?
const HAS_RE_LATE_BOUND = 1 << 16; const HAS_RE_LATE_BOUND = 1 << 16;
/// Does this have any `Bound` types? /// Does this have any `Bound` types?
const HAS_TY_LATE_BOUND = 1 << 17; const HAS_TY_LATE_BOUND = 1 << 17;

View file

@ -128,9 +128,16 @@ pub enum RegionKind<I: Interner> {
/// parameters are substituted. /// parameters are substituted.
ReEarlyBound(I::EarlyBoundRegion), ReEarlyBound(I::EarlyBoundRegion),
/// Region bound in a function scope, which will be substituted when the /// A higher-ranked region. These represent either late-bound function parameters
/// function is called. /// or bound variables from a `for<'a>`-binder.
ReLateBound(DebruijnIndex, I::BoundRegion), ///
/// While inside of a function, e.g. during typeck, the late-bound function parameters
/// can be converted to `ReFree` by calling `tcx.liberate_late_bound_regions`.
///
/// Bound regions inside of types **must not** be erased, as they impact trait
/// selection and the `TypeId` of that type. `for<'a> fn(&'a ())` and
/// `fn(&'static ())` are different types and have to be treated as such.
ReBound(DebruijnIndex, I::BoundRegion),
/// When checking a function body, the types of all arguments and so forth /// When checking a function body, the types of all arguments and so forth
/// that refer to bound region parameters are modified to refer to free /// that refer to bound region parameters are modified to refer to free
@ -160,7 +167,7 @@ pub enum RegionKind<I: Interner> {
const fn regionkind_discriminant<I: Interner>(value: &RegionKind<I>) -> usize { const fn regionkind_discriminant<I: Interner>(value: &RegionKind<I>) -> usize {
match value { match value {
ReEarlyBound(_) => 0, ReEarlyBound(_) => 0,
ReLateBound(_, _) => 1, ReBound(_, _) => 1,
ReFree(_) => 2, ReFree(_) => 2,
ReStatic => 3, ReStatic => 3,
ReVar(_) => 4, ReVar(_) => 4,
@ -189,7 +196,7 @@ impl<I: Interner> PartialEq for RegionKind<I> {
regionkind_discriminant(self) == regionkind_discriminant(other) regionkind_discriminant(self) == regionkind_discriminant(other)
&& match (self, other) { && match (self, other) {
(ReEarlyBound(a_r), ReEarlyBound(b_r)) => a_r == b_r, (ReEarlyBound(a_r), ReEarlyBound(b_r)) => a_r == b_r,
(ReLateBound(a_d, a_r), ReLateBound(b_d, b_r)) => a_d == b_d && a_r == b_r, (ReBound(a_d, a_r), ReBound(b_d, b_r)) => a_d == b_d && a_r == b_r,
(ReFree(a_r), ReFree(b_r)) => a_r == b_r, (ReFree(a_r), ReFree(b_r)) => a_r == b_r,
(ReStatic, ReStatic) => true, (ReStatic, ReStatic) => true,
(ReVar(a_r), ReVar(b_r)) => a_r == b_r, (ReVar(a_r), ReVar(b_r)) => a_r == b_r,
@ -218,8 +225,8 @@ impl<I: Interner> DebugWithInfcx<I> for RegionKind<I> {
match this.data { match this.data {
ReEarlyBound(data) => write!(f, "ReEarlyBound({data:?})"), ReEarlyBound(data) => write!(f, "ReEarlyBound({data:?})"),
ReLateBound(binder_id, bound_region) => { ReBound(binder_id, bound_region) => {
write!(f, "ReLateBound({binder_id:?}, {bound_region:?})") write!(f, "ReBound({binder_id:?}, {bound_region:?})")
} }
ReFree(fr) => write!(f, "{fr:?}"), ReFree(fr) => write!(f, "{fr:?}"),
@ -258,7 +265,7 @@ where
ReErased | ReStatic | ReError(_) => { ReErased | ReStatic | ReError(_) => {
// No variant fields to hash for these ... // No variant fields to hash for these ...
} }
ReLateBound(d, r) => { ReBound(d, r) => {
d.hash_stable(hcx, hasher); d.hash_stable(hcx, hasher);
r.hash_stable(hcx, hasher); r.hash_stable(hcx, hasher);
} }

View file

@ -62,7 +62,7 @@ pub struct Region {
#[derive(Clone, Debug, Eq, PartialEq)] #[derive(Clone, Debug, Eq, PartialEq)]
pub enum RegionKind { pub enum RegionKind {
ReEarlyBound(EarlyBoundRegion), ReEarlyBound(EarlyBoundRegion),
ReLateBound(DebruijnIndex, BoundRegion), ReBound(DebruijnIndex, BoundRegion),
ReStatic, ReStatic,
RePlaceholder(Placeholder<BoundRegion>), RePlaceholder(Placeholder<BoundRegion>),
ReErased, ReErased,

View file

@ -743,7 +743,7 @@ impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for RegionReplacer<'a, 'tcx> {
match *r { match *r {
// These are the regions that can be seen in the AST. // 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::ReVar(vid) => self.vid_to_region.get(&vid).cloned().unwrap_or(r),
ty::ReEarlyBound(_) | ty::ReStatic | ty::ReLateBound(..) | ty::ReError(_) => r, ty::ReEarlyBound(_) | ty::ReStatic | ty::ReBound(..) | ty::ReError(_) => r,
r => bug!("unexpected region: {r:?}"), r => bug!("unexpected region: {r:?}"),
} }
} }

View file

@ -286,11 +286,9 @@ pub(crate) fn clean_middle_region<'tcx>(region: ty::Region<'tcx>) -> Option<Life
match *region { match *region {
ty::ReStatic => Some(Lifetime::statik()), ty::ReStatic => Some(Lifetime::statik()),
_ if !region.has_name() => None, _ if !region.has_name() => None,
ty::ReLateBound(_, ty::BoundRegion { kind: ty::BrNamed(_, name), .. }) => { ty::ReBound(_, ty::BoundRegion { kind: ty::BrNamed(_, name), .. }) => Some(Lifetime(name)),
Some(Lifetime(name))
}
ty::ReEarlyBound(ref data) => Some(Lifetime(data.name)), ty::ReEarlyBound(ref data) => Some(Lifetime(data.name)),
ty::ReLateBound(..) ty::ReBound(..)
| ty::ReFree(..) | ty::ReFree(..)
| ty::ReVar(..) | ty::ReVar(..)
| ty::ReError(_) | ty::ReError(_)
@ -1931,13 +1929,11 @@ fn clean_trait_object_lifetime_bound<'tcx>(
match *region { match *region {
ty::ReStatic => Some(Lifetime::statik()), ty::ReStatic => Some(Lifetime::statik()),
ty::ReEarlyBound(region) if region.name != kw::Empty => Some(Lifetime(region.name)), ty::ReEarlyBound(region) if region.name != kw::Empty => Some(Lifetime(region.name)),
ty::ReLateBound(_, ty::BoundRegion { kind: ty::BrNamed(_, name), .. }) ty::ReBound(_, ty::BoundRegion { kind: ty::BrNamed(_, name), .. }) if name != kw::Empty => {
if name != kw::Empty =>
{
Some(Lifetime(name)) Some(Lifetime(name))
} }
ty::ReEarlyBound(_) ty::ReEarlyBound(_)
| ty::ReLateBound(..) | ty::ReBound(..)
| ty::ReFree(_) | ty::ReFree(_)
| ty::ReVar(_) | ty::ReVar(_)
| ty::RePlaceholder(_) | ty::RePlaceholder(_)

View file

@ -247,8 +247,8 @@ fn check_sig<'tcx>(cx: &LateContext<'tcx>, closure: ClosureArgs<'tcx>, call_sig:
/// This is needed because rustc is unable to late bind early-bound regions in a function signature. /// This is needed because rustc is unable to late bind early-bound regions in a function signature.
fn has_late_bound_to_non_late_bound_regions(from_sig: FnSig<'_>, to_sig: FnSig<'_>) -> bool { fn has_late_bound_to_non_late_bound_regions(from_sig: FnSig<'_>, to_sig: FnSig<'_>) -> bool {
fn check_region(from_region: Region<'_>, to_region: Region<'_>) -> bool { fn check_region(from_region: Region<'_>, to_region: Region<'_>) -> bool {
matches!(from_region.kind(), RegionKind::ReLateBound(..)) matches!(from_region.kind(), RegionKind::ReBound(..))
&& !matches!(to_region.kind(), RegionKind::ReLateBound(..)) && !matches!(to_region.kind(), RegionKind::ReBound(..))
} }
fn check_subs(from_subs: &[GenericArg<'_>], to_subs: &[GenericArg<'_>]) -> bool { fn check_subs(from_subs: &[GenericArg<'_>], to_subs: &[GenericArg<'_>]) -> bool {

View file

@ -168,7 +168,7 @@ impl<'tcx> PassByRefOrValue {
match *ty.skip_binder().kind() { match *ty.skip_binder().kind() {
ty::Ref(lt, ty, Mutability::Not) => { ty::Ref(lt, ty, Mutability::Not) => {
match lt.kind() { match lt.kind() {
RegionKind::ReLateBound(index, region) RegionKind::ReBound(index, region)
if index.as_u32() == 0 && output_regions.contains(&region) => if index.as_u32() == 0 && output_regions.contains(&region) =>
{ {
continue; continue;

View file

@ -466,7 +466,7 @@ fn check_fn_args<'cx, 'tcx: 'cx>(
.filter_map(|arg| { .filter_map(|arg| {
arg.as_region().and_then(|lifetime| match lifetime.kind() { arg.as_region().and_then(|lifetime| match lifetime.kind() {
ty::ReEarlyBound(r) => Some(r.def_id), ty::ReEarlyBound(r) => Some(r.def_id),
ty::ReLateBound(_, r) => r.kind.get_id(), ty::ReBound(_, r) => r.kind.get_id(),
ty::ReFree(r) => r.bound_region.get_id(), ty::ReFree(r) => r.bound_region.get_id(),
ty::ReStatic ty::ReStatic
| ty::ReVar(_) | ty::ReVar(_)

View file

@ -890,7 +890,7 @@ pub fn for_each_top_level_late_bound_region<B>(
impl<'tcx, B, F: FnMut(BoundRegion) -> ControlFlow<B>> TypeVisitor<TyCtxt<'tcx>> for V<F> { impl<'tcx, B, F: FnMut(BoundRegion) -> ControlFlow<B>> TypeVisitor<TyCtxt<'tcx>> for V<F> {
type BreakTy = B; type BreakTy = B;
fn visit_region(&mut self, r: Region<'tcx>) -> ControlFlow<Self::BreakTy> { fn visit_region(&mut self, r: Region<'tcx>) -> ControlFlow<Self::BreakTy> {
if let RegionKind::ReLateBound(idx, bound) = r.kind() if let RegionKind::ReBound(idx, bound) = r.kind()
&& idx.as_u32() == self.index && idx.as_u32() == self.index
{ {
(self.f)(bound) (self.f)(bound)

View file

@ -1,5 +1,5 @@
// This issue reproduces an ICE on compile (E.g. fails on 2018-12-19 nightly). // This issue reproduces an ICE on compile (E.g. fails on 2018-12-19 nightly).
// "cannot relate bound region: ReLateBound(DebruijnIndex(1), BrAnon(1)) <= '?1" // "cannot relate bound region: ReBound(DebruijnIndex(1), BrAnon(1)) <= '?1"
// run-pass // run-pass
// edition:2018 // edition:2018
#![feature(coroutines,coroutine_trait)] #![feature(coroutines,coroutine_trait)]

View file

@ -6,7 +6,7 @@ LL | let mut closure = expect_sig(|p, y| *p = y);
| |
= note: defining type: test::{closure#0} with closure args [ = note: defining type: test::{closure#0} with closure args [
i16, i16,
for<Region(BrAnon), Region(BrAnon), Region(BrAnon)> extern "rust-call" fn((&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon }) mut &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon }) i32, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 2, kind: BrAnon }) i32)), for<Region(BrAnon), Region(BrAnon), Region(BrAnon)> extern "rust-call" fn((&ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon }) mut &ReBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon }) i32, &ReBound(DebruijnIndex(0), BoundRegion { var: 2, kind: BrAnon }) i32)),
(), (),
] ]

View file

@ -6,7 +6,7 @@ LL | let mut closure = expect_sig(|p, y| *p = y);
| |
= note: defining type: test::{closure#0} with closure args [ = note: defining type: test::{closure#0} with closure args [
i16, i16,
for<Region(BrAnon), Region(BrAnon)> extern "rust-call" fn((&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon }) mut &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon }) i32, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon }) i32)), for<Region(BrAnon), Region(BrAnon)> extern "rust-call" fn((&ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon }) mut &ReBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon }) i32, &ReBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon }) i32)),
(), (),
] ]

View file

@ -6,7 +6,7 @@ LL | |_outlives1, _outlives2, _outlives3, x, y| {
| |
= note: defining type: supply::{closure#0} with closure args [ = note: defining type: supply::{closure#0} with closure args [
i16, i16,
for<Region(BrAnon), Region(BrAnon)> extern "rust-call" fn((std::cell::Cell<&'?1 &ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon }) u32>, std::cell::Cell<&'?2 &ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon }) u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon }) &'?3 u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon }) u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon }) u32>)), for<Region(BrAnon), Region(BrAnon)> extern "rust-call" fn((std::cell::Cell<&'?1 &ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon }) u32>, std::cell::Cell<&'?2 &ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon }) u32>, std::cell::Cell<&ReBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon }) &'?3 u32>, std::cell::Cell<&ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon }) u32>, std::cell::Cell<&ReBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon }) u32>)),
(), (),
] ]
= note: late-bound region is '?4 = note: late-bound region is '?4

View file

@ -6,7 +6,7 @@ LL | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y
| |
= note: defining type: supply::{closure#0} with closure args [ = note: defining type: supply::{closure#0} with closure args [
i16, i16,
for<Region(BrAnon), Region(BrAnon), Region(BrAnon), Region(BrAnon), Region(BrAnon), Region(BrAnon)> extern "rust-call" fn((&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon }) std::cell::Cell<&'?1 &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 2, kind: BrAnon }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrAnon }) &'?2 u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 4, kind: BrAnon }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 5, kind: BrAnon }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrAnon }) u32>)), for<Region(BrAnon), Region(BrAnon), Region(BrAnon), Region(BrAnon), Region(BrAnon), Region(BrAnon)> extern "rust-call" fn((&ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon }) std::cell::Cell<&'?1 &ReBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon }) u32>, &ReBound(DebruijnIndex(0), BoundRegion { var: 2, kind: BrAnon }) std::cell::Cell<&ReBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrAnon }) &'?2 u32>, &ReBound(DebruijnIndex(0), BoundRegion { var: 4, kind: BrAnon }) std::cell::Cell<&ReBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon }) u32>, &ReBound(DebruijnIndex(0), BoundRegion { var: 5, kind: BrAnon }) std::cell::Cell<&ReBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrAnon }) u32>)),
(), (),
] ]
= note: late-bound region is '?3 = note: late-bound region is '?3

View file

@ -6,7 +6,7 @@ LL | foo(cell, |cell_a, cell_x| {
| |
= note: defining type: case1::{closure#0} with closure args [ = note: defining type: case1::{closure#0} with closure args [
i32, i32,
for<Region(BrAnon)> extern "rust-call" fn((std::cell::Cell<&'?1 u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon }) u32>)), for<Region(BrAnon)> extern "rust-call" fn((std::cell::Cell<&'?1 u32>, std::cell::Cell<&ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon }) u32>)),
(), (),
] ]
@ -36,7 +36,7 @@ LL | foo(cell, |cell_a, cell_x| {
| |
= note: defining type: case2::{closure#0} with closure args [ = note: defining type: case2::{closure#0} with closure args [
i32, i32,
for<Region(BrAnon)> extern "rust-call" fn((std::cell::Cell<&'?1 u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon }) u32>)), for<Region(BrAnon)> extern "rust-call" fn((std::cell::Cell<&'?1 u32>, std::cell::Cell<&ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon }) u32>)),
(), (),
] ]
= note: number of external vids: 2 = note: number of external vids: 2

View file

@ -6,7 +6,7 @@ LL | establish_relationships(&cell_a, &cell_b, |_outlives, x, y| {
| |
= note: defining type: supply::{closure#0} with closure args [ = note: defining type: supply::{closure#0} with closure args [
i16, i16,
for<Region(BrAnon), Region(BrAnon), Region(BrAnon), Region(BrAnon), Region(BrAnon)> extern "rust-call" fn((&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon }) std::cell::Cell<&'?1 &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 2, kind: BrAnon }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrAnon }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 4, kind: BrAnon }) u32>)), for<Region(BrAnon), Region(BrAnon), Region(BrAnon), Region(BrAnon), Region(BrAnon)> extern "rust-call" fn((&ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon }) std::cell::Cell<&'?1 &ReBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon }) u32>, &ReBound(DebruijnIndex(0), BoundRegion { var: 2, kind: BrAnon }) std::cell::Cell<&ReBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon }) u32>, &ReBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrAnon }) std::cell::Cell<&ReBound(DebruijnIndex(0), BoundRegion { var: 4, kind: BrAnon }) u32>)),
(), (),
] ]
= note: late-bound region is '?2 = note: late-bound region is '?2

View file

@ -6,7 +6,7 @@ LL | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y
| |
= note: defining type: supply::{closure#0} with closure args [ = note: defining type: supply::{closure#0} with closure args [
i16, i16,
for<Region(BrAnon), Region(BrAnon), Region(BrAnon), Region(BrAnon), Region(BrAnon), Region(BrAnon)> extern "rust-call" fn((&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon }) std::cell::Cell<&'?1 &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 2, kind: BrAnon }) std::cell::Cell<&'?2 &ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrAnon }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 4, kind: BrAnon }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 5, kind: BrAnon }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrAnon }) u32>)), for<Region(BrAnon), Region(BrAnon), Region(BrAnon), Region(BrAnon), Region(BrAnon), Region(BrAnon)> extern "rust-call" fn((&ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon }) std::cell::Cell<&'?1 &ReBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon }) u32>, &ReBound(DebruijnIndex(0), BoundRegion { var: 2, kind: BrAnon }) std::cell::Cell<&'?2 &ReBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrAnon }) u32>, &ReBound(DebruijnIndex(0), BoundRegion { var: 4, kind: BrAnon }) std::cell::Cell<&ReBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon }) u32>, &ReBound(DebruijnIndex(0), BoundRegion { var: 5, kind: BrAnon }) std::cell::Cell<&ReBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrAnon }) u32>)),
(), (),
] ]
= note: late-bound region is '?3 = note: late-bound region is '?3

View file

@ -6,7 +6,7 @@ LL | establish_relationships(cell_a, cell_b, |outlives1, outlives2, x, y| {
| |
= note: defining type: test::{closure#0} with closure args [ = note: defining type: test::{closure#0} with closure args [
i16, i16,
for<Region(BrAnon), Region(BrAnon)> extern "rust-call" fn((std::cell::Cell<&'?1 &ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon }) u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon }) &'?2 u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon }) u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon }) u32>)), for<Region(BrAnon), Region(BrAnon)> extern "rust-call" fn((std::cell::Cell<&'?1 &ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon }) u32>, std::cell::Cell<&ReBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon }) &'?2 u32>, std::cell::Cell<&ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon }) u32>, std::cell::Cell<&ReBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon }) u32>)),
(), (),
] ]
= note: late-bound region is '?3 = note: late-bound region is '?3

View file

@ -6,7 +6,7 @@ LL | |_outlives1, _outlives2, x, y| {
| |
= note: defining type: supply::{closure#0} with closure args [ = note: defining type: supply::{closure#0} with closure args [
i16, i16,
for<Region(BrAnon), Region(BrAnon)> extern "rust-call" fn((std::cell::Cell<&'?1 &ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon }) u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon }) &'?2 u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon }) u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon }) u32>)), for<Region(BrAnon), Region(BrAnon)> extern "rust-call" fn((std::cell::Cell<&'?1 &ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon }) u32>, std::cell::Cell<&ReBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon }) &'?2 u32>, std::cell::Cell<&ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon }) u32>, std::cell::Cell<&ReBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon }) u32>)),
(), (),
] ]
= note: late-bound region is '?3 = note: late-bound region is '?3

View file

@ -6,7 +6,7 @@ LL | establish_relationships(&cell_a, &cell_b, |_outlives, x, y| {
| |
= note: defining type: supply::{closure#0} with closure args [ = note: defining type: supply::{closure#0} with closure args [
i16, i16,
for<Region(BrAnon), Region(BrAnon), Region(BrAnon), Region(BrAnon), Region(BrAnon)> extern "rust-call" fn((&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon }) &'?1 u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 2, kind: BrAnon }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrAnon }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 4, kind: BrAnon }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon }) u32>)), for<Region(BrAnon), Region(BrAnon), Region(BrAnon), Region(BrAnon), Region(BrAnon)> extern "rust-call" fn((&ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon }) std::cell::Cell<&ReBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon }) &'?1 u32>, &ReBound(DebruijnIndex(0), BoundRegion { var: 2, kind: BrAnon }) std::cell::Cell<&ReBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrAnon }) u32>, &ReBound(DebruijnIndex(0), BoundRegion { var: 4, kind: BrAnon }) std::cell::Cell<&ReBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon }) u32>)),
(), (),
] ]
= note: late-bound region is '?2 = note: late-bound region is '?2

View file

@ -6,7 +6,7 @@ LL | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y
| |
= note: defining type: supply::{closure#0} with closure args [ = note: defining type: supply::{closure#0} with closure args [
i16, i16,
for<Region(BrAnon), Region(BrAnon), Region(BrAnon), Region(BrAnon), Region(BrAnon), Region(BrAnon)> extern "rust-call" fn((&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon }) &'?1 u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 2, kind: BrAnon }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrAnon }) &'?2 u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 4, kind: BrAnon }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 5, kind: BrAnon }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrAnon }) u32>)), for<Region(BrAnon), Region(BrAnon), Region(BrAnon), Region(BrAnon), Region(BrAnon), Region(BrAnon)> extern "rust-call" fn((&ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon }) std::cell::Cell<&ReBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon }) &'?1 u32>, &ReBound(DebruijnIndex(0), BoundRegion { var: 2, kind: BrAnon }) std::cell::Cell<&ReBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrAnon }) &'?2 u32>, &ReBound(DebruijnIndex(0), BoundRegion { var: 4, kind: BrAnon }) std::cell::Cell<&ReBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon }) u32>, &ReBound(DebruijnIndex(0), BoundRegion { var: 5, kind: BrAnon }) std::cell::Cell<&ReBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrAnon }) u32>)),
(), (),
] ]
= note: late-bound region is '?3 = note: late-bound region is '?3

View file

@ -6,7 +6,7 @@ LL | expect_sig(|a, b| b); // ought to return `a`
| |
= note: defining type: test::{closure#0} with closure args [ = note: defining type: test::{closure#0} with closure args [
i16, i16,
for<Region(BrAnon), Region(BrAnon)> extern "rust-call" fn((&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon }) i32, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon }) i32)) -> &ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon }) i32, for<Region(BrAnon), Region(BrAnon)> extern "rust-call" fn((&ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon }) i32, &ReBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon }) i32)) -> &ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon }) i32,
(), (),
] ]

View file

@ -6,7 +6,7 @@ LL | twice(cell, value, |a, b| invoke(a, b));
| |
= note: defining type: generic::<T>::{closure#0} with closure args [ = note: defining type: generic::<T>::{closure#0} with closure args [
i16, i16,
for<Region(BrAnon), Region(BrAnon)> extern "rust-call" fn((std::option::Option<std::cell::Cell<&'?1 &ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon }) ()>>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon }) T)), for<Region(BrAnon), Region(BrAnon)> extern "rust-call" fn((std::option::Option<std::cell::Cell<&'?1 &ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon }) ()>>, &ReBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon }) T)),
(), (),
] ]
= note: number of external vids: 2 = note: number of external vids: 2
@ -28,7 +28,7 @@ LL | twice(cell, value, |a, b| invoke(a, b));
| |
= note: defining type: generic_fail::<T>::{closure#0} with closure args [ = note: defining type: generic_fail::<T>::{closure#0} with closure args [
i16, i16,
for<Region(BrAnon), Region(BrAnon)> extern "rust-call" fn((std::option::Option<std::cell::Cell<&'?1 &ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon }) ()>>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon }) T)), for<Region(BrAnon), Region(BrAnon)> extern "rust-call" fn((std::option::Option<std::cell::Cell<&'?1 &ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon }) ()>>, &ReBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon }) T)),
(), (),
] ]
= note: late-bound region is '?2 = note: late-bound region is '?2

View file

@ -1,8 +1,8 @@
error[E0277]: the trait bound `for<Region(BrNamed(DefId(0:6 ~ higher_ranked_fn_type[9e51]::called::'b), 'b))> fn(&ReLateBound(DebruijnIndex(1), BoundRegion { var: 0, kind: BrNamed(DefId(0:6 ~ higher_ranked_fn_type[9e51]::called::'b), 'b) }) ()): Foo` is not satisfied error[E0277]: the trait bound `for<Region(BrNamed(DefId(0:6 ~ higher_ranked_fn_type[9e51]::called::'b), 'b))> fn(&ReBound(DebruijnIndex(1), BoundRegion { var: 0, kind: BrNamed(DefId(0:6 ~ higher_ranked_fn_type[9e51]::called::'b), 'b) }) ()): Foo` is not satisfied
--> $DIR/higher-ranked-fn-type.rs:20:5 --> $DIR/higher-ranked-fn-type.rs:20:5
| |
LL | called() LL | called()
| ^^^^^^ the trait `for<Region(BrNamed(DefId(0:6 ~ higher_ranked_fn_type[9e51]::called::'b), 'b))> Foo` is not implemented for `fn(&ReLateBound(DebruijnIndex(1), BoundRegion { var: 0, kind: BrNamed(DefId(0:6 ~ higher_ranked_fn_type[9e51]::called::'b), 'b) }) ())` | ^^^^^^ the trait `for<Region(BrNamed(DefId(0:6 ~ higher_ranked_fn_type[9e51]::called::'b), 'b))> Foo` is not implemented for `fn(&ReBound(DebruijnIndex(1), BoundRegion { var: 0, kind: BrNamed(DefId(0:6 ~ higher_ranked_fn_type[9e51]::called::'b), 'b) }) ())`
| |
help: this trait has no implementations, consider adding one help: this trait has no implementations, consider adding one
--> $DIR/higher-ranked-fn-type.rs:6:1 --> $DIR/higher-ranked-fn-type.rs:6:1