mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 14:55:26 +00:00
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:
commit
1500db7314
@ -50,8 +50,8 @@ impl OutlivesSuggestionBuilder {
|
|||||||
// naming the `'self` lifetime in methods, etc.
|
// naming the `'self` lifetime in methods, etc.
|
||||||
fn region_name_is_suggestable(name: &RegionName) -> bool {
|
fn region_name_is_suggestable(name: &RegionName) -> bool {
|
||||||
match name.source {
|
match name.source {
|
||||||
RegionNameSource::NamedEarlyBoundRegion(..)
|
RegionNameSource::NamedEarlyParamRegion(..)
|
||||||
| RegionNameSource::NamedFreeRegion(..)
|
| RegionNameSource::NamedLateParamRegion(..)
|
||||||
| RegionNameSource::Static => true,
|
| RegionNameSource::Static => true,
|
||||||
|
|
||||||
// Don't give suggestions for upvars, closure return types, or other unnameable
|
// Don't give suggestions for upvars, closure return types, or other unnameable
|
||||||
|
@ -181,8 +181,8 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
|||||||
|
|
||||||
/// Returns `true` if a closure is inferred to be an `FnMut` closure.
|
/// Returns `true` if a closure is inferred to be an `FnMut` closure.
|
||||||
fn is_closure_fn_mut(&self, fr: RegionVid) -> bool {
|
fn is_closure_fn_mut(&self, fr: RegionVid) -> bool {
|
||||||
if let Some(ty::ReFree(free_region)) = self.to_error_region(fr).as_deref()
|
if let Some(ty::ReLateParam(late_param)) = self.to_error_region(fr).as_deref()
|
||||||
&& let ty::BoundRegionKind::BrEnv = free_region.bound_region
|
&& let ty::BoundRegionKind::BrEnv = late_param.bound_region
|
||||||
&& let DefiningTy::Closure(_, args) = self.regioncx.universal_regions().defining_ty
|
&& let DefiningTy::Closure(_, args) = self.regioncx.universal_regions().defining_ty
|
||||||
{
|
{
|
||||||
return args.as_closure().kind() == ty::ClosureKind::FnMut;
|
return args.as_closure().kind() == ty::ClosureKind::FnMut;
|
||||||
@ -995,7 +995,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
|||||||
.infcx
|
.infcx
|
||||||
.tcx
|
.tcx
|
||||||
.is_suitable_region(sub)
|
.is_suitable_region(sub)
|
||||||
.and_then(|anon_reg| find_anon_type(self.infcx.tcx, sub, &anon_reg.boundregion))
|
.and_then(|anon_reg| find_anon_type(self.infcx.tcx, sub, &anon_reg.bound_region))
|
||||||
else {
|
else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
@ -1004,7 +1004,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
|||||||
.infcx
|
.infcx
|
||||||
.tcx
|
.tcx
|
||||||
.is_suitable_region(sup)
|
.is_suitable_region(sup)
|
||||||
.and_then(|anon_reg| find_anon_type(self.infcx.tcx, sup, &anon_reg.boundregion))
|
.and_then(|anon_reg| find_anon_type(self.infcx.tcx, sup, &anon_reg.bound_region))
|
||||||
else {
|
else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
@ -23,14 +23,14 @@ pub(crate) struct RegionName {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Denotes the source of a region that is named by a `RegionName`. For example, a free region that
|
/// Denotes the source of a region that is named by a `RegionName`. For example, a free region that
|
||||||
/// was named by the user would get `NamedFreeRegion` and `'static` lifetime would get `Static`.
|
/// was named by the user would get `NamedLateParamRegion` and `'static` lifetime would get `Static`.
|
||||||
/// This helps to print the right kinds of diagnostics.
|
/// This helps to print the right kinds of diagnostics.
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub(crate) enum RegionNameSource {
|
pub(crate) enum RegionNameSource {
|
||||||
/// A bound (not free) region that was instantiated at the def site (not an HRTB).
|
/// A bound (not free) region that was instantiated at the def site (not an HRTB).
|
||||||
NamedEarlyBoundRegion(Span),
|
NamedEarlyParamRegion(Span),
|
||||||
/// A free region that the user has a name (`'a`) for.
|
/// A free region that the user has a name (`'a`) for.
|
||||||
NamedFreeRegion(Span),
|
NamedLateParamRegion(Span),
|
||||||
/// The `'static` region.
|
/// The `'static` region.
|
||||||
Static,
|
Static,
|
||||||
/// The free region corresponding to the environment of a closure.
|
/// The free region corresponding to the environment of a closure.
|
||||||
@ -69,8 +69,8 @@ pub(crate) enum RegionNameHighlight {
|
|||||||
impl RegionName {
|
impl RegionName {
|
||||||
pub(crate) fn was_named(&self) -> bool {
|
pub(crate) fn was_named(&self) -> bool {
|
||||||
match self.source {
|
match self.source {
|
||||||
RegionNameSource::NamedEarlyBoundRegion(..)
|
RegionNameSource::NamedEarlyParamRegion(..)
|
||||||
| RegionNameSource::NamedFreeRegion(..)
|
| RegionNameSource::NamedLateParamRegion(..)
|
||||||
| RegionNameSource::Static => true,
|
| RegionNameSource::Static => true,
|
||||||
RegionNameSource::SynthesizedFreeEnvRegion(..)
|
RegionNameSource::SynthesizedFreeEnvRegion(..)
|
||||||
| RegionNameSource::AnonRegionFromArgument(..)
|
| RegionNameSource::AnonRegionFromArgument(..)
|
||||||
@ -85,8 +85,8 @@ impl RegionName {
|
|||||||
pub(crate) fn span(&self) -> Option<Span> {
|
pub(crate) fn span(&self) -> Option<Span> {
|
||||||
match self.source {
|
match self.source {
|
||||||
RegionNameSource::Static => None,
|
RegionNameSource::Static => None,
|
||||||
RegionNameSource::NamedEarlyBoundRegion(span)
|
RegionNameSource::NamedEarlyParamRegion(span)
|
||||||
| RegionNameSource::NamedFreeRegion(span)
|
| RegionNameSource::NamedLateParamRegion(span)
|
||||||
| RegionNameSource::SynthesizedFreeEnvRegion(span, _)
|
| RegionNameSource::SynthesizedFreeEnvRegion(span, _)
|
||||||
| RegionNameSource::AnonRegionFromUpvar(span, _)
|
| RegionNameSource::AnonRegionFromUpvar(span, _)
|
||||||
| RegionNameSource::AnonRegionFromYieldTy(span, _)
|
| RegionNameSource::AnonRegionFromYieldTy(span, _)
|
||||||
@ -104,8 +104,8 @@ impl RegionName {
|
|||||||
|
|
||||||
pub(crate) fn highlight_region_name(&self, diag: &mut Diagnostic) {
|
pub(crate) fn highlight_region_name(&self, diag: &mut Diagnostic) {
|
||||||
match &self.source {
|
match &self.source {
|
||||||
RegionNameSource::NamedFreeRegion(span)
|
RegionNameSource::NamedLateParamRegion(span)
|
||||||
| RegionNameSource::NamedEarlyBoundRegion(span) => {
|
| RegionNameSource::NamedEarlyParamRegion(span) => {
|
||||||
diag.span_label(*span, format!("lifetime `{self}` defined here"));
|
diag.span_label(*span, format!("lifetime `{self}` defined here"));
|
||||||
}
|
}
|
||||||
RegionNameSource::SynthesizedFreeEnvRegion(span, note) => {
|
RegionNameSource::SynthesizedFreeEnvRegion(span, note) => {
|
||||||
@ -280,28 +280,31 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
|
|||||||
|
|
||||||
debug!("give_region_a_name: error_region = {:?}", error_region);
|
debug!("give_region_a_name: error_region = {:?}", error_region);
|
||||||
match *error_region {
|
match *error_region {
|
||||||
ty::ReEarlyBound(ebr) => ebr.has_name().then(|| {
|
ty::ReEarlyParam(ebr) => ebr.has_name().then(|| {
|
||||||
let span = tcx.hir().span_if_local(ebr.def_id).unwrap_or(DUMMY_SP);
|
let span = tcx.hir().span_if_local(ebr.def_id).unwrap_or(DUMMY_SP);
|
||||||
RegionName { name: ebr.name, source: RegionNameSource::NamedEarlyBoundRegion(span) }
|
RegionName { name: ebr.name, source: RegionNameSource::NamedEarlyParamRegion(span) }
|
||||||
}),
|
}),
|
||||||
|
|
||||||
ty::ReStatic => {
|
ty::ReStatic => {
|
||||||
Some(RegionName { name: kw::StaticLifetime, source: RegionNameSource::Static })
|
Some(RegionName { name: kw::StaticLifetime, source: RegionNameSource::Static })
|
||||||
}
|
}
|
||||||
|
|
||||||
ty::ReFree(free_region) => match free_region.bound_region {
|
ty::ReLateParam(late_param) => match late_param.bound_region {
|
||||||
ty::BoundRegionKind::BrNamed(region_def_id, name) => {
|
ty::BoundRegionKind::BrNamed(region_def_id, name) => {
|
||||||
// Get the span to point to, even if we don't use the name.
|
// Get the span to point to, even if we don't use the name.
|
||||||
let span = tcx.hir().span_if_local(region_def_id).unwrap_or(DUMMY_SP);
|
let span = tcx.hir().span_if_local(region_def_id).unwrap_or(DUMMY_SP);
|
||||||
debug!(
|
debug!(
|
||||||
"bound region named: {:?}, is_named: {:?}",
|
"bound region named: {:?}, is_named: {:?}",
|
||||||
name,
|
name,
|
||||||
free_region.bound_region.is_named()
|
late_param.bound_region.is_named()
|
||||||
);
|
);
|
||||||
|
|
||||||
if free_region.bound_region.is_named() {
|
if late_param.bound_region.is_named() {
|
||||||
// A named region that is actually named.
|
// A named region that is actually named.
|
||||||
Some(RegionName { name, source: RegionNameSource::NamedFreeRegion(span) })
|
Some(RegionName {
|
||||||
|
name,
|
||||||
|
source: RegionNameSource::NamedLateParamRegion(span),
|
||||||
|
})
|
||||||
} else if tcx.asyncness(self.mir_hir_id().owner).is_async() {
|
} else if tcx.asyncness(self.mir_hir_id().owner).is_async() {
|
||||||
// If we spuriously thought that the region is named, we should let the
|
// If we spuriously thought that the region is named, we should let the
|
||||||
// system generate a true name for error messages. Currently this can
|
// system generate a true name for error messages. Currently this can
|
||||||
@ -847,7 +850,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
|
|||||||
&self,
|
&self,
|
||||||
fr: RegionVid,
|
fr: RegionVid,
|
||||||
) -> Option<RegionName> {
|
) -> Option<RegionName> {
|
||||||
let ty::ReEarlyBound(region) = *self.to_error_region(fr)? else {
|
let ty::ReEarlyParam(region) = *self.to_error_region(fr)? else {
|
||||||
return None;
|
return None;
|
||||||
};
|
};
|
||||||
if region.has_name() {
|
if region.has_name() {
|
||||||
@ -862,7 +865,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
|
|||||||
|
|
||||||
let found = tcx
|
let found = tcx
|
||||||
.any_free_region_meets(&tcx.type_of(region_parent).instantiate_identity(), |r| {
|
.any_free_region_meets(&tcx.type_of(region_parent).instantiate_identity(), |r| {
|
||||||
*r == ty::ReEarlyBound(region)
|
*r == ty::ReEarlyParam(region)
|
||||||
});
|
});
|
||||||
|
|
||||||
Some(RegionName {
|
Some(RegionName {
|
||||||
@ -881,7 +884,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
|
|||||||
&self,
|
&self,
|
||||||
fr: RegionVid,
|
fr: RegionVid,
|
||||||
) -> Option<RegionName> {
|
) -> Option<RegionName> {
|
||||||
let ty::ReEarlyBound(region) = *self.to_error_region(fr)? else {
|
let ty::ReEarlyParam(region) = *self.to_error_region(fr)? else {
|
||||||
return None;
|
return None;
|
||||||
};
|
};
|
||||||
if region.has_name() {
|
if region.has_name() {
|
||||||
@ -943,7 +946,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
|
|||||||
&self,
|
&self,
|
||||||
clauses: &[ty::Clause<'tcx>],
|
clauses: &[ty::Clause<'tcx>],
|
||||||
ty: Ty<'tcx>,
|
ty: Ty<'tcx>,
|
||||||
region: ty::EarlyBoundRegion,
|
region: ty::EarlyParamRegion,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
let tcx = self.infcx.tcx;
|
let tcx = self.infcx.tcx;
|
||||||
ty.walk().any(|arg| {
|
ty.walk().any(|arg| {
|
||||||
@ -956,7 +959,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
|
|||||||
ty::ClauseKind::Projection(data) if data.projection_ty.self_ty() == ty => {}
|
ty::ClauseKind::Projection(data) if data.projection_ty.self_ty() == ty => {}
|
||||||
_ => return false,
|
_ => return false,
|
||||||
}
|
}
|
||||||
tcx.any_free_region_meets(pred, |r| *r == ty::ReEarlyBound(region))
|
tcx.any_free_region_meets(pred, |r| *r == ty::ReEarlyParam(region))
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
|
@ -36,7 +36,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
|||||||
/// call `infer_opaque_definition_from_instantiation` to get the inferred
|
/// call `infer_opaque_definition_from_instantiation` to get the inferred
|
||||||
/// type of `_Return<'_a>`. `infer_opaque_definition_from_instantiation`
|
/// type of `_Return<'_a>`. `infer_opaque_definition_from_instantiation`
|
||||||
/// compares lifetimes directly, so we need to map the inference variables
|
/// compares lifetimes directly, so we need to map the inference variables
|
||||||
/// back to concrete lifetimes: `'static`, `ReEarlyBound` or `ReFree`.
|
/// back to concrete lifetimes: `'static`, `ReEarlyParam` or `ReLateParam`.
|
||||||
///
|
///
|
||||||
/// First we map all the lifetimes in the concrete type to an equal
|
/// First we map all the lifetimes in the concrete type to an equal
|
||||||
/// universal region that occurs in the concrete type's args, in this case
|
/// universal region that occurs in the concrete type's args, in this case
|
||||||
@ -386,7 +386,7 @@ fn check_opaque_type_parameter_valid(
|
|||||||
let arg_is_param = match arg.unpack() {
|
let arg_is_param = match arg.unpack() {
|
||||||
GenericArgKind::Type(ty) => matches!(ty.kind(), ty::Param(_)),
|
GenericArgKind::Type(ty) => matches!(ty.kind(), ty::Param(_)),
|
||||||
GenericArgKind::Lifetime(lt) if is_ty_alias => {
|
GenericArgKind::Lifetime(lt) if is_ty_alias => {
|
||||||
matches!(*lt, ty::ReEarlyBound(_) | ty::ReFree(_))
|
matches!(*lt, ty::ReEarlyParam(_) | ty::ReLateParam(_))
|
||||||
}
|
}
|
||||||
// FIXME(#113916): we can't currently check for unique lifetime params,
|
// FIXME(#113916): we can't currently check for unique lifetime params,
|
||||||
// see that issue for more. We will also have to ignore unused lifetime
|
// see that issue for more. We will also have to ignore unused lifetime
|
||||||
|
@ -462,7 +462,6 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
|
|||||||
|
|
||||||
// "Liberate" the late-bound regions. These correspond to
|
// "Liberate" the late-bound regions. These correspond to
|
||||||
// "local" free regions.
|
// "local" free regions.
|
||||||
|
|
||||||
let bound_inputs_and_output = self.compute_inputs_and_output(&indices, defining_ty);
|
let bound_inputs_and_output = self.compute_inputs_and_output(&indices, defining_ty);
|
||||||
|
|
||||||
let inputs_and_output = self.infcx.replace_bound_regions_with_nll_infer_vars(
|
let inputs_and_output = self.infcx.replace_bound_regions_with_nll_infer_vars(
|
||||||
@ -784,7 +783,7 @@ impl<'cx, 'tcx> InferCtxtExt<'tcx> for BorrowckInferCtxt<'cx, 'tcx> {
|
|||||||
let (value, _map) = self.tcx.replace_late_bound_regions(value, |br| {
|
let (value, _map) = self.tcx.replace_late_bound_regions(value, |br| {
|
||||||
debug!(?br);
|
debug!(?br);
|
||||||
let liberated_region =
|
let liberated_region =
|
||||||
ty::Region::new_free(self.tcx, all_outlive_scope.to_def_id(), br.kind);
|
ty::Region::new_late_param(self.tcx, all_outlive_scope.to_def_id(), br.kind);
|
||||||
let region_vid = {
|
let region_vid = {
|
||||||
let name = match br.kind.get_name() {
|
let name = match br.kind.get_name() {
|
||||||
Some(name) => name,
|
Some(name) => name,
|
||||||
@ -854,7 +853,7 @@ impl<'tcx> UniversalRegionIndices<'tcx> {
|
|||||||
/// Initially, the `UniversalRegionIndices` map contains only the
|
/// Initially, the `UniversalRegionIndices` map contains only the
|
||||||
/// early-bound regions in scope. Once that is all setup, we come
|
/// early-bound regions in scope. Once that is all setup, we come
|
||||||
/// in later and instantiate the late-bound regions, and then we
|
/// in later and instantiate the late-bound regions, and then we
|
||||||
/// insert the `ReFree` version of those into the map as
|
/// insert the `ReLateParam` version of those into the map as
|
||||||
/// well. These are used for error reporting.
|
/// well. These are used for error reporting.
|
||||||
fn insert_late_bound_region(&mut self, r: ty::Region<'tcx>, vid: ty::RegionVid) {
|
fn insert_late_bound_region(&mut self, r: ty::Region<'tcx>, vid: ty::RegionVid) {
|
||||||
debug!("insert_late_bound_region({:?}, {:?})", r, vid);
|
debug!("insert_late_bound_region({:?}, {:?})", r, vid);
|
||||||
@ -933,7 +932,8 @@ fn for_each_late_bound_region_in_item<'tcx>(
|
|||||||
let ty::BoundVariableKind::Region(bound_region) = bound_var else {
|
let ty::BoundVariableKind::Region(bound_region) = bound_var else {
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
let liberated_region = ty::Region::new_free(tcx, mir_def_id.to_def_id(), bound_region);
|
let liberated_region =
|
||||||
|
ty::Region::new_late_param(tcx, mir_def_id.to_def_id(), bound_region);
|
||||||
f(liberated_region);
|
f(liberated_region);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -258,12 +258,12 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||||||
let item_def_id = tcx.hir().ty_param_owner(def_id.expect_local());
|
let item_def_id = tcx.hir().ty_param_owner(def_id.expect_local());
|
||||||
let generics = tcx.generics_of(item_def_id);
|
let generics = tcx.generics_of(item_def_id);
|
||||||
let index = generics.param_def_id_to_index[&def_id];
|
let index = generics.param_def_id_to_index[&def_id];
|
||||||
ty::Region::new_early_bound(tcx, ty::EarlyBoundRegion { def_id, index, name })
|
ty::Region::new_early_param(tcx, ty::EarlyParamRegion { def_id, index, name })
|
||||||
}
|
}
|
||||||
|
|
||||||
Some(rbv::ResolvedArg::Free(scope, id)) => {
|
Some(rbv::ResolvedArg::Free(scope, id)) => {
|
||||||
let name = lifetime_name(id.expect_local());
|
let name = lifetime_name(id.expect_local());
|
||||||
ty::Region::new_free(tcx, scope, ty::BrNamed(id, name))
|
ty::Region::new_late_param(tcx, scope, ty::BrNamed(id, name))
|
||||||
|
|
||||||
// (*) -- not late-bound, won't change
|
// (*) -- not late-bound, won't change
|
||||||
}
|
}
|
||||||
|
@ -532,8 +532,8 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for RemapLateBound<'_, '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 let ty::ReFree(fr) = *r {
|
if let ty::ReLateParam(fr) = *r {
|
||||||
ty::Region::new_free(
|
ty::Region::new_late_param(
|
||||||
self.tcx,
|
self.tcx,
|
||||||
fr.scope,
|
fr.scope,
|
||||||
self.mapping.get(&fr.bound_region).copied().unwrap_or(fr.bound_region),
|
self.mapping.get(&fr.bound_region).copied().unwrap_or(fr.bound_region),
|
||||||
@ -1078,20 +1078,20 @@ impl<'tcx> ty::FallibleTypeFolder<TyCtxt<'tcx>> for RemapHiddenTyRegions<'tcx> {
|
|||||||
region: ty::Region<'tcx>,
|
region: ty::Region<'tcx>,
|
||||||
) -> Result<ty::Region<'tcx>, Self::Error> {
|
) -> Result<ty::Region<'tcx>, Self::Error> {
|
||||||
match region.kind() {
|
match region.kind() {
|
||||||
// Remap all free regions, which correspond to late-bound regions in the function.
|
// Remap late-bound regions from the function.
|
||||||
ty::ReFree(_) => {}
|
ty::ReLateParam(_) => {}
|
||||||
// Remap early-bound regions as long as they don't come from the `impl` itself,
|
// Remap early-bound regions as long as they don't come from the `impl` itself,
|
||||||
// in which case we don't really need to renumber them.
|
// in which case we don't really need to renumber them.
|
||||||
ty::ReEarlyBound(ebr) if self.tcx.parent(ebr.def_id) != self.impl_def_id => {}
|
ty::ReEarlyParam(ebr) if self.tcx.parent(ebr.def_id) != self.impl_def_id => {}
|
||||||
_ => return Ok(region),
|
_ => return Ok(region),
|
||||||
}
|
}
|
||||||
|
|
||||||
let e = if let Some(region) = self.map.get(®ion) {
|
let e = if let Some(region) = self.map.get(®ion) {
|
||||||
if let ty::ReEarlyBound(e) = region.kind() { e } else { bug!() }
|
if let ty::ReEarlyParam(e) = region.kind() { e } else { bug!() }
|
||||||
} else {
|
} else {
|
||||||
let guar = match region.kind() {
|
let guar = match region.kind() {
|
||||||
ty::ReEarlyBound(ty::EarlyBoundRegion { def_id, .. })
|
ty::ReEarlyParam(ty::EarlyParamRegion { def_id, .. })
|
||||||
| ty::ReFree(ty::FreeRegion {
|
| ty::ReLateParam(ty::LateParamRegion {
|
||||||
bound_region: ty::BoundRegionKind::BrNamed(def_id, _),
|
bound_region: ty::BoundRegionKind::BrNamed(def_id, _),
|
||||||
..
|
..
|
||||||
}) => {
|
}) => {
|
||||||
@ -1119,9 +1119,9 @@ impl<'tcx> ty::FallibleTypeFolder<TyCtxt<'tcx>> for RemapHiddenTyRegions<'tcx> {
|
|||||||
return Err(guar);
|
return Err(guar);
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(ty::Region::new_early_bound(
|
Ok(ty::Region::new_early_param(
|
||||||
self.tcx,
|
self.tcx,
|
||||||
ty::EarlyBoundRegion {
|
ty::EarlyParamRegion {
|
||||||
def_id: e.def_id,
|
def_id: e.def_id,
|
||||||
name: e.name,
|
name: e.name,
|
||||||
index: (e.index as usize - self.num_trait_args + self.num_impl_args) as u32,
|
index: (e.index as usize - self.num_trait_args + self.num_impl_args) as u32,
|
||||||
|
@ -81,8 +81,7 @@ fn ensure_drop_params_and_item_params_correspond<'tcx>(
|
|||||||
self_type_did: DefId,
|
self_type_did: DefId,
|
||||||
adt_to_impl_args: GenericArgsRef<'tcx>,
|
adt_to_impl_args: GenericArgsRef<'tcx>,
|
||||||
) -> Result<(), ErrorGuaranteed> {
|
) -> Result<(), ErrorGuaranteed> {
|
||||||
let Err(arg) = tcx.uses_unique_generic_params(adt_to_impl_args, CheckRegions::OnlyEarlyBound)
|
let Err(arg) = tcx.uses_unique_generic_params(adt_to_impl_args, CheckRegions::OnlyParam) else {
|
||||||
else {
|
|
||||||
return Ok(());
|
return Ok(());
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -595,9 +595,9 @@ fn gather_gat_bounds<'tcx, T: TypeFoldable<TyCtxt<'tcx>>>(
|
|||||||
// Same for the region. In our example, 'a corresponds
|
// Same for the region. In our example, 'a corresponds
|
||||||
// to the 'me parameter.
|
// to the 'me parameter.
|
||||||
let region_param = gat_generics.param_at(*region_a_idx, tcx);
|
let region_param = gat_generics.param_at(*region_a_idx, tcx);
|
||||||
let region_param = ty::Region::new_early_bound(
|
let region_param = ty::Region::new_early_param(
|
||||||
tcx,
|
tcx,
|
||||||
ty::EarlyBoundRegion {
|
ty::EarlyParamRegion {
|
||||||
def_id: region_param.def_id,
|
def_id: region_param.def_id,
|
||||||
index: region_param.index,
|
index: region_param.index,
|
||||||
name: region_param.name,
|
name: region_param.name,
|
||||||
@ -628,9 +628,9 @@ fn gather_gat_bounds<'tcx, T: TypeFoldable<TyCtxt<'tcx>>>(
|
|||||||
debug!("required clause: {region_a} must outlive {region_b}");
|
debug!("required clause: {region_a} must outlive {region_b}");
|
||||||
// Translate into the generic parameters of the GAT.
|
// Translate into the generic parameters of the GAT.
|
||||||
let region_a_param = gat_generics.param_at(*region_a_idx, tcx);
|
let region_a_param = gat_generics.param_at(*region_a_idx, tcx);
|
||||||
let region_a_param = ty::Region::new_early_bound(
|
let region_a_param = ty::Region::new_early_param(
|
||||||
tcx,
|
tcx,
|
||||||
ty::EarlyBoundRegion {
|
ty::EarlyParamRegion {
|
||||||
def_id: region_a_param.def_id,
|
def_id: region_a_param.def_id,
|
||||||
index: region_a_param.index,
|
index: region_a_param.index,
|
||||||
name: region_a_param.name,
|
name: region_a_param.name,
|
||||||
@ -638,9 +638,9 @@ fn gather_gat_bounds<'tcx, T: TypeFoldable<TyCtxt<'tcx>>>(
|
|||||||
);
|
);
|
||||||
// Same for the region.
|
// Same for the region.
|
||||||
let region_b_param = gat_generics.param_at(*region_b_idx, tcx);
|
let region_b_param = gat_generics.param_at(*region_b_idx, tcx);
|
||||||
let region_b_param = ty::Region::new_early_bound(
|
let region_b_param = ty::Region::new_early_param(
|
||||||
tcx,
|
tcx,
|
||||||
ty::EarlyBoundRegion {
|
ty::EarlyParamRegion {
|
||||||
def_id: region_b_param.def_id,
|
def_id: region_b_param.def_id,
|
||||||
index: region_b_param.index,
|
index: region_b_param.index,
|
||||||
name: region_b_param.name,
|
name: region_b_param.name,
|
||||||
|
@ -550,7 +550,7 @@ fn infringing_fields_error(
|
|||||||
.entry((ty.clone(), predicate.clone()))
|
.entry((ty.clone(), predicate.clone()))
|
||||||
.or_default()
|
.or_default()
|
||||||
.push(origin.span());
|
.push(origin.span());
|
||||||
if let ty::RegionKind::ReEarlyBound(ebr) = *b
|
if let ty::RegionKind::ReEarlyParam(ebr) = *b
|
||||||
&& ebr.has_name()
|
&& ebr.has_name()
|
||||||
{
|
{
|
||||||
bounds.push((b.to_string(), a.to_string(), None));
|
bounds.push((b.to_string(), a.to_string(), None));
|
||||||
|
@ -443,7 +443,7 @@ impl<'tcx> AstConv<'tcx> for ItemCtxt<'tcx> {
|
|||||||
self.tcx.replace_late_bound_regions_uncached(
|
self.tcx.replace_late_bound_regions_uncached(
|
||||||
poly_trait_ref,
|
poly_trait_ref,
|
||||||
|_| {
|
|_| {
|
||||||
ty::Region::new_early_bound(self.tcx, ty::EarlyBoundRegion {
|
ty::Region::new_early_param(self.tcx, ty::EarlyParamRegion {
|
||||||
def_id: item_def_id,
|
def_id: item_def_id,
|
||||||
index: 0,
|
index: 0,
|
||||||
name: Symbol::intern(<_name),
|
name: Symbol::intern(<_name),
|
||||||
|
@ -362,10 +362,10 @@ fn compute_bidirectional_outlives_predicates<'tcx>(
|
|||||||
) {
|
) {
|
||||||
for param in opaque_own_params {
|
for param in opaque_own_params {
|
||||||
let orig_lifetime = tcx.map_rpit_lifetime_to_fn_lifetime(param.def_id.expect_local());
|
let orig_lifetime = tcx.map_rpit_lifetime_to_fn_lifetime(param.def_id.expect_local());
|
||||||
if let ty::ReEarlyBound(..) = *orig_lifetime {
|
if let ty::ReEarlyParam(..) = *orig_lifetime {
|
||||||
let dup_lifetime = ty::Region::new_early_bound(
|
let dup_lifetime = ty::Region::new_early_param(
|
||||||
tcx,
|
tcx,
|
||||||
ty::EarlyBoundRegion { def_id: param.def_id, index: param.index, name: param.name },
|
ty::EarlyParamRegion { def_id: param.def_id, index: param.index, name: param.name },
|
||||||
);
|
);
|
||||||
let span = tcx.def_span(param.def_id);
|
let span = tcx.def_span(param.def_id);
|
||||||
predicates.push((
|
predicates.push((
|
||||||
|
@ -2012,7 +2012,7 @@ fn is_late_bound_map(
|
|||||||
|
|
||||||
fn visit_region(&mut self, r: ty::Region<'tcx>) -> ControlFlow<!> {
|
fn visit_region(&mut self, r: ty::Region<'tcx>) -> ControlFlow<!> {
|
||||||
debug!("r={:?}", r.kind());
|
debug!("r={:?}", r.kind());
|
||||||
if let ty::RegionKind::ReEarlyBound(region) = r.kind() {
|
if let ty::RegionKind::ReEarlyParam(region) = r.kind() {
|
||||||
self.arg_is_constrained[region.index as usize] = true;
|
self.arg_is_constrained[region.index as usize] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,8 +13,8 @@ impl From<ty::ParamTy> for Parameter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<ty::EarlyBoundRegion> for Parameter {
|
impl From<ty::EarlyParamRegion> for Parameter {
|
||||||
fn from(param: ty::EarlyBoundRegion) -> Self {
|
fn from(param: ty::EarlyParamRegion) -> Self {
|
||||||
Parameter(param.index)
|
Parameter(param.index)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -73,7 +73,7 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for ParameterCollector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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::ReEarlyBound(data) = *r {
|
if let ty::ReEarlyParam(data) = *r {
|
||||||
self.parameters.push(Parameter::from(data));
|
self.parameters.push(Parameter::from(data));
|
||||||
}
|
}
|
||||||
ControlFlow::Continue(())
|
ControlFlow::Continue(())
|
||||||
|
@ -146,11 +146,11 @@ fn is_free_region(region: Region<'_>) -> bool {
|
|||||||
// These correspond to `T: 'a` relationships:
|
// These correspond to `T: 'a` relationships:
|
||||||
//
|
//
|
||||||
// struct Foo<'a, T> {
|
// struct Foo<'a, T> {
|
||||||
// field: &'a T, // this would generate a ReEarlyBound referencing `'a`
|
// field: &'a T, // this would generate a ReEarlyParam referencing `'a`
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// We care about these, so fall through.
|
// We care about these, so fall through.
|
||||||
ty::ReEarlyBound(_) => true,
|
ty::ReEarlyParam(_) => true,
|
||||||
|
|
||||||
// These correspond to `T: 'static` relationships which can be
|
// These correspond to `T: 'static` relationships which can be
|
||||||
// rather surprising.
|
// rather surprising.
|
||||||
@ -173,7 +173,7 @@ fn is_free_region(region: Region<'_>) -> bool {
|
|||||||
ty::ReError(_) => false,
|
ty::ReError(_) => false,
|
||||||
|
|
||||||
// These regions don't appear in types from type declarations:
|
// These regions don't appear in types from type declarations:
|
||||||
ty::ReErased | ty::ReVar(..) | ty::RePlaceholder(..) | ty::ReFree(..) => {
|
ty::ReErased | ty::ReVar(..) | ty::RePlaceholder(..) | ty::ReLateParam(..) => {
|
||||||
bug!("unexpected region in outlives inference: {:?}", region);
|
bug!("unexpected region in outlives inference: {:?}", region);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -413,7 +413,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
|
|||||||
variance: VarianceTermPtr<'a>,
|
variance: VarianceTermPtr<'a>,
|
||||||
) {
|
) {
|
||||||
match *region {
|
match *region {
|
||||||
ty::ReEarlyBound(ref data) => {
|
ty::ReEarlyParam(ref data) => {
|
||||||
self.add_constraint(current, data.index, variance);
|
self.add_constraint(current, data.index, variance);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -428,7 +428,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
|
|||||||
|
|
||||||
ty::ReError(_) => {}
|
ty::ReError(_) => {}
|
||||||
|
|
||||||
ty::ReFree(..) | ty::ReVar(..) | ty::RePlaceholder(..) | ty::ReErased => {
|
ty::ReLateParam(..) | ty::ReVar(..) | ty::RePlaceholder(..) | ty::ReErased => {
|
||||||
// We don't expect to see anything but 'static or bound
|
// We don't expect to see anything but 'static or bound
|
||||||
// regions when visiting member types or method types.
|
// regions when visiting member types or method types.
|
||||||
bug!(
|
bug!(
|
||||||
|
@ -106,7 +106,7 @@ fn variance_of_opaque(tcx: TyCtxt<'_>, item_def_id: LocalDefId) -> &[ty::Varianc
|
|||||||
impl<'tcx> ty::TypeVisitor<TyCtxt<'tcx>> for OpaqueTypeLifetimeCollector<'tcx> {
|
impl<'tcx> ty::TypeVisitor<TyCtxt<'tcx>> for OpaqueTypeLifetimeCollector<'tcx> {
|
||||||
#[instrument(level = "trace", skip(self), ret)]
|
#[instrument(level = "trace", skip(self), ret)]
|
||||||
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::RegionKind::ReEarlyBound(ebr) = r.kind() {
|
if let ty::RegionKind::ReEarlyParam(ebr) = r.kind() {
|
||||||
self.variances[ebr.index as usize] = ty::Invariant;
|
self.variances[ebr.index as usize] = ty::Invariant;
|
||||||
}
|
}
|
||||||
ControlFlow::Continue(())
|
ControlFlow::Continue(())
|
||||||
|
@ -238,7 +238,7 @@ impl<'a, 'tcx> AstConv<'tcx> for FnCtxt<'a, 'tcx> {
|
|||||||
|
|
||||||
fn re_infer(&self, def: Option<&ty::GenericParamDef>, span: Span) -> Option<ty::Region<'tcx>> {
|
fn re_infer(&self, def: Option<&ty::GenericParamDef>, span: Span) -> Option<ty::Region<'tcx>> {
|
||||||
let v = match def {
|
let v = match def {
|
||||||
Some(def) => infer::EarlyBoundRegion(span, def.name),
|
Some(def) => infer::RegionParameterDefinition(span, def.name),
|
||||||
None => infer::MiscVariable(span),
|
None => infer::MiscVariable(span),
|
||||||
};
|
};
|
||||||
Some(self.next_region_var(v))
|
Some(self.next_region_var(v))
|
||||||
|
@ -17,7 +17,7 @@ impl<'a> DescriptionCtx<'a> {
|
|||||||
alt_span: Option<Span>,
|
alt_span: Option<Span>,
|
||||||
) -> Option<Self> {
|
) -> Option<Self> {
|
||||||
let (span, kind, arg) = match *region {
|
let (span, kind, arg) = match *region {
|
||||||
ty::ReEarlyBound(ref br) => {
|
ty::ReEarlyParam(ref br) => {
|
||||||
let scope = region.free_region_binding_scope(tcx).expect_local();
|
let scope = region.free_region_binding_scope(tcx).expect_local();
|
||||||
let span = if let Some(param) =
|
let span = if let Some(param) =
|
||||||
tcx.hir().get_generics(scope).and_then(|generics| generics.get_named(br.name))
|
tcx.hir().get_generics(scope).and_then(|generics| generics.get_named(br.name))
|
||||||
@ -32,7 +32,7 @@ impl<'a> DescriptionCtx<'a> {
|
|||||||
(Some(span), "as_defined_anon", String::new())
|
(Some(span), "as_defined_anon", String::new())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ty::ReFree(ref fr) => {
|
ty::ReLateParam(ref fr) => {
|
||||||
if !fr.bound_region.is_named()
|
if !fr.bound_region.is_named()
|
||||||
&& let Some((ty, _)) = find_anon_type(tcx, region, &fr.bound_region)
|
&& let Some((ty, _)) = find_anon_type(tcx, region, &fr.bound_region)
|
||||||
{
|
{
|
||||||
@ -70,7 +70,7 @@ impl<'a> DescriptionCtx<'a> {
|
|||||||
ty::RePlaceholder(_) | ty::ReError(_) => return None,
|
ty::RePlaceholder(_) | ty::ReError(_) => return None,
|
||||||
|
|
||||||
// FIXME(#13998) RePlaceholder should probably print like
|
// FIXME(#13998) RePlaceholder should probably print like
|
||||||
// ReFree rather than dumping Debug output on the user.
|
// ReLateParam 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 ReBound though.
|
// and ReBound though.
|
||||||
|
@ -172,7 +172,7 @@ impl CanonicalizeMode for CanonicalizeQueryResponse {
|
|||||||
r: ty::Region<'tcx>,
|
r: ty::Region<'tcx>,
|
||||||
) -> ty::Region<'tcx> {
|
) -> ty::Region<'tcx> {
|
||||||
match *r {
|
match *r {
|
||||||
ty::ReFree(_) | ty::ReErased | ty::ReStatic | ty::ReEarlyBound(..) => r,
|
ty::ReLateParam(_) | ty::ReErased | ty::ReStatic | ty::ReEarlyParam(..) => r,
|
||||||
|
|
||||||
ty::RePlaceholder(placeholder) => canonicalizer.canonical_var_for_region(
|
ty::RePlaceholder(placeholder) => canonicalizer.canonical_var_for_region(
|
||||||
CanonicalVarInfo { kind: CanonicalVarKind::PlaceholderRegion(placeholder) },
|
CanonicalVarInfo { kind: CanonicalVarKind::PlaceholderRegion(placeholder) },
|
||||||
@ -223,7 +223,11 @@ impl CanonicalizeMode for CanonicalizeUserTypeAnnotation {
|
|||||||
r: ty::Region<'tcx>,
|
r: ty::Region<'tcx>,
|
||||||
) -> ty::Region<'tcx> {
|
) -> ty::Region<'tcx> {
|
||||||
match *r {
|
match *r {
|
||||||
ty::ReEarlyBound(_) | ty::ReFree(_) | ty::ReErased | ty::ReStatic | ty::ReError(_) => r,
|
ty::ReEarlyParam(_)
|
||||||
|
| ty::ReLateParam(_)
|
||||||
|
| 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::ReBound(..) => {
|
ty::RePlaceholder(..) | ty::ReBound(..) => {
|
||||||
// We only expect region names that the user can type.
|
// We only expect region names that the user can type.
|
||||||
@ -359,9 +363,9 @@ impl<'cx, 'tcx> TypeFolder<TyCtxt<'tcx>> for Canonicalizer<'cx, 'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ty::ReStatic
|
ty::ReStatic
|
||||||
| ty::ReEarlyBound(..)
|
| ty::ReEarlyParam(..)
|
||||||
| ty::ReError(_)
|
| ty::ReError(_)
|
||||||
| ty::ReFree(_)
|
| ty::ReLateParam(_)
|
||||||
| ty::RePlaceholder(..)
|
| ty::RePlaceholder(..)
|
||||||
| ty::ReErased => self.canonicalize_mode.canonicalize_free_region(self, r),
|
| ty::ReErased => self.canonicalize_mode.canonicalize_free_region(self, r),
|
||||||
}
|
}
|
||||||
|
@ -168,7 +168,7 @@ pub(super) fn note_and_explain_region<'tcx>(
|
|||||||
alt_span: Option<Span>,
|
alt_span: Option<Span>,
|
||||||
) {
|
) {
|
||||||
let (description, span) = match *region {
|
let (description, span) = match *region {
|
||||||
ty::ReEarlyBound(_) | ty::ReFree(_) | ty::RePlaceholder(_) | ty::ReStatic => {
|
ty::ReEarlyParam(_) | ty::ReLateParam(_) | ty::RePlaceholder(_) | ty::ReStatic => {
|
||||||
msg_span_from_named_region(tcx, region, alt_span)
|
msg_span_from_named_region(tcx, region, alt_span)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -202,7 +202,7 @@ fn msg_span_from_named_region<'tcx>(
|
|||||||
alt_span: Option<Span>,
|
alt_span: Option<Span>,
|
||||||
) -> (String, Option<Span>) {
|
) -> (String, Option<Span>) {
|
||||||
match *region {
|
match *region {
|
||||||
ty::ReEarlyBound(ref br) => {
|
ty::ReEarlyParam(ref br) => {
|
||||||
let scope = region.free_region_binding_scope(tcx).expect_local();
|
let scope = region.free_region_binding_scope(tcx).expect_local();
|
||||||
let span = if let Some(param) =
|
let span = if let Some(param) =
|
||||||
tcx.hir().get_generics(scope).and_then(|generics| generics.get_named(br.name))
|
tcx.hir().get_generics(scope).and_then(|generics| generics.get_named(br.name))
|
||||||
@ -218,7 +218,7 @@ fn msg_span_from_named_region<'tcx>(
|
|||||||
};
|
};
|
||||||
(text, Some(span))
|
(text, Some(span))
|
||||||
}
|
}
|
||||||
ty::ReFree(ref fr) => {
|
ty::ReLateParam(ref fr) => {
|
||||||
if !fr.bound_region.is_named()
|
if !fr.bound_region.is_named()
|
||||||
&& let Some((ty, _)) = find_anon_type(tcx, region, &fr.bound_region)
|
&& let Some((ty, _)) = find_anon_type(tcx, region, &fr.bound_region)
|
||||||
{
|
{
|
||||||
@ -315,7 +315,7 @@ pub fn unexpected_hidden_region_diagnostic<'tcx>(
|
|||||||
|
|
||||||
// Explain the region we are capturing.
|
// Explain the region we are capturing.
|
||||||
match *hidden_region {
|
match *hidden_region {
|
||||||
ty::ReEarlyBound(_) | ty::ReFree(_) | ty::ReStatic => {
|
ty::ReEarlyParam(_) | ty::ReLateParam(_) | ty::ReStatic => {
|
||||||
// Assuming regionck succeeded (*), we ought to always be
|
// Assuming regionck succeeded (*), we ought to always be
|
||||||
// capturing *some* region from the fn header, and hence it
|
// capturing *some* region from the fn header, and hence it
|
||||||
// ought to be free. So under normal circumstances, we will go
|
// ought to be free. So under normal circumstances, we will go
|
||||||
@ -2364,7 +2364,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||||||
span,
|
span,
|
||||||
format!("{labeled_user_string} may not live long enough"),
|
format!("{labeled_user_string} may not live long enough"),
|
||||||
match sub.kind() {
|
match sub.kind() {
|
||||||
ty::ReEarlyBound(_) | ty::ReFree(_) if sub.has_name() => error_code!(E0309),
|
ty::ReEarlyParam(_) | ty::ReLateParam(_) if sub.has_name() => error_code!(E0309),
|
||||||
ty::ReStatic => error_code!(E0310),
|
ty::ReStatic => error_code!(E0310),
|
||||||
_ => error_code!(E0311),
|
_ => error_code!(E0311),
|
||||||
},
|
},
|
||||||
@ -2372,7 +2372,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||||||
|
|
||||||
'_explain: {
|
'_explain: {
|
||||||
let (description, span) = match sub.kind() {
|
let (description, span) = match sub.kind() {
|
||||||
ty::ReEarlyBound(_) | ty::ReFree(_) | ty::ReStatic => {
|
ty::ReEarlyParam(_) | ty::ReLateParam(_) | ty::ReStatic => {
|
||||||
msg_span_from_named_region(self.tcx, sub, Some(span))
|
msg_span_from_named_region(self.tcx, sub, Some(span))
|
||||||
}
|
}
|
||||||
_ => (format!("lifetime `{sub}`"), Some(span)),
|
_ => (format!("lifetime `{sub}`"), Some(span)),
|
||||||
@ -2515,7 +2515,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||||||
|
|
||||||
let (lifetime_def_id, lifetime_scope) = match self.tcx.is_suitable_region(lifetime) {
|
let (lifetime_def_id, lifetime_scope) = match self.tcx.is_suitable_region(lifetime) {
|
||||||
Some(info) if !lifetime.has_name() => {
|
Some(info) if !lifetime.has_name() => {
|
||||||
(info.boundregion.get_id().unwrap().expect_local(), info.def_id)
|
(info.bound_region.get_id().unwrap().expect_local(), info.def_id)
|
||||||
}
|
}
|
||||||
_ => return lifetime.get_name_or_anon().to_string(),
|
_ => return lifetime.get_name_or_anon().to_string(),
|
||||||
};
|
};
|
||||||
@ -2714,8 +2714,8 @@ impl<'tcx> TypeRelation<'tcx> for SameTypeModuloInfer<'_, 'tcx> {
|
|||||||
a: ty::Region<'tcx>,
|
a: ty::Region<'tcx>,
|
||||||
b: ty::Region<'tcx>,
|
b: ty::Region<'tcx>,
|
||||||
) -> RelateResult<'tcx, ty::Region<'tcx>> {
|
) -> RelateResult<'tcx, ty::Region<'tcx>> {
|
||||||
if (a.is_var() && b.is_free_or_static())
|
if (a.is_var() && b.is_free())
|
||||||
|| (b.is_var() && a.is_free_or_static())
|
|| (b.is_var() && a.is_free())
|
||||||
|| (a.is_var() && b.is_var())
|
|| (a.is_var() && b.is_var())
|
||||||
|| a == b
|
|| a == b
|
||||||
{
|
{
|
||||||
@ -2779,7 +2779,9 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||||||
br_string(br),
|
br_string(br),
|
||||||
self.tcx.associated_item(def_id).name
|
self.tcx.associated_item(def_id).name
|
||||||
),
|
),
|
||||||
infer::EarlyBoundRegion(_, name) => format!(" for lifetime parameter `{name}`"),
|
infer::RegionParameterDefinition(_, name) => {
|
||||||
|
format!(" for lifetime parameter `{name}`")
|
||||||
|
}
|
||||||
infer::UpvarRegion(ref upvar_id, _) => {
|
infer::UpvarRegion(ref upvar_id, _) => {
|
||||||
let var_name = self.tcx.hir().name(upvar_id.var_path.hir_id);
|
let var_name = self.tcx.hir().name(upvar_id.var_path.hir_id);
|
||||||
format!(" for capture of `{var_name}` by closure")
|
format!(" for capture of `{var_name}` by closure")
|
||||||
|
@ -70,9 +70,9 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
|||||||
|
|
||||||
let anon_reg_sub = self.tcx().is_suitable_region(sub)?;
|
let anon_reg_sub = self.tcx().is_suitable_region(sub)?;
|
||||||
let scope_def_id_sup = anon_reg_sup.def_id;
|
let scope_def_id_sup = anon_reg_sup.def_id;
|
||||||
let bregion_sup = anon_reg_sup.boundregion;
|
let bregion_sup = anon_reg_sup.bound_region;
|
||||||
let scope_def_id_sub = anon_reg_sub.def_id;
|
let scope_def_id_sub = anon_reg_sub.def_id;
|
||||||
let bregion_sub = anon_reg_sub.boundregion;
|
let bregion_sub = anon_reg_sub.bound_region;
|
||||||
|
|
||||||
let ty_sup = find_anon_type(self.tcx(), sup, &bregion_sup)?;
|
let ty_sup = find_anon_type(self.tcx(), sup, &bregion_sup)?;
|
||||||
|
|
||||||
|
@ -41,8 +41,8 @@ pub fn find_param_with_region<'tcx>(
|
|||||||
replace_region: Region<'tcx>,
|
replace_region: Region<'tcx>,
|
||||||
) -> Option<AnonymousParamInfo<'tcx>> {
|
) -> Option<AnonymousParamInfo<'tcx>> {
|
||||||
let (id, bound_region) = match *anon_region {
|
let (id, bound_region) = match *anon_region {
|
||||||
ty::ReFree(ref free_region) => (free_region.scope, free_region.bound_region),
|
ty::ReLateParam(late_param) => (late_param.scope, late_param.bound_region),
|
||||||
ty::ReEarlyBound(ebr) => {
|
ty::ReEarlyParam(ebr) => {
|
||||||
(tcx.parent(ebr.def_id), ty::BoundRegionKind::BrNamed(ebr.def_id, ebr.name))
|
(tcx.parent(ebr.def_id), ty::BoundRegionKind::BrNamed(ebr.def_id, ebr.name))
|
||||||
}
|
}
|
||||||
_ => return None, // not a free region
|
_ => return None, // not a free region
|
||||||
|
@ -22,8 +22,8 @@ impl<'a, 'tcx> RegionRelations<'a, 'tcx> {
|
|||||||
Self { tcx, free_regions }
|
Self { tcx, free_regions }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn lub_free_regions(&self, r_a: Region<'tcx>, r_b: Region<'tcx>) -> Region<'tcx> {
|
pub fn lub_param_regions(&self, r_a: Region<'tcx>, r_b: Region<'tcx>) -> Region<'tcx> {
|
||||||
self.free_regions.lub_free_regions(self.tcx, r_a, r_b)
|
self.free_regions.lub_param_regions(self.tcx, r_a, r_b)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,7 +59,7 @@ impl<'tcx> FreeRegionMap<'tcx> {
|
|||||||
r_a: Region<'tcx>,
|
r_a: Region<'tcx>,
|
||||||
r_b: Region<'tcx>,
|
r_b: Region<'tcx>,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
assert!(r_a.is_free_or_static() && r_b.is_free_or_static());
|
assert!(r_a.is_free() && r_b.is_free());
|
||||||
let re_static = tcx.lifetimes.re_static;
|
let re_static = tcx.lifetimes.re_static;
|
||||||
if self.check_relation(re_static, r_b) {
|
if self.check_relation(re_static, r_b) {
|
||||||
// `'a <= 'static` is always true, and not stored in the
|
// `'a <= 'static` is always true, and not stored in the
|
||||||
@ -80,15 +80,15 @@ impl<'tcx> FreeRegionMap<'tcx> {
|
|||||||
/// cases, this is more conservative than necessary, in order to
|
/// cases, this is more conservative than necessary, in order to
|
||||||
/// avoid making arbitrary choices. See
|
/// avoid making arbitrary choices. See
|
||||||
/// `TransitiveRelation::postdom_upper_bound` for more details.
|
/// `TransitiveRelation::postdom_upper_bound` for more details.
|
||||||
pub fn lub_free_regions(
|
pub fn lub_param_regions(
|
||||||
&self,
|
&self,
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
r_a: Region<'tcx>,
|
r_a: Region<'tcx>,
|
||||||
r_b: Region<'tcx>,
|
r_b: Region<'tcx>,
|
||||||
) -> Region<'tcx> {
|
) -> Region<'tcx> {
|
||||||
debug!("lub_free_regions(r_a={:?}, r_b={:?})", r_a, r_b);
|
debug!("lub_param_regions(r_a={:?}, r_b={:?})", r_a, r_b);
|
||||||
assert!(r_a.is_free());
|
assert!(r_a.is_param());
|
||||||
assert!(r_b.is_free());
|
assert!(r_b.is_param());
|
||||||
let result = if r_a == r_b {
|
let result = if r_a == r_b {
|
||||||
r_a
|
r_a
|
||||||
} else {
|
} else {
|
||||||
@ -97,7 +97,7 @@ impl<'tcx> FreeRegionMap<'tcx> {
|
|||||||
Some(r) => r,
|
Some(r) => r,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
debug!("lub_free_regions(r_a={:?}, r_b={:?}) = {:?}", r_a, r_b, result);
|
debug!("lub_param_regions(r_a={:?}, r_b={:?}) = {:?}", r_a, r_b, result);
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -115,8 +115,8 @@ impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for TypeFreshener<'a, 'tcx> {
|
|||||||
r
|
r
|
||||||
}
|
}
|
||||||
|
|
||||||
ty::ReEarlyBound(..)
|
ty::ReEarlyParam(..)
|
||||||
| ty::ReFree(_)
|
| ty::ReLateParam(_)
|
||||||
| ty::ReVar(_)
|
| ty::ReVar(_)
|
||||||
| ty::RePlaceholder(..)
|
| ty::RePlaceholder(..)
|
||||||
| ty::ReStatic
|
| ty::ReStatic
|
||||||
|
@ -340,8 +340,8 @@ where
|
|||||||
ty::RePlaceholder(..)
|
ty::RePlaceholder(..)
|
||||||
| ty::ReVar(..)
|
| ty::ReVar(..)
|
||||||
| ty::ReStatic
|
| ty::ReStatic
|
||||||
| ty::ReEarlyBound(..)
|
| ty::ReEarlyParam(..)
|
||||||
| ty::ReFree(..) => {
|
| ty::ReLateParam(..) => {
|
||||||
// see common code below
|
// see common code below
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ 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::{ReBound, RePlaceholder, ReVar};
|
||||||
use rustc_middle::ty::{ReEarlyBound, ReErased, ReError, ReFree, ReStatic};
|
use rustc_middle::ty::{ReEarlyParam, ReErased, ReError, ReLateParam, ReStatic};
|
||||||
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;
|
||||||
@ -390,7 +390,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
ReStatic | ReEarlyBound(_) | ReFree(_) => {
|
ReStatic | ReEarlyParam(_) | ReLateParam(_) => {
|
||||||
// nothing lives longer than `'static`
|
// nothing lives longer than `'static`
|
||||||
|
|
||||||
// All empty regions are less than early-bound, free,
|
// All empty regions are less than early-bound, free,
|
||||||
@ -423,9 +423,9 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
ReStatic | ReEarlyBound(_) | ReFree(_) => {
|
ReStatic | ReEarlyParam(_) | ReLateParam(_) => {
|
||||||
// nothing lives longer than `'static`
|
// nothing lives longer than `'static`
|
||||||
// All empty regions are less than early-bound, free,
|
// All empty regions are less than early-bound, late-bound,
|
||||||
// and scope regions.
|
// and scope regions.
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
@ -450,8 +450,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
|
|||||||
|
|
||||||
// Check for the case where we know that `'b: 'static` -- in that case,
|
// Check for the case where we know that `'b: 'static` -- in that case,
|
||||||
// `a <= b` for all `a`.
|
// `a <= b` for all `a`.
|
||||||
let b_free_or_static = b.is_free_or_static();
|
if b.is_free() && sub_free_regions(tcx.lifetimes.re_static, b) {
|
||||||
if b_free_or_static && sub_free_regions(tcx.lifetimes.re_static, b) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -460,8 +459,7 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
|
|||||||
// `lub` relationship defined below, since sometimes the "lub"
|
// `lub` relationship defined below, since sometimes the "lub"
|
||||||
// is actually the `postdom_upper_bound` (see
|
// is actually the `postdom_upper_bound` (see
|
||||||
// `TransitiveRelation` for more details).
|
// `TransitiveRelation` for more details).
|
||||||
let a_free_or_static = a.is_free_or_static();
|
if a.is_free() && b.is_free() {
|
||||||
if a_free_or_static && b_free_or_static {
|
|
||||||
return sub_free_regions(a, b);
|
return sub_free_regions(a, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -501,8 +499,8 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
|
|||||||
self.tcx().lifetimes.re_static
|
self.tcx().lifetimes.re_static
|
||||||
}
|
}
|
||||||
|
|
||||||
(ReEarlyBound(_) | ReFree(_), ReEarlyBound(_) | ReFree(_)) => {
|
(ReEarlyParam(_) | ReLateParam(_), ReEarlyParam(_) | ReLateParam(_)) => {
|
||||||
self.region_rels.lub_free_regions(a, b)
|
self.region_rels.lub_param_regions(a, b)
|
||||||
}
|
}
|
||||||
|
|
||||||
// For these types, we cannot define any additional
|
// For these types, we cannot define any additional
|
||||||
@ -723,13 +721,13 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We place free regions first because we are special casing
|
// We place late-bound regions first because we are special casing
|
||||||
// SubSupConflict(ReFree, ReFree) when reporting error, and so
|
// SubSupConflict(ReLateParam, ReLateParam) when reporting error, and so
|
||||||
// the user will more likely get a specific suggestion.
|
// the user will more likely get a specific suggestion.
|
||||||
fn region_order_key(x: &RegionAndOrigin<'_>) -> u8 {
|
fn region_order_key(x: &RegionAndOrigin<'_>) -> u8 {
|
||||||
match *x.region {
|
match *x.region {
|
||||||
ReEarlyBound(_) => 0,
|
ReEarlyParam(_) => 0,
|
||||||
ReFree(_) => 1,
|
ReLateParam(_) => 1,
|
||||||
_ => 2,
|
_ => 2,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -508,7 +508,10 @@ pub enum RegionVariableOrigin {
|
|||||||
Coercion(Span),
|
Coercion(Span),
|
||||||
|
|
||||||
/// Region variables created as the values for early-bound regions.
|
/// Region variables created as the values for early-bound regions.
|
||||||
EarlyBoundRegion(Span, Symbol),
|
///
|
||||||
|
/// FIXME(@lcnr): This can also store a `DefId`, similar to
|
||||||
|
/// `TypeVariableOriginKind::TypeParameterDefinition`.
|
||||||
|
RegionParameterDefinition(Span, Symbol),
|
||||||
|
|
||||||
/// Region variables created when instantiating a binder with
|
/// Region variables created when instantiating a binder with
|
||||||
/// existential variables, e.g. when calling a function or method.
|
/// existential variables, e.g. when calling a function or method.
|
||||||
@ -1165,7 +1168,7 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||||||
GenericParamDefKind::Lifetime => {
|
GenericParamDefKind::Lifetime => {
|
||||||
// Create a region inference variable for the given
|
// Create a region inference variable for the given
|
||||||
// region parameter definition.
|
// region parameter definition.
|
||||||
self.next_region_var(EarlyBoundRegion(span, param.name)).into()
|
self.next_region_var(RegionParameterDefinition(span, param.name)).into()
|
||||||
}
|
}
|
||||||
GenericParamDefKind::Type { .. } => {
|
GenericParamDefKind::Type { .. } => {
|
||||||
// Create a type inference variable for the given
|
// Create a type inference variable for the given
|
||||||
@ -2041,7 +2044,7 @@ impl RegionVariableOrigin {
|
|||||||
| AddrOfRegion(a)
|
| AddrOfRegion(a)
|
||||||
| Autoref(a)
|
| Autoref(a)
|
||||||
| Coercion(a)
|
| Coercion(a)
|
||||||
| EarlyBoundRegion(a, ..)
|
| RegionParameterDefinition(a, ..)
|
||||||
| BoundRegion(a, ..)
|
| BoundRegion(a, ..)
|
||||||
| UpvarRegion(_, a) => a,
|
| UpvarRegion(_, a) => a,
|
||||||
Nll(..) => bug!("NLL variable used with `span`"),
|
Nll(..) => bug!("NLL variable used with `span`"),
|
||||||
|
@ -138,8 +138,8 @@ impl<'tcx> OutlivesEnvironmentBuilder<'tcx> {
|
|||||||
}
|
}
|
||||||
OutlivesBound::RegionSubRegion(r_a, r_b) => match (*r_a, *r_b) {
|
OutlivesBound::RegionSubRegion(r_a, r_b) => match (*r_a, *r_b) {
|
||||||
(
|
(
|
||||||
ty::ReStatic | ty::ReEarlyBound(_) | ty::ReFree(_),
|
ty::ReStatic | ty::ReEarlyParam(_) | ty::ReLateParam(_),
|
||||||
ty::ReStatic | ty::ReEarlyBound(_) | ty::ReFree(_),
|
ty::ReStatic | ty::ReEarlyParam(_) | ty::ReLateParam(_),
|
||||||
) => self.region_relation.add(r_a, r_b),
|
) => self.region_relation.add(r_a, r_b),
|
||||||
(ty::ReError(_), _) | (_, ty::ReError(_)) => {}
|
(ty::ReError(_), _) | (_, ty::ReError(_)) => {}
|
||||||
// FIXME(#109628): We shouldn't have existential variables in implied bounds.
|
// FIXME(#109628): We shouldn't have existential variables in implied bounds.
|
||||||
|
@ -662,8 +662,8 @@ impl<'tcx> RegionConstraintCollector<'_, 'tcx> {
|
|||||||
match *region {
|
match *region {
|
||||||
ty::ReStatic
|
ty::ReStatic
|
||||||
| ty::ReErased
|
| ty::ReErased
|
||||||
| ty::ReFree(..)
|
| ty::ReLateParam(..)
|
||||||
| ty::ReEarlyBound(..)
|
| ty::ReEarlyParam(..)
|
||||||
| 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),
|
||||||
|
@ -1910,7 +1910,7 @@ impl ExplicitOutlivesRequirements {
|
|||||||
.iter()
|
.iter()
|
||||||
.filter_map(|(clause, _)| match clause.kind().skip_binder() {
|
.filter_map(|(clause, _)| match clause.kind().skip_binder() {
|
||||||
ty::ClauseKind::RegionOutlives(ty::OutlivesPredicate(a, b)) => match *a {
|
ty::ClauseKind::RegionOutlives(ty::OutlivesPredicate(a, b)) => match *a {
|
||||||
ty::ReEarlyBound(ebr) if ebr.def_id == def_id => Some(b),
|
ty::ReEarlyParam(ebr) if ebr.def_id == def_id => Some(b),
|
||||||
_ => None,
|
_ => None,
|
||||||
},
|
},
|
||||||
_ => None,
|
_ => None,
|
||||||
@ -1953,7 +1953,7 @@ impl ExplicitOutlivesRequirements {
|
|||||||
let is_inferred = match tcx.named_bound_var(lifetime.hir_id) {
|
let is_inferred = match tcx.named_bound_var(lifetime.hir_id) {
|
||||||
Some(ResolvedArg::EarlyBound(def_id)) => inferred_outlives
|
Some(ResolvedArg::EarlyBound(def_id)) => inferred_outlives
|
||||||
.iter()
|
.iter()
|
||||||
.any(|r| matches!(**r, ty::ReEarlyBound(ebr) if { ebr.def_id == def_id })),
|
.any(|r| matches!(**r, ty::ReEarlyParam(ebr) if { ebr.def_id == def_id })),
|
||||||
_ => false,
|
_ => false,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -64,8 +64,8 @@ impl<'tcx> UnifyValue for UnifiedRegion<'tcx> {
|
|||||||
cmp::min_by_key(r1, r2, |r| match r.kind() {
|
cmp::min_by_key(r1, r2, |r| match r.kind() {
|
||||||
ty::ReStatic
|
ty::ReStatic
|
||||||
| ty::ReErased
|
| ty::ReErased
|
||||||
| ty::ReFree(..)
|
| ty::ReLateParam(..)
|
||||||
| ty::ReEarlyBound(..)
|
| ty::ReEarlyParam(..)
|
||||||
| ty::ReError(_) => ty::UniverseIndex::ROOT,
|
| ty::ReError(_) => ty::UniverseIndex::ROOT,
|
||||||
ty::RePlaceholder(placeholder) => placeholder.universe,
|
ty::RePlaceholder(placeholder) => placeholder.universe,
|
||||||
ty::ReVar(..) | ty::ReBound(..) => bug!("not a universal region"),
|
ty::ReVar(..) | ty::ReBound(..) => bug!("not a universal region"),
|
||||||
|
@ -77,7 +77,7 @@ use std::ops::Deref;
|
|||||||
/// picture, but rather the ending point.
|
/// picture, but rather the ending point.
|
||||||
//
|
//
|
||||||
// FIXME(pnkfelix): this currently derives `PartialOrd` and `Ord` to
|
// FIXME(pnkfelix): this currently derives `PartialOrd` and `Ord` to
|
||||||
// placate the same deriving in `ty::FreeRegion`, but we may want to
|
// placate the same deriving in `ty::LateParamRegion`, but we may want to
|
||||||
// actually attach a more meaningful ordering to scopes than the one
|
// actually attach a more meaningful ordering to scopes than the one
|
||||||
// generated via deriving here.
|
// generated via deriving here.
|
||||||
#[derive(Clone, PartialEq, PartialOrd, Eq, Ord, Hash, Copy, TyEncodable, TyDecodable)]
|
#[derive(Clone, PartialEq, PartialOrd, Eq, Ord, Hash, Copy, TyEncodable, TyDecodable)]
|
||||||
|
@ -113,9 +113,9 @@ impl<'tcx> Interner for TyCtxt<'tcx> {
|
|||||||
type ExprConst = ty::Expr<'tcx>;
|
type ExprConst = ty::Expr<'tcx>;
|
||||||
|
|
||||||
type Region = Region<'tcx>;
|
type Region = Region<'tcx>;
|
||||||
type EarlyBoundRegion = ty::EarlyBoundRegion;
|
type EarlyParamRegion = ty::EarlyParamRegion;
|
||||||
type BoundRegion = ty::BoundRegion;
|
type BoundRegion = ty::BoundRegion;
|
||||||
type FreeRegion = ty::FreeRegion;
|
type LateParamRegion = ty::LateParamRegion;
|
||||||
type InferRegion = ty::RegionVid;
|
type InferRegion = ty::RegionVid;
|
||||||
type PlaceholderRegion = ty::PlaceholderRegion;
|
type PlaceholderRegion = ty::PlaceholderRegion;
|
||||||
|
|
||||||
@ -445,14 +445,14 @@ impl<'tcx> CommonConsts<'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This struct contains information regarding the `ReFree(FreeRegion)` corresponding to a lifetime
|
/// This struct contains information regarding a free parameter region,
|
||||||
/// conflict.
|
/// either a `ReEarlyParam` or `ReLateParam`.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct FreeRegionInfo {
|
pub struct FreeRegionInfo {
|
||||||
/// `LocalDefId` corresponding to FreeRegion
|
/// `LocalDefId` of the free region.
|
||||||
pub def_id: LocalDefId,
|
pub def_id: LocalDefId,
|
||||||
/// the bound region corresponding to FreeRegion
|
/// the bound region corresponding to free region.
|
||||||
pub boundregion: ty::BoundRegionKind,
|
pub bound_region: ty::BoundRegionKind,
|
||||||
/// checks if bound region is in Impl Item
|
/// checks if bound region is in Impl Item
|
||||||
pub is_impl_item: bool,
|
pub is_impl_item: bool,
|
||||||
}
|
}
|
||||||
@ -1080,8 +1080,8 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||||||
pub fn is_suitable_region(self, mut region: Region<'tcx>) -> Option<FreeRegionInfo> {
|
pub fn is_suitable_region(self, mut region: Region<'tcx>) -> Option<FreeRegionInfo> {
|
||||||
let (suitable_region_binding_scope, bound_region) = loop {
|
let (suitable_region_binding_scope, bound_region) = loop {
|
||||||
let def_id = match region.kind() {
|
let def_id = match region.kind() {
|
||||||
ty::ReFree(fr) => fr.bound_region.get_id()?.as_local()?,
|
ty::ReLateParam(fr) => fr.bound_region.get_id()?.as_local()?,
|
||||||
ty::ReEarlyBound(ebr) => ebr.def_id.expect_local(),
|
ty::ReEarlyParam(ebr) => ebr.def_id.expect_local(),
|
||||||
_ => return None, // not a free region
|
_ => return None, // not a free region
|
||||||
};
|
};
|
||||||
let scope = self.local_parent(def_id);
|
let scope = self.local_parent(def_id);
|
||||||
@ -1102,11 +1102,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||||||
_ => false,
|
_ => false,
|
||||||
};
|
};
|
||||||
|
|
||||||
Some(FreeRegionInfo {
|
Some(FreeRegionInfo { def_id: suitable_region_binding_scope, bound_region, is_impl_item })
|
||||||
def_id: suitable_region_binding_scope,
|
|
||||||
boundregion: bound_region,
|
|
||||||
is_impl_item,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Given a `DefId` for an `fn`, return all the `dyn` and `impl` traits in its return type.
|
/// Given a `DefId` for an `fn`, return all the `dyn` and `impl` traits in its return type.
|
||||||
@ -1743,7 +1739,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||||||
pub fn mk_param_from_def(self, param: &ty::GenericParamDef) -> GenericArg<'tcx> {
|
pub fn mk_param_from_def(self, param: &ty::GenericParamDef) -> GenericArg<'tcx> {
|
||||||
match param.kind {
|
match param.kind {
|
||||||
GenericParamDefKind::Lifetime => {
|
GenericParamDefKind::Lifetime => {
|
||||||
ty::Region::new_early_bound(self, param.to_early_bound_region_data()).into()
|
ty::Region::new_early_param(self, param.to_early_bound_region_data()).into()
|
||||||
}
|
}
|
||||||
GenericParamDefKind::Type { .. } => Ty::new_param(self, param.index, param.name).into(),
|
GenericParamDefKind::Type { .. } => Ty::new_param(self, param.index, param.name).into(),
|
||||||
GenericParamDefKind::Const { .. } => ty::Const::new_param(
|
GenericParamDefKind::Const { .. } => ty::Const::new_param(
|
||||||
@ -2040,7 +2036,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||||||
/// Given the def-id of an early-bound lifetime on an RPIT corresponding to
|
/// Given the def-id of an early-bound lifetime on an RPIT corresponding to
|
||||||
/// a duplicated captured lifetime, map it back to the early- or late-bound
|
/// a duplicated captured lifetime, map it back to the early- or late-bound
|
||||||
/// lifetime of the function from which it originally as captured. If it is
|
/// lifetime of the function from which it originally as captured. If it is
|
||||||
/// a late-bound lifetime, this will represent the liberated (`ReFree`) lifetime
|
/// a late-bound lifetime, this will represent the liberated (`ReLateParam`) lifetime
|
||||||
/// of the signature.
|
/// of the signature.
|
||||||
// FIXME(RPITIT): if we ever synthesize new lifetimes for RPITITs and not just
|
// FIXME(RPITIT): if we ever synthesize new lifetimes for RPITITs and not just
|
||||||
// re-use the generics of the opaque, this function will need to be tweaked slightly.
|
// re-use the generics of the opaque, this function will need to be tweaked slightly.
|
||||||
@ -2079,9 +2075,9 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let generics = self.generics_of(new_parent);
|
let generics = self.generics_of(new_parent);
|
||||||
return ty::Region::new_early_bound(
|
return ty::Region::new_early_param(
|
||||||
self,
|
self,
|
||||||
ty::EarlyBoundRegion {
|
ty::EarlyParamRegion {
|
||||||
def_id: ebv,
|
def_id: ebv,
|
||||||
index: generics
|
index: generics
|
||||||
.param_def_id_to_index(self, ebv)
|
.param_def_id_to_index(self, ebv)
|
||||||
@ -2092,7 +2088,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||||||
}
|
}
|
||||||
Some(resolve_bound_vars::ResolvedArg::LateBound(_, _, lbv)) => {
|
Some(resolve_bound_vars::ResolvedArg::LateBound(_, _, lbv)) => {
|
||||||
let new_parent = self.parent(lbv);
|
let new_parent = self.parent(lbv);
|
||||||
return ty::Region::new_free(
|
return ty::Region::new_late_param(
|
||||||
self,
|
self,
|
||||||
new_parent,
|
new_parent,
|
||||||
ty::BoundRegionKind::BrNamed(
|
ty::BoundRegionKind::BrNamed(
|
||||||
|
@ -326,7 +326,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||||||
T: TypeFoldable<TyCtxt<'tcx>>,
|
T: TypeFoldable<TyCtxt<'tcx>>,
|
||||||
{
|
{
|
||||||
self.replace_late_bound_regions_uncached(value, |br| {
|
self.replace_late_bound_regions_uncached(value, |br| {
|
||||||
ty::Region::new_free(self, all_outlive_scope, br.kind)
|
ty::Region::new_late_param(self, all_outlive_scope, br.kind)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -809,7 +809,7 @@ impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for ArgFolder<'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> {
|
||||||
#[cold]
|
#[cold]
|
||||||
#[inline(never)]
|
#[inline(never)]
|
||||||
fn region_param_out_of_range(data: ty::EarlyBoundRegion, args: &[GenericArg<'_>]) -> ! {
|
fn region_param_out_of_range(data: ty::EarlyParamRegion, args: &[GenericArg<'_>]) -> ! {
|
||||||
bug!(
|
bug!(
|
||||||
"Region parameter out of range when substituting in region {} (index={}, args = {:?})",
|
"Region parameter out of range when substituting in region {} (index={}, args = {:?})",
|
||||||
data.name,
|
data.name,
|
||||||
@ -820,7 +820,7 @@ impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for ArgFolder<'a, 'tcx> {
|
|||||||
|
|
||||||
#[cold]
|
#[cold]
|
||||||
#[inline(never)]
|
#[inline(never)]
|
||||||
fn region_param_invalid(data: ty::EarlyBoundRegion, other: GenericArgKind<'_>) -> ! {
|
fn region_param_invalid(data: ty::EarlyParamRegion, other: GenericArgKind<'_>) -> ! {
|
||||||
bug!(
|
bug!(
|
||||||
"Unexpected parameter {:?} when substituting in region {} (index={})",
|
"Unexpected parameter {:?} when substituting in region {} (index={})",
|
||||||
other,
|
other,
|
||||||
@ -835,7 +835,7 @@ impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for ArgFolder<'a, 'tcx> {
|
|||||||
// regions that appear in a function signature is done using
|
// regions that appear in a function signature is done using
|
||||||
// the specialized routine `ty::replace_late_regions()`.
|
// the specialized routine `ty::replace_late_regions()`.
|
||||||
match *r {
|
match *r {
|
||||||
ty::ReEarlyBound(data) => {
|
ty::ReEarlyParam(data) => {
|
||||||
let rk = self.args.get(data.index as usize).map(|k| k.unpack());
|
let rk = self.args.get(data.index as usize).map(|k| k.unpack());
|
||||||
match rk {
|
match rk {
|
||||||
Some(GenericArgKind::Lifetime(lt)) => self.shift_region_through_binders(lt),
|
Some(GenericArgKind::Lifetime(lt)) => self.shift_region_through_binders(lt),
|
||||||
@ -844,7 +844,7 @@ impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for ArgFolder<'a, 'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
ty::ReBound(..)
|
ty::ReBound(..)
|
||||||
| ty::ReFree(_)
|
| ty::ReLateParam(_)
|
||||||
| ty::ReStatic
|
| ty::ReStatic
|
||||||
| ty::RePlaceholder(_)
|
| ty::RePlaceholder(_)
|
||||||
| ty::ReErased
|
| ty::ReErased
|
||||||
|
@ -6,7 +6,7 @@ use rustc_hir::def_id::DefId;
|
|||||||
use rustc_span::symbol::{kw, Symbol};
|
use rustc_span::symbol::{kw, Symbol};
|
||||||
use rustc_span::Span;
|
use rustc_span::Span;
|
||||||
|
|
||||||
use super::{Clause, EarlyBoundRegion, InstantiatedPredicates, ParamConst, ParamTy, Ty, TyCtxt};
|
use super::{Clause, InstantiatedPredicates, ParamConst, ParamTy, Ty, TyCtxt};
|
||||||
|
|
||||||
#[derive(Clone, Debug, TyEncodable, TyDecodable, HashStable)]
|
#[derive(Clone, Debug, TyEncodable, TyDecodable, HashStable)]
|
||||||
pub enum GenericParamDefKind {
|
pub enum GenericParamDefKind {
|
||||||
@ -62,9 +62,9 @@ pub struct GenericParamDef {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl GenericParamDef {
|
impl GenericParamDef {
|
||||||
pub fn to_early_bound_region_data(&self) -> ty::EarlyBoundRegion {
|
pub fn to_early_bound_region_data(&self) -> ty::EarlyParamRegion {
|
||||||
if let GenericParamDefKind::Lifetime = self.kind {
|
if let GenericParamDefKind::Lifetime = self.kind {
|
||||||
ty::EarlyBoundRegion { def_id: self.def_id, index: self.index, name: self.name }
|
ty::EarlyParamRegion { def_id: self.def_id, index: self.index, name: self.name }
|
||||||
} else {
|
} else {
|
||||||
bug!("cannot convert a non-lifetime parameter def to an early bound region")
|
bug!("cannot convert a non-lifetime parameter def to an early bound region")
|
||||||
}
|
}
|
||||||
@ -260,10 +260,10 @@ impl<'tcx> Generics {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the `GenericParamDef` associated with this `EarlyBoundRegion`.
|
/// Returns the `GenericParamDef` associated with this `EarlyParamRegion`.
|
||||||
pub fn region_param(
|
pub fn region_param(
|
||||||
&'tcx self,
|
&'tcx self,
|
||||||
param: &EarlyBoundRegion,
|
param: &ty::EarlyParamRegion,
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
) -> &'tcx GenericParamDef {
|
) -> &'tcx GenericParamDef {
|
||||||
let param = self.param_at(param.index as usize, tcx);
|
let param = self.param_at(param.index as usize, tcx);
|
||||||
|
@ -98,11 +98,12 @@ pub use self::sty::BoundRegionKind::*;
|
|||||||
pub use self::sty::{
|
pub use self::sty::{
|
||||||
AliasTy, Article, Binder, BoundRegion, BoundRegionKind, BoundTy, BoundTyKind, BoundVar,
|
AliasTy, Article, Binder, BoundRegion, BoundRegionKind, BoundTy, BoundTyKind, BoundVar,
|
||||||
BoundVariableKind, CanonicalPolyFnSig, ClauseKind, ClosureArgs, ClosureArgsParts, ConstKind,
|
BoundVariableKind, CanonicalPolyFnSig, ClauseKind, ClosureArgs, ClosureArgsParts, ConstKind,
|
||||||
ConstVid, CoroutineArgs, CoroutineArgsParts, EarlyBoundRegion, EffectVid, ExistentialPredicate,
|
ConstVid, CoroutineArgs, CoroutineArgsParts, EarlyParamRegion, EffectVid, ExistentialPredicate,
|
||||||
ExistentialProjection, ExistentialTraitRef, FnSig, FreeRegion, GenSig, InlineConstArgs,
|
ExistentialProjection, ExistentialTraitRef, FnSig, GenSig, InlineConstArgs,
|
||||||
InlineConstArgsParts, ParamConst, ParamTy, PolyExistentialPredicate, PolyExistentialProjection,
|
InlineConstArgsParts, LateParamRegion, ParamConst, ParamTy, PolyExistentialPredicate,
|
||||||
PolyExistentialTraitRef, PolyFnSig, PolyGenSig, PolyTraitRef, PredicateKind, Region,
|
PolyExistentialProjection, PolyExistentialTraitRef, PolyFnSig, PolyGenSig, PolyTraitRef,
|
||||||
RegionKind, RegionVid, TraitRef, TyKind, TypeAndMut, UpvarArgs, VarianceDiagInfo,
|
PredicateKind, Region, RegionKind, RegionVid, TraitRef, TyKind, TypeAndMut, UpvarArgs,
|
||||||
|
VarianceDiagInfo,
|
||||||
};
|
};
|
||||||
pub use self::trait_def::TraitDef;
|
pub use self::trait_def::TraitDef;
|
||||||
pub use self::typeck_results::{
|
pub use self::typeck_results::{
|
||||||
@ -463,7 +464,7 @@ pub struct CReaderCacheKey {
|
|||||||
#[rustc_pass_by_value]
|
#[rustc_pass_by_value]
|
||||||
pub struct Ty<'tcx>(Interned<'tcx, WithCachedTypeInfo<TyKind<'tcx>>>);
|
pub struct Ty<'tcx>(Interned<'tcx, WithCachedTypeInfo<TyKind<'tcx>>>);
|
||||||
|
|
||||||
impl ty::EarlyBoundRegion {
|
impl EarlyParamRegion {
|
||||||
/// Does this early bound region have a name? Early bound regions normally
|
/// Does this early bound region have a name? Early bound regions normally
|
||||||
/// always have names except when using anonymous lifetimes (`'_`).
|
/// always have names except when using anonymous lifetimes (`'_`).
|
||||||
pub fn has_name(&self) -> bool {
|
pub fn has_name(&self) -> bool {
|
||||||
|
@ -113,7 +113,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ReverseMapper<'tcx> {
|
|||||||
ty::ReError(_) => return r,
|
ty::ReError(_) => return r,
|
||||||
|
|
||||||
// The regions that we expect from borrow checking.
|
// The regions that we expect from borrow checking.
|
||||||
ty::ReEarlyBound(_) | ty::ReFree(_) => {}
|
ty::ReEarlyParam(_) | ty::ReLateParam(_) => {}
|
||||||
|
|
||||||
ty::RePlaceholder(_) | ty::ReVar(_) => {
|
ty::RePlaceholder(_) | ty::ReVar(_) => {
|
||||||
// All of the regions in the type should either have been
|
// All of the regions in the type should either have been
|
||||||
|
@ -2158,10 +2158,10 @@ impl<'tcx> PrettyPrinter<'tcx> for FmtPrinter<'_, 'tcx> {
|
|||||||
let identify_regions = self.tcx.sess.opts.unstable_opts.identify_regions;
|
let identify_regions = self.tcx.sess.opts.unstable_opts.identify_regions;
|
||||||
|
|
||||||
match *region {
|
match *region {
|
||||||
ty::ReEarlyBound(ref data) => data.has_name(),
|
ty::ReEarlyParam(ref data) => data.has_name(),
|
||||||
|
|
||||||
ty::ReBound(_, ty::BoundRegion { kind: br, .. })
|
ty::ReBound(_, ty::BoundRegion { kind: br, .. })
|
||||||
| ty::ReFree(ty::FreeRegion { bound_region: br, .. })
|
| ty::ReLateParam(ty::LateParamRegion { bound_region: br, .. })
|
||||||
| ty::RePlaceholder(ty::Placeholder {
|
| ty::RePlaceholder(ty::Placeholder {
|
||||||
bound: ty::BoundRegion { kind: br, .. }, ..
|
bound: ty::BoundRegion { kind: br, .. }, ..
|
||||||
}) => {
|
}) => {
|
||||||
@ -2228,14 +2228,14 @@ impl<'tcx> FmtPrinter<'_, 'tcx> {
|
|||||||
// to fit that into a short string. Hence the recommendation to use
|
// to fit that into a short string. Hence the recommendation to use
|
||||||
// `explain_region()` or `note_and_explain_region()`.
|
// `explain_region()` or `note_and_explain_region()`.
|
||||||
match *region {
|
match *region {
|
||||||
ty::ReEarlyBound(ref data) => {
|
ty::ReEarlyParam(ref data) => {
|
||||||
if data.name != kw::Empty {
|
if data.name != kw::Empty {
|
||||||
p!(write("{}", data.name));
|
p!(write("{}", data.name));
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ty::ReBound(_, ty::BoundRegion { kind: br, .. })
|
ty::ReBound(_, ty::BoundRegion { kind: br, .. })
|
||||||
| ty::ReFree(ty::FreeRegion { bound_region: br, .. })
|
| ty::ReLateParam(ty::LateParamRegion { bound_region: br, .. })
|
||||||
| ty::RePlaceholder(ty::Placeholder {
|
| ty::RePlaceholder(ty::Placeholder {
|
||||||
bound: ty::BoundRegion { kind: br, .. }, ..
|
bound: ty::BoundRegion { kind: br, .. }, ..
|
||||||
}) => {
|
}) => {
|
||||||
|
@ -79,9 +79,9 @@ impl fmt::Debug for ty::BoundRegionKind {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Debug for ty::FreeRegion {
|
impl fmt::Debug for ty::LateParamRegion {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
write!(f, "ReFree({:?}, {:?})", self.scope, self.bound_region)
|
write!(f, "ReLateParam({:?}, {:?})", self.scope, self.bound_region)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -444,7 +444,7 @@ TrivialTypeTraversalImpls! {
|
|||||||
crate::ty::Placeholder<crate::ty::BoundRegion>,
|
crate::ty::Placeholder<crate::ty::BoundRegion>,
|
||||||
crate::ty::Placeholder<crate::ty::BoundTy>,
|
crate::ty::Placeholder<crate::ty::BoundTy>,
|
||||||
crate::ty::Placeholder<ty::BoundVar>,
|
crate::ty::Placeholder<ty::BoundVar>,
|
||||||
crate::ty::FreeRegion,
|
crate::ty::LateParamRegion,
|
||||||
crate::ty::InferTy,
|
crate::ty::InferTy,
|
||||||
crate::ty::IntVarValue,
|
crate::ty::IntVarValue,
|
||||||
crate::ty::adjustment::PointerCoercion,
|
crate::ty::adjustment::PointerCoercion,
|
||||||
|
@ -61,9 +61,9 @@ pub struct TypeAndMut<'tcx> {
|
|||||||
|
|
||||||
#[derive(Clone, PartialEq, PartialOrd, Eq, Ord, Hash, TyEncodable, TyDecodable, Copy)]
|
#[derive(Clone, PartialEq, PartialOrd, Eq, Ord, Hash, TyEncodable, TyDecodable, Copy)]
|
||||||
#[derive(HashStable)]
|
#[derive(HashStable)]
|
||||||
/// A "free" region `fr` can be interpreted as "some region
|
/// The parameter representation of late-bound function parameters, "some region
|
||||||
/// at least as big as the scope `fr.scope`".
|
/// at least as big as the scope `fr.scope`".
|
||||||
pub struct FreeRegion {
|
pub struct LateParamRegion {
|
||||||
pub scope: DefId,
|
pub scope: DefId,
|
||||||
pub bound_region: BoundRegionKind,
|
pub bound_region: BoundRegionKind,
|
||||||
}
|
}
|
||||||
@ -1468,11 +1468,11 @@ pub struct Region<'tcx>(pub Interned<'tcx, RegionKind<'tcx>>);
|
|||||||
|
|
||||||
impl<'tcx> Region<'tcx> {
|
impl<'tcx> Region<'tcx> {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn new_early_bound(
|
pub fn new_early_param(
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
early_bound_region: ty::EarlyBoundRegion,
|
early_bound_region: ty::EarlyParamRegion,
|
||||||
) -> Region<'tcx> {
|
) -> Region<'tcx> {
|
||||||
tcx.intern_region(ty::ReEarlyBound(early_bound_region))
|
tcx.intern_region(ty::ReEarlyParam(early_bound_region))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
@ -1493,12 +1493,12 @@ impl<'tcx> Region<'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn new_free(
|
pub fn new_late_param(
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
scope: DefId,
|
scope: DefId,
|
||||||
bound_region: ty::BoundRegionKind,
|
bound_region: ty::BoundRegionKind,
|
||||||
) -> Region<'tcx> {
|
) -> Region<'tcx> {
|
||||||
tcx.intern_region(ty::ReFree(ty::FreeRegion { scope, bound_region }))
|
tcx.intern_region(ty::ReLateParam(ty::LateParamRegion { scope, bound_region }))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
@ -1549,10 +1549,10 @@ impl<'tcx> Region<'tcx> {
|
|||||||
/// to avoid the cost of the `match`.
|
/// to avoid the cost of the `match`.
|
||||||
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::ReEarlyParam(region) => Region::new_early_param(tcx, region),
|
||||||
ty::ReBound(debruijn, region) => Region::new_bound(tcx, debruijn, region),
|
ty::ReBound(debruijn, region) => Region::new_bound(tcx, debruijn, region),
|
||||||
ty::ReFree(ty::FreeRegion { scope, bound_region }) => {
|
ty::ReLateParam(ty::LateParamRegion { scope, bound_region }) => {
|
||||||
Region::new_free(tcx, scope, bound_region)
|
Region::new_late_param(tcx, scope, bound_region)
|
||||||
}
|
}
|
||||||
ty::ReStatic => tcx.lifetimes.re_static,
|
ty::ReStatic => tcx.lifetimes.re_static,
|
||||||
ty::ReVar(vid) => Region::new_var(tcx, vid),
|
ty::ReVar(vid) => Region::new_var(tcx, vid),
|
||||||
@ -1574,13 +1574,13 @@ impl<'tcx> Deref for Region<'tcx> {
|
|||||||
|
|
||||||
#[derive(Copy, Clone, PartialEq, Eq, Hash, TyEncodable, TyDecodable, PartialOrd, Ord)]
|
#[derive(Copy, Clone, PartialEq, Eq, Hash, TyEncodable, TyDecodable, PartialOrd, Ord)]
|
||||||
#[derive(HashStable)]
|
#[derive(HashStable)]
|
||||||
pub struct EarlyBoundRegion {
|
pub struct EarlyParamRegion {
|
||||||
pub def_id: DefId,
|
pub def_id: DefId,
|
||||||
pub index: u32,
|
pub index: u32,
|
||||||
pub name: Symbol,
|
pub name: Symbol,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Debug for EarlyBoundRegion {
|
impl fmt::Debug for EarlyParamRegion {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
write!(f, "{:?}, {}, {}", self.def_id, self.index, self.name)
|
write!(f, "{:?}, {}, {}", self.def_id, self.index, self.name)
|
||||||
}
|
}
|
||||||
@ -1722,9 +1722,9 @@ impl<'tcx> Region<'tcx> {
|
|||||||
pub fn get_name(self) -> Option<Symbol> {
|
pub fn get_name(self) -> Option<Symbol> {
|
||||||
if self.has_name() {
|
if self.has_name() {
|
||||||
match *self {
|
match *self {
|
||||||
ty::ReEarlyBound(ebr) => Some(ebr.name),
|
ty::ReEarlyParam(ebr) => Some(ebr.name),
|
||||||
ty::ReBound(_, br) => br.kind.get_name(),
|
ty::ReBound(_, br) => br.kind.get_name(),
|
||||||
ty::ReFree(fr) => fr.bound_region.get_name(),
|
ty::ReLateParam(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(),
|
||||||
_ => None,
|
_ => None,
|
||||||
@ -1744,9 +1744,9 @@ impl<'tcx> Region<'tcx> {
|
|||||||
/// Is this region named by the user?
|
/// Is this region named by the user?
|
||||||
pub fn has_name(self) -> bool {
|
pub fn has_name(self) -> bool {
|
||||||
match *self {
|
match *self {
|
||||||
ty::ReEarlyBound(ebr) => ebr.has_name(),
|
ty::ReEarlyParam(ebr) => ebr.has_name(),
|
||||||
ty::ReBound(_, br) => br.kind.is_named(),
|
ty::ReBound(_, br) => br.kind.is_named(),
|
||||||
ty::ReFree(fr) => fr.bound_region.is_named(),
|
ty::ReLateParam(fr) => fr.bound_region.is_named(),
|
||||||
ty::ReStatic => true,
|
ty::ReStatic => true,
|
||||||
ty::ReVar(..) => false,
|
ty::ReVar(..) => false,
|
||||||
ty::RePlaceholder(placeholder) => placeholder.bound.kind.is_named(),
|
ty::RePlaceholder(placeholder) => placeholder.bound.kind.is_named(),
|
||||||
@ -1802,12 +1802,12 @@ impl<'tcx> Region<'tcx> {
|
|||||||
flags = flags | TypeFlags::HAS_FREE_LOCAL_REGIONS;
|
flags = flags | TypeFlags::HAS_FREE_LOCAL_REGIONS;
|
||||||
flags = flags | TypeFlags::HAS_RE_PLACEHOLDER;
|
flags = flags | TypeFlags::HAS_RE_PLACEHOLDER;
|
||||||
}
|
}
|
||||||
ty::ReEarlyBound(..) => {
|
ty::ReEarlyParam(..) => {
|
||||||
flags = flags | TypeFlags::HAS_FREE_REGIONS;
|
flags = flags | TypeFlags::HAS_FREE_REGIONS;
|
||||||
flags = flags | TypeFlags::HAS_FREE_LOCAL_REGIONS;
|
flags = flags | TypeFlags::HAS_FREE_LOCAL_REGIONS;
|
||||||
flags = flags | TypeFlags::HAS_RE_PARAM;
|
flags = flags | TypeFlags::HAS_RE_PARAM;
|
||||||
}
|
}
|
||||||
ty::ReFree { .. } => {
|
ty::ReLateParam { .. } => {
|
||||||
flags = flags | TypeFlags::HAS_FREE_REGIONS;
|
flags = flags | TypeFlags::HAS_FREE_REGIONS;
|
||||||
flags = flags | TypeFlags::HAS_FREE_LOCAL_REGIONS;
|
flags = flags | TypeFlags::HAS_FREE_LOCAL_REGIONS;
|
||||||
}
|
}
|
||||||
@ -1851,22 +1851,28 @@ impl<'tcx> Region<'tcx> {
|
|||||||
/// function might return the `DefId` of a closure.
|
/// function might return the `DefId` of a closure.
|
||||||
pub fn free_region_binding_scope(self, tcx: TyCtxt<'_>) -> DefId {
|
pub fn free_region_binding_scope(self, tcx: TyCtxt<'_>) -> DefId {
|
||||||
match *self {
|
match *self {
|
||||||
ty::ReEarlyBound(br) => tcx.parent(br.def_id),
|
ty::ReEarlyParam(br) => tcx.parent(br.def_id),
|
||||||
ty::ReFree(fr) => fr.scope,
|
ty::ReLateParam(fr) => fr.scope,
|
||||||
_ => bug!("free_region_binding_scope invoked on inappropriate region: {:?}", self),
|
_ => bug!("free_region_binding_scope invoked on inappropriate region: {:?}", self),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// True for free regions other than `'static`.
|
/// True for free regions other than `'static`.
|
||||||
pub fn is_free(self) -> bool {
|
pub fn is_param(self) -> bool {
|
||||||
matches!(*self, ty::ReEarlyBound(_) | ty::ReFree(_))
|
matches!(*self, ty::ReEarlyParam(_) | ty::ReLateParam(_))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// True if `self` is a free region or static.
|
/// True for free region in the current context.
|
||||||
pub fn is_free_or_static(self) -> bool {
|
///
|
||||||
|
/// This is the case for `'static` and param regions.
|
||||||
|
pub fn is_free(self) -> bool {
|
||||||
match *self {
|
match *self {
|
||||||
ty::ReStatic => true,
|
ty::ReStatic | ty::ReEarlyParam(..) | ty::ReLateParam(..) => true,
|
||||||
_ => self.is_free(),
|
ty::ReVar(..)
|
||||||
|
| ty::RePlaceholder(..)
|
||||||
|
| ty::ReBound(..)
|
||||||
|
| ty::ReErased
|
||||||
|
| ty::ReError(..) => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,7 +126,7 @@ pub struct TypeckResults<'tcx> {
|
|||||||
/// fn(&'a u32) -> u32
|
/// fn(&'a u32) -> u32
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// Note that `'a` is not bound (it would be an `ReFree`) and
|
/// Note that `'a` is not bound (it would be an `ReLateParam`) and
|
||||||
/// that the `Foo` opaque type is replaced by its hidden type.
|
/// that the `Foo` opaque type is replaced by its hidden type.
|
||||||
liberated_fn_sigs: ItemLocalMap<ty::FnSig<'tcx>>,
|
liberated_fn_sigs: ItemLocalMap<ty::FnSig<'tcx>>,
|
||||||
|
|
||||||
|
@ -35,12 +35,14 @@ pub struct Discr<'tcx> {
|
|||||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||||
pub enum CheckRegions {
|
pub enum CheckRegions {
|
||||||
No,
|
No,
|
||||||
/// Only permit early bound regions. This is useful for Adts which
|
/// Only permit parameter regions. This should be used
|
||||||
/// can never have late bound regions.
|
/// for everything apart from functions, which may use
|
||||||
OnlyEarlyBound,
|
/// `ReBound` to represent late-bound regions.
|
||||||
/// Permit both late bound and early bound regions. Use this for functions,
|
OnlyParam,
|
||||||
/// which frequently have late bound regions.
|
/// Check region parameters from a function definition.
|
||||||
Bound,
|
/// Allows `ReEarlyParam` and `ReBound` to handle early
|
||||||
|
/// and late-bound region parameters.
|
||||||
|
FromFunction,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug)]
|
#[derive(Copy, Clone, Debug)]
|
||||||
@ -431,7 +433,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||||||
.filter(|&(_, k)| {
|
.filter(|&(_, k)| {
|
||||||
match k.unpack() {
|
match k.unpack() {
|
||||||
GenericArgKind::Lifetime(region) => match region.kind() {
|
GenericArgKind::Lifetime(region) => match region.kind() {
|
||||||
ty::ReEarlyBound(ref ebr) => {
|
ty::ReEarlyParam(ref ebr) => {
|
||||||
!impl_generics.region_param(ebr, self).pure_wrt_drop
|
!impl_generics.region_param(ebr, self).pure_wrt_drop
|
||||||
}
|
}
|
||||||
// Error: not a region param
|
// Error: not a region param
|
||||||
@ -468,17 +470,17 @@ 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::ReBound(di, reg)) => {
|
(CheckRegions::FromFunction, 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()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(CheckRegions::OnlyEarlyBound | CheckRegions::Bound, ty::ReEarlyBound(p)) => {
|
(CheckRegions::OnlyParam | CheckRegions::FromFunction, ty::ReEarlyParam(p)) => {
|
||||||
if !seen.insert(p.index) {
|
if !seen.insert(p.index) {
|
||||||
return Err(NotUniqueParam::DuplicateParam(lt.into()));
|
return Err(NotUniqueParam::DuplicateParam(lt.into()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(CheckRegions::OnlyEarlyBound | CheckRegions::Bound, _) => {
|
(CheckRegions::OnlyParam | CheckRegions::FromFunction, _) => {
|
||||||
return Err(NotUniqueParam::NotParam(lt.into()));
|
return Err(NotUniqueParam::NotParam(lt.into()));
|
||||||
}
|
}
|
||||||
(CheckRegions::No, _) => {}
|
(CheckRegions::No, _) => {}
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
use crate::rustc_internal::{IndexMap, RustcInternal};
|
use crate::rustc_internal::{IndexMap, RustcInternal};
|
||||||
use crate::rustc_smir::hir::def::DefKind;
|
use crate::rustc_smir::hir::def::DefKind;
|
||||||
use crate::rustc_smir::stable_mir::ty::{BoundRegion, EarlyBoundRegion, Region};
|
use crate::rustc_smir::stable_mir::ty::{BoundRegion, EarlyParamRegion, Region};
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_middle::mir;
|
use rustc_middle::mir;
|
||||||
use rustc_middle::mir::interpret::{alloc_range, AllocId};
|
use rustc_middle::mir::interpret::{alloc_range, AllocId};
|
||||||
@ -1729,7 +1729,7 @@ impl<'tcx> Stable<'tcx> for ty::RegionKind<'tcx> {
|
|||||||
fn stable(&self, tables: &mut Tables<'tcx>) -> Self::T {
|
fn stable(&self, tables: &mut Tables<'tcx>) -> Self::T {
|
||||||
use stable_mir::ty::RegionKind;
|
use stable_mir::ty::RegionKind;
|
||||||
match self {
|
match self {
|
||||||
ty::ReEarlyBound(early_reg) => RegionKind::ReEarlyBound(EarlyBoundRegion {
|
ty::ReEarlyParam(early_reg) => RegionKind::ReEarlyParam(EarlyParamRegion {
|
||||||
def_id: tables.region_def(early_reg.def_id),
|
def_id: tables.region_def(early_reg.def_id),
|
||||||
index: early_reg.index,
|
index: early_reg.index,
|
||||||
name: early_reg.name.to_string(),
|
name: early_reg.name.to_string(),
|
||||||
|
@ -282,12 +282,12 @@ 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.
|
// FIXME(@lcnr): Why is `ReEarlyParam` reachable here.
|
||||||
RegionKind::ReEarlyBound(..) | RegionKind::ReErased => {
|
RegionKind::ReEarlyParam(..) | RegionKind::ReErased => {
|
||||||
s.push_str("u6region");
|
s.push_str("u6region");
|
||||||
compress(dict, DictKey::Region(region), &mut s);
|
compress(dict, DictKey::Region(region), &mut s);
|
||||||
}
|
}
|
||||||
RegionKind::ReFree(..)
|
RegionKind::ReLateParam(..)
|
||||||
| RegionKind::ReStatic
|
| RegionKind::ReStatic
|
||||||
| RegionKind::ReError(_)
|
| RegionKind::ReError(_)
|
||||||
| RegionKind::ReVar(..)
|
| RegionKind::ReVar(..)
|
||||||
|
@ -237,7 +237,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for Canonicalizer<'_, 'tcx> {
|
|||||||
CanonicalizeMode::Response { .. } => return r,
|
CanonicalizeMode::Response { .. } => return r,
|
||||||
},
|
},
|
||||||
|
|
||||||
ty::ReFree(_) | ty::ReEarlyBound(_) => match self.canonicalize_mode {
|
ty::ReLateParam(_) | ty::ReEarlyParam(_) => match self.canonicalize_mode {
|
||||||
CanonicalizeMode::Input => CanonicalVarKind::Region(ty::UniverseIndex::ROOT),
|
CanonicalizeMode::Input => CanonicalVarKind::Region(ty::UniverseIndex::ROOT),
|
||||||
CanonicalizeMode::Response { .. } => bug!("unexpected region in response: {r:?}"),
|
CanonicalizeMode::Response { .. } => bug!("unexpected region in response: {r:?}"),
|
||||||
},
|
},
|
||||||
|
@ -484,7 +484,7 @@ fn is_impossible_associated_item(
|
|||||||
t.super_visit_with(self)
|
t.super_visit_with(self)
|
||||||
}
|
}
|
||||||
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::ReEarlyBound(param) = r.kind()
|
if let ty::ReEarlyParam(param) = r.kind()
|
||||||
&& let param_def_id = self.generics.region_param(¶m, self.tcx).def_id
|
&& let param_def_id = self.generics.region_param(¶m, self.tcx).def_id
|
||||||
&& self.tcx.parent(param_def_id) == self.trait_item_def_id
|
&& self.tcx.parent(param_def_id) == self.trait_item_def_id
|
||||||
{
|
{
|
||||||
|
@ -54,8 +54,8 @@ fn assumed_wf_types<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> &'tcx [(Ty<'
|
|||||||
match data {
|
match data {
|
||||||
ty::ImplTraitInTraitData::Trait { fn_def_id, .. } => {
|
ty::ImplTraitInTraitData::Trait { fn_def_id, .. } => {
|
||||||
// We need to remap all of the late-bound lifetimes in the assumed wf types
|
// We need to remap all of the late-bound lifetimes in the assumed wf types
|
||||||
// of the fn (which are represented as ReFree) to the early-bound lifetimes
|
// of the fn (which are represented as ReLateParam) to the early-bound lifetimes
|
||||||
// of the RPITIT (which are represented by ReEarlyBound owned by the opaque).
|
// of the RPITIT (which are represented by ReEarlyParam owned by the opaque).
|
||||||
// Luckily, this is very easy to do because we already have that mapping
|
// Luckily, this is very easy to do because we already have that mapping
|
||||||
// stored in the HIR of this RPITIT.
|
// stored in the HIR of this RPITIT.
|
||||||
//
|
//
|
||||||
@ -65,19 +65,19 @@ fn assumed_wf_types<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> &'tcx [(Ty<'
|
|||||||
let mut mapping = FxHashMap::default();
|
let mut mapping = FxHashMap::default();
|
||||||
let generics = tcx.generics_of(def_id);
|
let generics = tcx.generics_of(def_id);
|
||||||
|
|
||||||
// For each captured opaque lifetime, if it's late-bound (`ReFree` in this case,
|
// For each captured opaque lifetime, if it's late-bound (`ReLateParam` in this
|
||||||
// since it has been liberated), map it back to the early-bound lifetime of
|
// case, since it has been liberated), map it back to the early-bound lifetime of
|
||||||
// the GAT. Since RPITITs also have all of the fn's generics, we slice only
|
// the GAT. Since RPITITs also have all of the fn's generics, we slice only
|
||||||
// the end of the list corresponding to the opaque's generics.
|
// the end of the list corresponding to the opaque's generics.
|
||||||
for param in &generics.params[tcx.generics_of(fn_def_id).params.len()..] {
|
for param in &generics.params[tcx.generics_of(fn_def_id).params.len()..] {
|
||||||
let orig_lt =
|
let orig_lt =
|
||||||
tcx.map_rpit_lifetime_to_fn_lifetime(param.def_id.expect_local());
|
tcx.map_rpit_lifetime_to_fn_lifetime(param.def_id.expect_local());
|
||||||
if matches!(*orig_lt, ty::ReFree(..)) {
|
if matches!(*orig_lt, ty::ReLateParam(..)) {
|
||||||
mapping.insert(
|
mapping.insert(
|
||||||
orig_lt,
|
orig_lt,
|
||||||
ty::Region::new_early_bound(
|
ty::Region::new_early_param(
|
||||||
tcx,
|
tcx,
|
||||||
ty::EarlyBoundRegion {
|
ty::EarlyParamRegion {
|
||||||
def_id: param.def_id,
|
def_id: param.def_id,
|
||||||
index: param.index,
|
index: param.index,
|
||||||
name: param.name,
|
name: param.name,
|
||||||
@ -90,7 +90,7 @@ fn assumed_wf_types<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> &'tcx [(Ty<'
|
|||||||
let remapped_wf_tys = tcx.fold_regions(
|
let remapped_wf_tys = tcx.fold_regions(
|
||||||
tcx.assumed_wf_types(fn_def_id.expect_local()).to_vec(),
|
tcx.assumed_wf_types(fn_def_id.expect_local()).to_vec(),
|
||||||
|region, _| {
|
|region, _| {
|
||||||
// If `region` is a `ReFree` that is captured by the
|
// If `region` is a `ReLateParam` that is captured by the
|
||||||
// opaque, remap it to its corresponding the early-
|
// opaque, remap it to its corresponding the early-
|
||||||
// bound region.
|
// bound region.
|
||||||
if let Some(remapped_region) = mapping.get(®ion) {
|
if let Some(remapped_region) = mapping.get(®ion) {
|
||||||
|
@ -159,10 +159,10 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for OpaqueTypeCollector<'tcx> {
|
|||||||
// Only check that the parent generics of the TAIT/RPIT are unique.
|
// Only check that the parent generics of the TAIT/RPIT are unique.
|
||||||
// the args owned by the opaque are going to always be duplicate
|
// the args owned by the opaque are going to always be duplicate
|
||||||
// lifetime params for RPITs, and empty for TAITs.
|
// lifetime params for RPITs, and empty for TAITs.
|
||||||
match self
|
match self.tcx.uses_unique_generic_params(
|
||||||
.tcx
|
&alias_ty.args[..parent_count],
|
||||||
.uses_unique_generic_params(&alias_ty.args[..parent_count], CheckRegions::Bound)
|
CheckRegions::FromFunction,
|
||||||
{
|
) {
|
||||||
Ok(()) => {
|
Ok(()) => {
|
||||||
// FIXME: implement higher kinded lifetime bounds on nested opaque types. They are not
|
// FIXME: implement higher kinded lifetime bounds on nested opaque types. They are not
|
||||||
// supported at all, so this is sound to do, but once we want to support them, you'll
|
// supported at all, so this is sound to do, but once we want to support them, you'll
|
||||||
|
@ -8,7 +8,7 @@ bitflags! {
|
|||||||
// required.
|
// required.
|
||||||
/// Does this have `Param`?
|
/// Does this have `Param`?
|
||||||
const HAS_TY_PARAM = 1 << 0;
|
const HAS_TY_PARAM = 1 << 0;
|
||||||
/// Does this have `ReEarlyBound`?
|
/// Does this have `ReEarlyParam`?
|
||||||
const HAS_RE_PARAM = 1 << 1;
|
const HAS_RE_PARAM = 1 << 1;
|
||||||
/// Does this have `ConstKind::Param`?
|
/// Does this have `ConstKind::Param`?
|
||||||
const HAS_CT_PARAM = 1 << 2;
|
const HAS_CT_PARAM = 1 << 2;
|
||||||
|
@ -47,9 +47,9 @@ pub trait Interner: Sized {
|
|||||||
|
|
||||||
// Kinds of regions
|
// Kinds of regions
|
||||||
type Region: Clone + DebugWithInfcx<Self> + Hash + Ord;
|
type Region: Clone + DebugWithInfcx<Self> + Hash + Ord;
|
||||||
type EarlyBoundRegion: Clone + Debug + Hash + Ord;
|
type EarlyParamRegion: Clone + Debug + Hash + Ord;
|
||||||
type BoundRegion: Clone + Debug + Hash + Ord;
|
type BoundRegion: Clone + Debug + Hash + Ord;
|
||||||
type FreeRegion: Clone + Debug + Hash + Ord;
|
type LateParamRegion: Clone + Debug + Hash + Ord;
|
||||||
type InferRegion: Clone + DebugWithInfcx<Self> + Hash + Ord;
|
type InferRegion: Clone + DebugWithInfcx<Self> + Hash + Ord;
|
||||||
type PlaceholderRegion: Clone + Debug + Hash + Ord;
|
type PlaceholderRegion: Clone + Debug + Hash + Ord;
|
||||||
|
|
||||||
|
@ -22,8 +22,8 @@ use self::RegionKind::*;
|
|||||||
/// ```text
|
/// ```text
|
||||||
/// static ----------+-----...------+ (greatest)
|
/// static ----------+-----...------+ (greatest)
|
||||||
/// | | |
|
/// | | |
|
||||||
/// early-bound and | |
|
/// param regions | |
|
||||||
/// free regions | |
|
/// | | |
|
||||||
/// | | |
|
/// | | |
|
||||||
/// | | |
|
/// | | |
|
||||||
/// empty(root) placeholder(U1) |
|
/// empty(root) placeholder(U1) |
|
||||||
@ -88,8 +88,8 @@ use self::RegionKind::*;
|
|||||||
/// To do this, we replace the bound regions with placeholder markers,
|
/// To do this, we replace the bound regions with placeholder markers,
|
||||||
/// which don't satisfy any relation not explicitly provided.
|
/// which don't satisfy any relation not explicitly provided.
|
||||||
///
|
///
|
||||||
/// There are two kinds of placeholder regions in rustc: `ReFree` and
|
/// There are two kinds of placeholder regions in rustc: `ReLateParam` and
|
||||||
/// `RePlaceholder`. When checking an item's body, `ReFree` is supposed
|
/// `RePlaceholder`. When checking an item's body, `ReLateParam` is supposed
|
||||||
/// to be used. These also support explicit bounds: both the internally-stored
|
/// to be used. These also support explicit bounds: both the internally-stored
|
||||||
/// *scope*, which the region is assumed to outlive, as well as other
|
/// *scope*, which the region is assumed to outlive, as well as other
|
||||||
/// relations stored in the `FreeRegionMap`. Note that these relations
|
/// relations stored in the `FreeRegionMap`. Note that these relations
|
||||||
@ -123,26 +123,35 @@ use self::RegionKind::*;
|
|||||||
)]
|
)]
|
||||||
#[derive(TyEncodable, TyDecodable)]
|
#[derive(TyEncodable, TyDecodable)]
|
||||||
pub enum RegionKind<I: Interner> {
|
pub enum RegionKind<I: Interner> {
|
||||||
/// Region bound in a type or fn declaration which will be
|
/// A region parameter; for example `'a` in `impl<'a> Trait for &'a ()`.
|
||||||
/// substituted 'early' -- that is, at the same time when type
|
///
|
||||||
/// parameters are substituted.
|
/// There are some important differences between region and type parameters.
|
||||||
ReEarlyBound(I::EarlyBoundRegion),
|
/// Not all region parameters in the source are represented via `ReEarlyParam`:
|
||||||
|
/// late-bound function parameters are instead lowered to a `ReBound`. Late-bound
|
||||||
|
/// regions get eagerly replaced with `ReLateParam` which behaves in the same way as
|
||||||
|
/// `ReEarlyParam`. Region parameters are also sometimes implicit,
|
||||||
|
/// e.g. in `impl Trait for &()`.
|
||||||
|
ReEarlyParam(I::EarlyParamRegion),
|
||||||
|
|
||||||
/// A higher-ranked region. These represent either late-bound function parameters
|
/// A higher-ranked region. These represent either late-bound function parameters
|
||||||
/// or bound variables from a `for<'a>`-binder.
|
/// or bound variables from a `for<'a>`-binder.
|
||||||
///
|
///
|
||||||
/// While inside of a function, e.g. during typeck, the late-bound function parameters
|
/// 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`.
|
/// can be converted to `ReLateParam` by calling `tcx.liberate_late_bound_regions`.
|
||||||
///
|
///
|
||||||
/// Bound regions inside of types **must not** be erased, as they impact trait
|
/// 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
|
/// selection and the `TypeId` of that type. `for<'a> fn(&'a ())` and
|
||||||
/// `fn(&'static ())` are different types and have to be treated as such.
|
/// `fn(&'static ())` are different types and have to be treated as such.
|
||||||
ReBound(DebruijnIndex, I::BoundRegion),
|
ReBound(DebruijnIndex, I::BoundRegion),
|
||||||
|
|
||||||
/// When checking a function body, the types of all arguments and so forth
|
/// Late-bound function parameters are represented using a `ReBound`. When
|
||||||
/// that refer to bound region parameters are modified to refer to free
|
/// inside of a function, we convert these bound variables to placeholder
|
||||||
/// region parameters.
|
/// parameters via `tcx.liberate_late_bound_regions`. They are then treated
|
||||||
ReFree(I::FreeRegion),
|
/// the same way as `ReEarlyParam` while inside of the function.
|
||||||
|
///
|
||||||
|
/// See <https://rustc-dev-guide.rust-lang.org/early-late-bound-summary.html> for
|
||||||
|
/// more info about early and late bound lifetime parameters.
|
||||||
|
ReLateParam(I::LateParamRegion),
|
||||||
|
|
||||||
/// Static data that has an "infinite" lifetime. Top in the region lattice.
|
/// Static data that has an "infinite" lifetime. Top in the region lattice.
|
||||||
ReStatic,
|
ReStatic,
|
||||||
@ -150,8 +159,11 @@ pub enum RegionKind<I: Interner> {
|
|||||||
/// A region variable. Should not exist outside of type inference.
|
/// A region variable. Should not exist outside of type inference.
|
||||||
ReVar(I::InferRegion),
|
ReVar(I::InferRegion),
|
||||||
|
|
||||||
/// A placeholder region -- basically, the higher-ranked version of `ReFree`.
|
/// A placeholder region -- the higher-ranked version of `ReLateParam`.
|
||||||
/// Should not exist outside of type inference.
|
/// Should not exist outside of type inference.
|
||||||
|
///
|
||||||
|
/// Used when instantiating a `forall` binder via
|
||||||
|
/// `infcx.instantiate_binder_with_placeholders`.
|
||||||
RePlaceholder(I::PlaceholderRegion),
|
RePlaceholder(I::PlaceholderRegion),
|
||||||
|
|
||||||
/// Erased region, used by trait selection, in MIR and during codegen.
|
/// Erased region, used by trait selection, in MIR and during codegen.
|
||||||
@ -166,9 +178,9 @@ pub enum RegionKind<I: Interner> {
|
|||||||
#[inline]
|
#[inline]
|
||||||
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,
|
ReEarlyParam(_) => 0,
|
||||||
ReBound(_, _) => 1,
|
ReBound(_, _) => 1,
|
||||||
ReFree(_) => 2,
|
ReLateParam(_) => 2,
|
||||||
ReStatic => 3,
|
ReStatic => 3,
|
||||||
ReVar(_) => 4,
|
ReVar(_) => 4,
|
||||||
RePlaceholder(_) => 5,
|
RePlaceholder(_) => 5,
|
||||||
@ -180,9 +192,9 @@ const fn regionkind_discriminant<I: Interner>(value: &RegionKind<I>) -> usize {
|
|||||||
// This is manually implemented because a derive would require `I: Copy`
|
// This is manually implemented because a derive would require `I: Copy`
|
||||||
impl<I: Interner> Copy for RegionKind<I>
|
impl<I: Interner> Copy for RegionKind<I>
|
||||||
where
|
where
|
||||||
I::EarlyBoundRegion: Copy,
|
I::EarlyParamRegion: Copy,
|
||||||
I::BoundRegion: Copy,
|
I::BoundRegion: Copy,
|
||||||
I::FreeRegion: Copy,
|
I::LateParamRegion: Copy,
|
||||||
I::InferRegion: Copy,
|
I::InferRegion: Copy,
|
||||||
I::PlaceholderRegion: Copy,
|
I::PlaceholderRegion: Copy,
|
||||||
I::ErrorGuaranteed: Copy,
|
I::ErrorGuaranteed: Copy,
|
||||||
@ -195,9 +207,9 @@ impl<I: Interner> PartialEq for RegionKind<I> {
|
|||||||
fn eq(&self, other: &RegionKind<I>) -> bool {
|
fn eq(&self, other: &RegionKind<I>) -> bool {
|
||||||
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,
|
(ReEarlyParam(a_r), ReEarlyParam(b_r)) => a_r == b_r,
|
||||||
(ReBound(a_d, a_r), ReBound(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,
|
(ReLateParam(a_r), ReLateParam(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,
|
||||||
(RePlaceholder(a_r), RePlaceholder(b_r)) => a_r == b_r,
|
(RePlaceholder(a_r), RePlaceholder(b_r)) => a_r == b_r,
|
||||||
@ -223,13 +235,13 @@ impl<I: Interner> DebugWithInfcx<I> for RegionKind<I> {
|
|||||||
f: &mut core::fmt::Formatter<'_>,
|
f: &mut core::fmt::Formatter<'_>,
|
||||||
) -> core::fmt::Result {
|
) -> core::fmt::Result {
|
||||||
match this.data {
|
match this.data {
|
||||||
ReEarlyBound(data) => write!(f, "ReEarlyBound({data:?})"),
|
ReEarlyParam(data) => write!(f, "ReEarlyParam({data:?})"),
|
||||||
|
|
||||||
ReBound(binder_id, bound_region) => {
|
ReBound(binder_id, bound_region) => {
|
||||||
write!(f, "ReBound({binder_id:?}, {bound_region:?})")
|
write!(f, "ReBound({binder_id:?}, {bound_region:?})")
|
||||||
}
|
}
|
||||||
|
|
||||||
ReFree(fr) => write!(f, "{fr:?}"),
|
ReLateParam(fr) => write!(f, "{fr:?}"),
|
||||||
|
|
||||||
ReStatic => f.write_str("ReStatic"),
|
ReStatic => f.write_str("ReStatic"),
|
||||||
|
|
||||||
@ -252,9 +264,9 @@ impl<I: Interner> fmt::Debug for RegionKind<I> {
|
|||||||
// This is not a derived impl because a derive would require `I: HashStable`
|
// This is not a derived impl because a derive would require `I: HashStable`
|
||||||
impl<CTX: HashStableContext, I: Interner> HashStable<CTX> for RegionKind<I>
|
impl<CTX: HashStableContext, I: Interner> HashStable<CTX> for RegionKind<I>
|
||||||
where
|
where
|
||||||
I::EarlyBoundRegion: HashStable<CTX>,
|
I::EarlyParamRegion: HashStable<CTX>,
|
||||||
I::BoundRegion: HashStable<CTX>,
|
I::BoundRegion: HashStable<CTX>,
|
||||||
I::FreeRegion: HashStable<CTX>,
|
I::LateParamRegion: HashStable<CTX>,
|
||||||
I::InferRegion: HashStable<CTX>,
|
I::InferRegion: HashStable<CTX>,
|
||||||
I::PlaceholderRegion: HashStable<CTX>,
|
I::PlaceholderRegion: HashStable<CTX>,
|
||||||
{
|
{
|
||||||
@ -269,10 +281,10 @@ where
|
|||||||
d.hash_stable(hcx, hasher);
|
d.hash_stable(hcx, hasher);
|
||||||
r.hash_stable(hcx, hasher);
|
r.hash_stable(hcx, hasher);
|
||||||
}
|
}
|
||||||
ReEarlyBound(r) => {
|
ReEarlyParam(r) => {
|
||||||
r.hash_stable(hcx, hasher);
|
r.hash_stable(hcx, hasher);
|
||||||
}
|
}
|
||||||
ReFree(r) => {
|
ReLateParam(r) => {
|
||||||
r.hash_stable(hcx, hasher);
|
r.hash_stable(hcx, hasher);
|
||||||
}
|
}
|
||||||
RePlaceholder(r) => {
|
RePlaceholder(r) => {
|
||||||
|
@ -61,7 +61,7 @@ pub struct Region {
|
|||||||
|
|
||||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||||
pub enum RegionKind {
|
pub enum RegionKind {
|
||||||
ReEarlyBound(EarlyBoundRegion),
|
ReEarlyParam(EarlyParamRegion),
|
||||||
ReBound(DebruijnIndex, BoundRegion),
|
ReBound(DebruijnIndex, BoundRegion),
|
||||||
ReStatic,
|
ReStatic,
|
||||||
RePlaceholder(Placeholder<BoundRegion>),
|
RePlaceholder(Placeholder<BoundRegion>),
|
||||||
@ -71,7 +71,7 @@ pub enum RegionKind {
|
|||||||
pub(crate) type DebruijnIndex = u32;
|
pub(crate) type DebruijnIndex = u32;
|
||||||
|
|
||||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||||
pub struct EarlyBoundRegion {
|
pub struct EarlyParamRegion {
|
||||||
pub def_id: RegionDef,
|
pub def_id: RegionDef,
|
||||||
pub index: u32,
|
pub index: u32,
|
||||||
pub name: Symbol,
|
pub name: Symbol,
|
||||||
|
@ -723,7 +723,7 @@ where
|
|||||||
|
|
||||||
fn region_name(region: Region<'_>) -> Option<Symbol> {
|
fn region_name(region: Region<'_>) -> Option<Symbol> {
|
||||||
match *region {
|
match *region {
|
||||||
ty::ReEarlyBound(r) => Some(r.name),
|
ty::ReEarlyParam(r) => Some(r.name),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -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::ReBound(..) | ty::ReError(_) => r,
|
ty::ReEarlyParam(_) | ty::ReStatic | ty::ReBound(..) | ty::ReError(_) => r,
|
||||||
r => bug!("unexpected region: {r:?}"),
|
r => bug!("unexpected region: {r:?}"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -287,9 +287,9 @@ pub(crate) fn clean_middle_region<'tcx>(region: ty::Region<'tcx>) -> Option<Life
|
|||||||
ty::ReStatic => Some(Lifetime::statik()),
|
ty::ReStatic => Some(Lifetime::statik()),
|
||||||
_ if !region.has_name() => None,
|
_ if !region.has_name() => None,
|
||||||
ty::ReBound(_, ty::BoundRegion { kind: ty::BrNamed(_, name), .. }) => Some(Lifetime(name)),
|
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::ReBound(..)
|
||||||
| ty::ReFree(..)
|
| ty::ReLateParam(..)
|
||||||
| ty::ReVar(..)
|
| ty::ReVar(..)
|
||||||
| ty::ReError(_)
|
| ty::ReError(_)
|
||||||
| ty::RePlaceholder(..)
|
| ty::RePlaceholder(..)
|
||||||
@ -1928,13 +1928,13 @@ fn clean_trait_object_lifetime_bound<'tcx>(
|
|||||||
// latter contrary to `clean_middle_region`.
|
// latter contrary to `clean_middle_region`.
|
||||||
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::ReEarlyParam(region) if region.name != kw::Empty => Some(Lifetime(region.name)),
|
||||||
ty::ReBound(_, ty::BoundRegion { kind: ty::BrNamed(_, name), .. }) if name != kw::Empty => {
|
ty::ReBound(_, ty::BoundRegion { kind: ty::BrNamed(_, name), .. }) if name != kw::Empty => {
|
||||||
Some(Lifetime(name))
|
Some(Lifetime(name))
|
||||||
}
|
}
|
||||||
ty::ReEarlyBound(_)
|
ty::ReEarlyParam(_)
|
||||||
| ty::ReBound(..)
|
| ty::ReBound(..)
|
||||||
| ty::ReFree(_)
|
| ty::ReLateParam(_)
|
||||||
| ty::ReVar(_)
|
| ty::ReVar(_)
|
||||||
| ty::RePlaceholder(_)
|
| ty::RePlaceholder(_)
|
||||||
| ty::ReErased
|
| ty::ReErased
|
||||||
|
@ -175,7 +175,7 @@ impl<'tcx> PassByRefOrValue {
|
|||||||
},
|
},
|
||||||
// Early bound regions on functions are either from the containing item, are bounded by another
|
// 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.
|
// lifetime, or are used as a bound for a type or lifetime.
|
||||||
RegionKind::ReEarlyBound(..) => continue,
|
RegionKind::ReEarlyParam(..) => continue,
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -465,9 +465,9 @@ fn check_fn_args<'cx, 'tcx: 'cx>(
|
|||||||
.walk()
|
.walk()
|
||||||
.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::ReEarlyParam(r) => Some(r.def_id),
|
||||||
ty::ReBound(_, r) => r.kind.get_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::ReStatic
|
||||||
| ty::ReVar(_)
|
| ty::ReVar(_)
|
||||||
| ty::RePlaceholder(_)
|
| ty::RePlaceholder(_)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
error: {foo<ReEarlyBound(DefId(..), 0, 'a)>::{closure#0} closure_kind_ty=i8 closure_sig_as_fn_ptr_ty=extern "rust-call" fn(()) upvar_tys=()}
|
error: {foo<ReEarlyParam(DefId(..), 0, 'a)>::{closure#0} closure_kind_ty=i8 closure_sig_as_fn_ptr_ty=extern "rust-call" fn(()) upvar_tys=()}
|
||||||
--> $DIR/erased-regions-in-hidden-ty.rs:11:36
|
--> $DIR/erased-regions-in-hidden-ty.rs:11:36
|
||||||
|
|
|
|
||||||
LL | fn foo<'a: 'a>(x: &'a Vec<i32>) -> impl Fn() + 'static {
|
LL | fn foo<'a: 'a>(x: &'a Vec<i32>) -> impl Fn() + 'static {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
error: {foo<ReEarlyBound(DefId(..), 0, 'a)>::{closure#0} closure_kind_ty=i8 closure_sig_as_fn_ptr_ty=extern "rust-call" fn(()) upvar_tys=()}
|
error: {foo<ReEarlyParam(DefId(..), 0, 'a)>::{closure#0} closure_kind_ty=i8 closure_sig_as_fn_ptr_ty=extern "rust-call" fn(()) upvar_tys=()}
|
||||||
--> $DIR/erased-regions-in-hidden-ty.rs:11:36
|
--> $DIR/erased-regions-in-hidden-ty.rs:11:36
|
||||||
|
|
|
|
||||||
LL | fn foo<'a: 'a>(x: &'a Vec<i32>) -> impl Fn() + 'static {
|
LL | fn foo<'a: 'a>(x: &'a Vec<i32>) -> impl Fn() + 'static {
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
error[E0700]: hidden type for `Opaque(DefId(0:13 ~ impl_trait_captures[aeb9]::foo::{opaque#0}), [ReEarlyBound(DefId(0:9 ~ impl_trait_captures[aeb9]::foo::'a), 0, 'a), T, ReEarlyBound(DefId(0:9 ~ impl_trait_captures[aeb9]::foo::'a), 0, 'a)])` captures lifetime that does not appear in bounds
|
error[E0700]: hidden type for `Opaque(DefId(0:13 ~ impl_trait_captures[aeb9]::foo::{opaque#0}), [ReEarlyParam(DefId(0:9 ~ impl_trait_captures[aeb9]::foo::'a), 0, 'a), T, ReEarlyParam(DefId(0:9 ~ impl_trait_captures[aeb9]::foo::'a), 0, 'a)])` captures lifetime that does not appear in bounds
|
||||||
--> $DIR/impl-trait-captures.rs:11:5
|
--> $DIR/impl-trait-captures.rs:11:5
|
||||||
|
|
|
|
||||||
LL | fn foo<'a, T>(x: &T) -> impl Foo<'a> {
|
LL | fn foo<'a, T>(x: &T) -> impl Foo<'a> {
|
||||||
| -- ------------ opaque type defined here
|
| -- ------------ opaque type defined here
|
||||||
| |
|
| |
|
||||||
| hidden type `&ReFree(DefId(0:8 ~ impl_trait_captures[aeb9]::foo), BrNamed(DefId(0:12 ~ impl_trait_captures[aeb9]::foo::'_), '_)) T` captures the anonymous lifetime defined here
|
| hidden type `&ReLateParam(DefId(0:8 ~ impl_trait_captures[aeb9]::foo), BrNamed(DefId(0:12 ~ impl_trait_captures[aeb9]::foo::'_), '_)) T` captures the anonymous lifetime defined here
|
||||||
LL | x
|
LL | x
|
||||||
| ^
|
| ^
|
||||||
|
|
|
|
||||||
help: to declare that `Opaque(DefId(0:13 ~ impl_trait_captures[aeb9]::foo::{opaque#0}), [ReEarlyBound(DefId(0:9 ~ impl_trait_captures[aeb9]::foo::'a), 0, 'a), T, ReEarlyBound(DefId(0:14 ~ impl_trait_captures[aeb9]::foo::{opaque#0}::'a), 2, 'a)])` captures `ReFree(DefId(0:8 ~ impl_trait_captures[aeb9]::foo), BrNamed(DefId(0:12 ~ impl_trait_captures[aeb9]::foo::'_), '_))`, you can add an explicit `ReFree(DefId(0:8 ~ impl_trait_captures[aeb9]::foo), BrNamed(DefId(0:12 ~ impl_trait_captures[aeb9]::foo::'_), '_))` lifetime bound
|
help: to declare that `Opaque(DefId(0:13 ~ impl_trait_captures[aeb9]::foo::{opaque#0}), [ReEarlyParam(DefId(0:9 ~ impl_trait_captures[aeb9]::foo::'a), 0, 'a), T, ReEarlyParam(DefId(0:14 ~ impl_trait_captures[aeb9]::foo::{opaque#0}::'a), 2, 'a)])` captures `ReLateParam(DefId(0:8 ~ impl_trait_captures[aeb9]::foo), BrNamed(DefId(0:12 ~ impl_trait_captures[aeb9]::foo::'_), '_))`, you can add an explicit `ReLateParam(DefId(0:8 ~ impl_trait_captures[aeb9]::foo), BrNamed(DefId(0:12 ~ impl_trait_captures[aeb9]::foo::'_), '_))` lifetime bound
|
||||||
|
|
|
|
||||||
LL | fn foo<'a, T>(x: &T) -> impl Foo<'a> + ReFree(DefId(0:8 ~ impl_trait_captures[aeb9]::foo), BrNamed(DefId(0:12 ~ impl_trait_captures[aeb9]::foo::'_), '_)) {
|
LL | fn foo<'a, T>(x: &T) -> impl Foo<'a> + ReLateParam(DefId(0:8 ~ impl_trait_captures[aeb9]::foo), BrNamed(DefId(0:12 ~ impl_trait_captures[aeb9]::foo::'_), '_)) {
|
||||||
| ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
| +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user