rename upcast
to cast_to_tcx_lifetime
and improve comment
This commit is contained in:
parent
d695512437
commit
59ea17ed3f
@ -48,7 +48,7 @@ impl<'gcx: 'tcx, 'tcx> super::QueryTypeOp<'gcx, 'tcx> for Eq<'tcx> {
|
||||
tcx.type_op_eq(canonicalized)
|
||||
}
|
||||
|
||||
fn upcast_result(
|
||||
fn cast_to_tcx_lifetime(
|
||||
v: &'a CanonicalizedQueryResult<'gcx, ()>,
|
||||
) -> &'a Canonical<'tcx, QueryResult<'tcx, ()>> {
|
||||
v
|
||||
|
@ -54,14 +54,19 @@ pub trait QueryTypeOp<'gcx: 'tcx, 'tcx>: fmt::Debug + Sized {
|
||||
canonicalized: Canonicalized<'gcx, Self::QueryKey>,
|
||||
) -> Fallible<CanonicalizedQueryResult<'gcx, Self::QueryResult>>;
|
||||
|
||||
/// "Upcasts" a lifted query result (which is in the gcx lifetime)
|
||||
/// Casts a lifted query result (which is in the gcx lifetime)
|
||||
/// into the tcx lifetime. This is always just an identity cast,
|
||||
/// but the generic code does't realize it, so we have to push the
|
||||
/// operation into the impls that know more specifically what
|
||||
/// but the generic code doesn't realize it -- put another way, in
|
||||
/// the generic code, we have a `Lifted<'gcx, Self::QueryResult>`
|
||||
/// and we want to convert that to a `Self::QueryResult`. This is
|
||||
/// not a priori valid, so we can't do it -- but in practice, it
|
||||
/// is always a no-op (e.g., the lifted form of a type,
|
||||
/// `Ty<'gcx>`, is a subtype of `Ty<'tcx>`). So we have to push
|
||||
/// the operation into the impls that know more specifically what
|
||||
/// `QueryResult` is. This operation would (maybe) be nicer with
|
||||
/// something like HKTs or GATs, since then we could make
|
||||
/// `QueryResult` parametric and `'gcx` and `'tcx` etc.
|
||||
fn upcast_result(
|
||||
fn cast_to_tcx_lifetime(
|
||||
lifted_query_result: &'a CanonicalizedQueryResult<'gcx, Self::QueryResult>,
|
||||
) -> &'a Canonical<'tcx, QueryResult<'tcx, Self::QueryResult>>;
|
||||
|
||||
@ -80,7 +85,7 @@ pub trait QueryTypeOp<'gcx: 'tcx, 'tcx>: fmt::Debug + Sized {
|
||||
let (canonical_self, canonical_var_values) =
|
||||
infcx.canonicalize_hr_query_hack(&query_key);
|
||||
let canonical_result = Self::perform_query(infcx.tcx, canonical_self)?;
|
||||
let canonical_result = Self::upcast_result(&canonical_result);
|
||||
let canonical_result = Self::cast_to_tcx_lifetime(&canonical_result);
|
||||
|
||||
let param_env = Self::param_env(&query_key);
|
||||
|
||||
|
@ -55,10 +55,10 @@ where
|
||||
T::type_op_method(tcx, canonicalized)
|
||||
}
|
||||
|
||||
fn upcast_result(
|
||||
fn cast_to_tcx_lifetime(
|
||||
v: &'a CanonicalizedQueryResult<'gcx, T>,
|
||||
) -> &'a Canonical<'tcx, QueryResult<'tcx, T>> {
|
||||
T::upcast_result(v)
|
||||
T::cast_to_tcx_lifetime(v)
|
||||
}
|
||||
}
|
||||
|
||||
@ -70,7 +70,7 @@ pub trait Normalizable<'gcx, 'tcx>: fmt::Debug + TypeFoldable<'tcx> + Lift<'gcx>
|
||||
|
||||
/// Convert from the `'gcx` (lifted) form of `Self` into the `tcx`
|
||||
/// form of `Self`.
|
||||
fn upcast_result(
|
||||
fn cast_to_tcx_lifetime(
|
||||
v: &'a CanonicalizedQueryResult<'gcx, Self>,
|
||||
) -> &'a Canonical<'tcx, QueryResult<'tcx, Self>>;
|
||||
}
|
||||
@ -86,7 +86,7 @@ where
|
||||
tcx.type_op_normalize_ty(canonicalized)
|
||||
}
|
||||
|
||||
fn upcast_result(
|
||||
fn cast_to_tcx_lifetime(
|
||||
v: &'a CanonicalizedQueryResult<'gcx, Self>,
|
||||
) -> &'a Canonical<'tcx, QueryResult<'tcx, Self>> {
|
||||
v
|
||||
@ -104,7 +104,7 @@ where
|
||||
tcx.type_op_normalize_predicate(canonicalized)
|
||||
}
|
||||
|
||||
fn upcast_result(
|
||||
fn cast_to_tcx_lifetime(
|
||||
v: &'a CanonicalizedQueryResult<'gcx, Self>,
|
||||
) -> &'a Canonical<'tcx, QueryResult<'tcx, Self>> {
|
||||
v
|
||||
@ -122,7 +122,7 @@ where
|
||||
tcx.type_op_normalize_poly_fn_sig(canonicalized)
|
||||
}
|
||||
|
||||
fn upcast_result(
|
||||
fn cast_to_tcx_lifetime(
|
||||
v: &'a CanonicalizedQueryResult<'gcx, Self>,
|
||||
) -> &'a Canonical<'tcx, QueryResult<'tcx, Self>> {
|
||||
v
|
||||
@ -140,7 +140,7 @@ where
|
||||
tcx.type_op_normalize_fn_sig(canonicalized)
|
||||
}
|
||||
|
||||
fn upcast_result(
|
||||
fn cast_to_tcx_lifetime(
|
||||
v: &'a CanonicalizedQueryResult<'gcx, Self>,
|
||||
) -> &'a Canonical<'tcx, QueryResult<'tcx, Self>> {
|
||||
v
|
||||
|
@ -55,7 +55,7 @@ where
|
||||
tcx.dropck_outlives(canonicalized)
|
||||
}
|
||||
|
||||
fn upcast_result(
|
||||
fn cast_to_tcx_lifetime(
|
||||
lifted_query_result: &'a CanonicalizedQueryResult<'gcx, Self::QueryResult>,
|
||||
) -> &'a Canonical<'tcx, QueryResult<'tcx, Self::QueryResult>> {
|
||||
lifted_query_result
|
||||
|
@ -46,7 +46,7 @@ impl<'gcx: 'tcx, 'tcx> super::QueryTypeOp<'gcx, 'tcx> for ProvePredicate<'tcx> {
|
||||
tcx.type_op_prove_predicate(canonicalized)
|
||||
}
|
||||
|
||||
fn upcast_result(
|
||||
fn cast_to_tcx_lifetime(
|
||||
v: &'a CanonicalizedQueryResult<'gcx, ()>,
|
||||
) -> &'a Canonical<'tcx, QueryResult<'tcx, ()>> {
|
||||
v
|
||||
|
@ -52,7 +52,7 @@ impl<'gcx: 'tcx, 'tcx> super::QueryTypeOp<'gcx, 'tcx> for Subtype<'tcx> {
|
||||
tcx.type_op_subtype(canonicalized)
|
||||
}
|
||||
|
||||
fn upcast_result(
|
||||
fn cast_to_tcx_lifetime(
|
||||
v: &'a CanonicalizedQueryResult<'gcx, ()>,
|
||||
) -> &'a Canonical<'tcx, QueryResult<'tcx, ()>> {
|
||||
v
|
||||
|
Loading…
x
Reference in New Issue
Block a user