Rename some functions to represent their generalized behavior
This commit is contained in:
parent
99df5a2b42
commit
74d5bbbf94
4 changed files with 13 additions and 13 deletions
|
@ -358,7 +358,7 @@ fn check_opaque_meets_bounds<'tcx>(
|
||||||
tcx, parent,
|
tcx, parent,
|
||||||
)
|
)
|
||||||
.extend_to(tcx, def_id.to_def_id(), |param, _| {
|
.extend_to(tcx, def_id.to_def_id(), |param, _| {
|
||||||
tcx.map_rpit_lifetime_to_fn_lifetime(param.def_id.expect_local()).into()
|
tcx.map_opaque_lifetime_to_parent_lifetime(param.def_id.expect_local()).into()
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -339,7 +339,7 @@ fn compute_bidirectional_outlives_predicates<'tcx>(
|
||||||
predicates: &mut Vec<(ty::Clause<'tcx>, Span)>,
|
predicates: &mut Vec<(ty::Clause<'tcx>, Span)>,
|
||||||
) {
|
) {
|
||||||
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_opaque_lifetime_to_parent_lifetime(param.def_id.expect_local());
|
||||||
if let ty::ReEarlyParam(..) = *orig_lifetime {
|
if let ty::ReEarlyParam(..) = *orig_lifetime {
|
||||||
let dup_lifetime = ty::Region::new_early_param(
|
let dup_lifetime = ty::Region::new_early_param(
|
||||||
tcx,
|
tcx,
|
||||||
|
|
|
@ -1254,7 +1254,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||||
if self.def_kind(scope) == DefKind::OpaqueTy {
|
if self.def_kind(scope) == DefKind::OpaqueTy {
|
||||||
// Lifetime params of opaque types are synthetic and thus irrelevant to
|
// Lifetime params of opaque types are synthetic and thus irrelevant to
|
||||||
// diagnostics. Map them back to their origin!
|
// diagnostics. Map them back to their origin!
|
||||||
region = self.map_rpit_lifetime_to_fn_lifetime(def_id);
|
region = self.map_opaque_lifetime_to_parent_lifetime(def_id);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
break (scope, ty::BrNamed(def_id.into(), self.item_name(def_id.into())));
|
break (scope, ty::BrNamed(def_id.into(), self.item_name(def_id.into())));
|
||||||
|
@ -2219,31 +2219,31 @@ 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 opaque 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 (`ReLateParam`) 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.
|
||||||
pub fn map_rpit_lifetime_to_fn_lifetime(
|
pub fn map_opaque_lifetime_to_parent_lifetime(
|
||||||
self,
|
self,
|
||||||
mut rpit_lifetime_param_def_id: LocalDefId,
|
mut opaque_lifetime_param_def_id: LocalDefId,
|
||||||
) -> ty::Region<'tcx> {
|
) -> ty::Region<'tcx> {
|
||||||
debug_assert!(
|
debug_assert!(
|
||||||
matches!(self.def_kind(rpit_lifetime_param_def_id), DefKind::LifetimeParam),
|
matches!(self.def_kind(opaque_lifetime_param_def_id), DefKind::LifetimeParam),
|
||||||
"{rpit_lifetime_param_def_id:?} is a {}",
|
"{opaque_lifetime_param_def_id:?} is a {}",
|
||||||
self.def_descr(rpit_lifetime_param_def_id.to_def_id())
|
self.def_descr(opaque_lifetime_param_def_id.to_def_id())
|
||||||
);
|
);
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
let parent = self.local_parent(rpit_lifetime_param_def_id);
|
let parent = self.local_parent(opaque_lifetime_param_def_id);
|
||||||
let hir::OpaqueTy { lifetime_mapping, .. } =
|
let hir::OpaqueTy { lifetime_mapping, .. } =
|
||||||
self.hir_node_by_def_id(parent).expect_item().expect_opaque_ty();
|
self.hir_node_by_def_id(parent).expect_item().expect_opaque_ty();
|
||||||
|
|
||||||
let Some((lifetime, _)) = lifetime_mapping
|
let Some((lifetime, _)) = lifetime_mapping
|
||||||
.iter()
|
.iter()
|
||||||
.find(|(_, duplicated_param)| *duplicated_param == rpit_lifetime_param_def_id)
|
.find(|(_, duplicated_param)| *duplicated_param == opaque_lifetime_param_def_id)
|
||||||
else {
|
else {
|
||||||
bug!("duplicated lifetime param should be present");
|
bug!("duplicated lifetime param should be present");
|
||||||
};
|
};
|
||||||
|
@ -2256,7 +2256,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||||
// of the opaque we mapped from. Continue mapping.
|
// of the opaque we mapped from. Continue mapping.
|
||||||
if matches!(self.def_kind(new_parent), DefKind::OpaqueTy) {
|
if matches!(self.def_kind(new_parent), DefKind::OpaqueTy) {
|
||||||
debug_assert_eq!(self.parent(parent.to_def_id()), new_parent);
|
debug_assert_eq!(self.parent(parent.to_def_id()), new_parent);
|
||||||
rpit_lifetime_param_def_id = ebv.expect_local();
|
opaque_lifetime_param_def_id = ebv.expect_local();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,7 @@ fn assumed_wf_types<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> &'tcx [(Ty<'
|
||||||
// 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_opaque_lifetime_to_parent_lifetime(param.def_id.expect_local());
|
||||||
if matches!(*orig_lt, ty::ReLateParam(..)) {
|
if matches!(*orig_lt, ty::ReLateParam(..)) {
|
||||||
mapping.insert(
|
mapping.insert(
|
||||||
orig_lt,
|
orig_lt,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue