Rename some functions to represent their generalized behavior · rust-lang/rust@74d5bbb (original) (raw)

`@@ -1254,7 +1254,7 @@ impl<'tcx> TyCtxt<'tcx> {

`

1254

1254

`if self.def_kind(scope) == DefKind::OpaqueTy {

`

1255

1255

`// Lifetime params of opaque types are synthetic and thus irrelevant to

`

1256

1256

`// diagnostics. Map them back to their origin!

`

1257

``

`-

region = self.map_rpit_lifetime_to_fn_lifetime(def_id);

`

``

1257

`+

region = self.map_opaque_lifetime_to_parent_lifetime(def_id);

`

1258

1258

`continue;

`

1259

1259

`}

`

1260

1260

`break (scope, ty::BrNamed(def_id.into(), self.item_name(def_id.into())));

`

`@@ -2219,31 +2219,31 @@ impl<'tcx> TyCtxt<'tcx> {

`

2219

2219

`)

`

2220

2220

`}

`

2221

2221

``

2222

``

`-

/// Given the def-id of an early-bound lifetime on an RPIT corresponding to

`

``

2222

`+

/// Given the def-id of an early-bound lifetime on an opaque corresponding to

`

2223

2223

`/// a duplicated captured lifetime, map it back to the early- or late-bound

`

2224

2224

`/// lifetime of the function from which it originally as captured. If it is

`

2225

2225

`` /// a late-bound lifetime, this will represent the liberated (ReLateParam) lifetime

``

2226

2226

`/// of the signature.

`

2227

2227

`// FIXME(RPITIT): if we ever synthesize new lifetimes for RPITITs and not just

`

2228

2228

`// re-use the generics of the opaque, this function will need to be tweaked slightly.

`

2229

``

`-

pub fn map_rpit_lifetime_to_fn_lifetime(

`

``

2229

`+

pub fn map_opaque_lifetime_to_parent_lifetime(

`

2230

2230

`self,

`

2231

``

`-

mut rpit_lifetime_param_def_id: LocalDefId,

`

``

2231

`+

mut opaque_lifetime_param_def_id: LocalDefId,

`

2232

2232

`) -> ty::Region<'tcx> {

`

2233

2233

`debug_assert!(

`

2234

``

`-

matches!(self.def_kind(rpit_lifetime_param_def_id), DefKind::LifetimeParam),

`

2235

``

`-

"{rpit_lifetime_param_def_id:?} is a {}",

`

2236

``

`-

self.def_descr(rpit_lifetime_param_def_id.to_def_id())

`

``

2234

`+

matches!(self.def_kind(opaque_lifetime_param_def_id), DefKind::LifetimeParam),

`

``

2235

`+

"{opaque_lifetime_param_def_id:?} is a {}",

`

``

2236

`+

self.def_descr(opaque_lifetime_param_def_id.to_def_id())

`

2237

2237

`);

`

2238

2238

``

2239

2239

`loop {

`

2240

``

`-

let parent = self.local_parent(rpit_lifetime_param_def_id);

`

``

2240

`+

let parent = self.local_parent(opaque_lifetime_param_def_id);

`

2241

2241

`let hir::OpaqueTy { lifetime_mapping, .. } =

`

2242

2242

`self.hir_node_by_def_id(parent).expect_item().expect_opaque_ty();

`

2243

2243

``

2244

2244

`let Some((lifetime, _)) = lifetime_mapping

`

2245

2245

`.iter()

`

2246

``

`-

.find(|(_, duplicated_param)| *duplicated_param == rpit_lifetime_param_def_id)

`

``

2246

`+

.find(|(_, duplicated_param)| *duplicated_param == opaque_lifetime_param_def_id)

`

2247

2247

`else {

`

2248

2248

`bug!("duplicated lifetime param should be present");

`

2249

2249

`};

`

`@@ -2256,7 +2256,7 @@ impl<'tcx> TyCtxt<'tcx> {

`

2256

2256

`// of the opaque we mapped from. Continue mapping.

`

2257

2257

`if matches!(self.def_kind(new_parent), DefKind::OpaqueTy) {

`

2258

2258

`debug_assert_eq!(self.parent(parent.to_def_id()), new_parent);

`

2259

``

`-

rpit_lifetime_param_def_id = ebv.expect_local();

`

``

2259

`+

opaque_lifetime_param_def_id = ebv.expect_local();

`

2260

2260

`continue;

`

2261

2261

`}

`

2262

2262

``