Skip to content

Commit 4469bdd

Browse files
Remove shrink_to_tcx_lifetime
There's no longer two distinct gcx and tcx lifetimes which made this necessary (or, at least, the code compiles -- it's possible we got better at normalizing, but that seems unlikely).
1 parent 9f63a3a commit 4469bdd

File tree

8 files changed

+9
-98
lines changed

8 files changed

+9
-98
lines changed

src/librustc/traits/query/type_op/ascribe_user_type.rs

+1-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::infer::canonical::{Canonical, Canonicalized, CanonicalizedQueryResponse, QueryResponse};
1+
use crate::infer::canonical::{Canonicalized, CanonicalizedQueryResponse};
22
use crate::traits::query::Fallible;
33
use crate::hir::def_id::DefId;
44
use crate::ty::{ParamEnvAnd, Ty, TyCtxt};
@@ -37,12 +37,6 @@ impl<'tcx> super::QueryTypeOp<'tcx> for AscribeUserType<'tcx> {
3737
) -> Fallible<CanonicalizedQueryResponse<'tcx, ()>> {
3838
tcx.type_op_ascribe_user_type(canonicalized)
3939
}
40-
41-
fn shrink_to_tcx_lifetime(
42-
v: &'a CanonicalizedQueryResponse<'tcx, ()>,
43-
) -> &'a Canonical<'tcx, QueryResponse<'tcx, ()>> {
44-
v
45-
}
4640
}
4741

4842
BraceStructTypeFoldableImpl! {

src/librustc/traits/query/type_op/eq.rs

+1-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::infer::canonical::{Canonical, Canonicalized, CanonicalizedQueryResponse, QueryResponse};
1+
use crate::infer::canonical::{Canonicalized, CanonicalizedQueryResponse};
22
use crate::traits::query::Fallible;
33
use crate::ty::{ParamEnvAnd, Ty, TyCtxt};
44

@@ -34,12 +34,6 @@ impl<'tcx> super::QueryTypeOp<'tcx> for Eq<'tcx> {
3434
) -> Fallible<CanonicalizedQueryResponse<'tcx, ()>> {
3535
tcx.type_op_eq(canonicalized)
3636
}
37-
38-
fn shrink_to_tcx_lifetime(
39-
v: &'a CanonicalizedQueryResponse<'tcx, ()>,
40-
) -> &'a Canonical<'tcx, QueryResponse<'tcx, ()>> {
41-
v
42-
}
4337
}
4438

4539
BraceStructTypeFoldableImpl! {

src/librustc/traits/query/type_op/implied_outlives_bounds.rs

+1-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::infer::canonical::{Canonical, Canonicalized, CanonicalizedQueryResponse, QueryResponse};
1+
use crate::infer::canonical::{Canonicalized, CanonicalizedQueryResponse};
22
use crate::traits::query::outlives_bounds::OutlivesBound;
33
use crate::traits::query::Fallible;
44
use crate::ty::{ParamEnvAnd, Ty, TyCtxt};
@@ -38,12 +38,6 @@ impl<'tcx> super::QueryTypeOp<'tcx> for ImpliedOutlivesBounds<'tcx> {
3838

3939
tcx.implied_outlives_bounds(canonicalized)
4040
}
41-
42-
fn shrink_to_tcx_lifetime(
43-
v: &'a CanonicalizedQueryResponse<'tcx, Self::QueryResponse>,
44-
) -> &'a Canonical<'tcx, QueryResponse<'tcx, Self::QueryResponse>> {
45-
v
46-
}
4741
}
4842

4943
BraceStructTypeFoldableImpl! {

src/librustc/traits/query/type_op/mod.rs

+2-19
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::infer::canonical::{
2-
Canonical, Canonicalized, CanonicalizedQueryResponse, OriginalQueryValues,
3-
QueryRegionConstraints, QueryResponse,
2+
Canonicalized, CanonicalizedQueryResponse, OriginalQueryValues,
3+
QueryRegionConstraints,
44
};
55
use crate::infer::{InferCtxt, InferOk};
66
use std::fmt;
@@ -66,22 +66,6 @@ pub trait QueryTypeOp<'tcx>: fmt::Debug + Sized + TypeFoldable<'tcx> + 'tcx {
6666
canonicalized: Canonicalized<'tcx, ParamEnvAnd<'tcx, Self>>,
6767
) -> Fallible<CanonicalizedQueryResponse<'tcx, Self::QueryResponse>>;
6868

69-
/// Casts a lifted query result (which is in the tcx lifetime)
70-
/// into the tcx lifetime. This is always just an identity cast,
71-
/// but the generic code doesn't realize it -- put another way, in
72-
/// the generic code, we have a `Lifted<'tcx, Self::QueryResponse>`
73-
/// and we want to convert that to a `Self::QueryResponse`. This is
74-
/// not a priori valid, so we can't do it -- but in practice, it
75-
/// is always a no-op (e.g., the lifted form of a type,
76-
/// `Ty<'tcx>`, is a subtype of `Ty<'tcx>`). So we have to push
77-
/// the operation into the impls that know more specifically what
78-
/// `QueryResponse` is. This operation would (maybe) be nicer with
79-
/// something like HKTs or GATs, since then we could make
80-
/// `QueryResponse` parametric and `'tcx` and `'tcx` etc.
81-
fn shrink_to_tcx_lifetime(
82-
lifted_query_result: &'a CanonicalizedQueryResponse<'tcx, Self::QueryResponse>,
83-
) -> &'a Canonical<'tcx, QueryResponse<'tcx, Self::QueryResponse>>;
84-
8569
fn fully_perform_into(
8670
query_key: ParamEnvAnd<'tcx, Self>,
8771
infcx: &InferCtxt<'_, 'tcx>,
@@ -99,7 +83,6 @@ pub trait QueryTypeOp<'tcx>: fmt::Debug + Sized + TypeFoldable<'tcx> + 'tcx {
9983
let canonical_self =
10084
infcx.canonicalize_hr_query_hack(&query_key, &mut canonical_var_values);
10185
let canonical_result = Self::perform_query(infcx.tcx, canonical_self)?;
102-
let canonical_result = Self::shrink_to_tcx_lifetime(&canonical_result);
10386

10487
let param_env = query_key.param_env;
10588

src/librustc/traits/query/type_op/normalize.rs

+1-37
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::infer::canonical::{Canonical, Canonicalized, CanonicalizedQueryResponse, QueryResponse};
1+
use crate::infer::canonical::{Canonicalized, CanonicalizedQueryResponse};
22
use std::fmt;
33
use crate::traits::query::Fallible;
44
use crate::ty::fold::TypeFoldable;
@@ -38,25 +38,13 @@ where
3838
) -> Fallible<CanonicalizedQueryResponse<'tcx, Self::QueryResponse>> {
3939
T::type_op_method(tcx, canonicalized)
4040
}
41-
42-
fn shrink_to_tcx_lifetime(
43-
v: &'a CanonicalizedQueryResponse<'tcx, T>,
44-
) -> &'a Canonical<'tcx, QueryResponse<'tcx, T>> {
45-
T::shrink_to_tcx_lifetime(v)
46-
}
4741
}
4842

4943
pub trait Normalizable<'tcx>: fmt::Debug + TypeFoldable<'tcx> + Lift<'tcx> + Copy {
5044
fn type_op_method(
5145
tcx: TyCtxt<'tcx>,
5246
canonicalized: Canonicalized<'tcx, ParamEnvAnd<'tcx, Normalize<Self>>>,
5347
) -> Fallible<CanonicalizedQueryResponse<'tcx, Self>>;
54-
55-
/// Converts from the `'tcx` (lifted) form of `Self` into the `tcx`
56-
/// form of `Self`.
57-
fn shrink_to_tcx_lifetime(
58-
v: &'a CanonicalizedQueryResponse<'tcx, Self>,
59-
) -> &'a Canonical<'tcx, QueryResponse<'tcx, Self>>;
6048
}
6149

6250
impl Normalizable<'tcx> for Ty<'tcx> {
@@ -66,12 +54,6 @@ impl Normalizable<'tcx> for Ty<'tcx> {
6654
) -> Fallible<CanonicalizedQueryResponse<'tcx, Self>> {
6755
tcx.type_op_normalize_ty(canonicalized)
6856
}
69-
70-
fn shrink_to_tcx_lifetime(
71-
v: &'a CanonicalizedQueryResponse<'tcx, Self>,
72-
) -> &'a Canonical<'tcx, QueryResponse<'tcx, Self>> {
73-
v
74-
}
7557
}
7658

7759
impl Normalizable<'tcx> for ty::Predicate<'tcx> {
@@ -81,12 +63,6 @@ impl Normalizable<'tcx> for ty::Predicate<'tcx> {
8163
) -> Fallible<CanonicalizedQueryResponse<'tcx, Self>> {
8264
tcx.type_op_normalize_predicate(canonicalized)
8365
}
84-
85-
fn shrink_to_tcx_lifetime(
86-
v: &'a CanonicalizedQueryResponse<'tcx, Self>,
87-
) -> &'a Canonical<'tcx, QueryResponse<'tcx, Self>> {
88-
v
89-
}
9066
}
9167

9268
impl Normalizable<'tcx> for ty::PolyFnSig<'tcx> {
@@ -96,12 +72,6 @@ impl Normalizable<'tcx> for ty::PolyFnSig<'tcx> {
9672
) -> Fallible<CanonicalizedQueryResponse<'tcx, Self>> {
9773
tcx.type_op_normalize_poly_fn_sig(canonicalized)
9874
}
99-
100-
fn shrink_to_tcx_lifetime(
101-
v: &'a CanonicalizedQueryResponse<'tcx, Self>,
102-
) -> &'a Canonical<'tcx, QueryResponse<'tcx, Self>> {
103-
v
104-
}
10575
}
10676

10777
impl Normalizable<'tcx> for ty::FnSig<'tcx> {
@@ -111,12 +81,6 @@ impl Normalizable<'tcx> for ty::FnSig<'tcx> {
11181
) -> Fallible<CanonicalizedQueryResponse<'tcx, Self>> {
11282
tcx.type_op_normalize_fn_sig(canonicalized)
11383
}
114-
115-
fn shrink_to_tcx_lifetime(
116-
v: &'a CanonicalizedQueryResponse<'tcx, Self>,
117-
) -> &'a Canonical<'tcx, QueryResponse<'tcx, Self>> {
118-
v
119-
}
12084
}
12185

12286
BraceStructTypeFoldableImpl! {

src/librustc/traits/query/type_op/outlives.rs

+1-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::infer::canonical::{Canonical, Canonicalized, CanonicalizedQueryResponse, QueryResponse};
1+
use crate::infer::canonical::{Canonicalized, CanonicalizedQueryResponse};
22
use crate::traits::query::dropck_outlives::trivial_dropck_outlives;
33
use crate::traits::query::dropck_outlives::DropckOutlivesResult;
44
use crate::traits::query::Fallible;
@@ -53,12 +53,6 @@ impl super::QueryTypeOp<'tcx> for DropckOutlives<'tcx> {
5353

5454
tcx.dropck_outlives(canonicalized)
5555
}
56-
57-
fn shrink_to_tcx_lifetime(
58-
lifted_query_result: &'a CanonicalizedQueryResponse<'tcx, Self::QueryResponse>,
59-
) -> &'a Canonical<'tcx, QueryResponse<'tcx, Self::QueryResponse>> {
60-
lifted_query_result
61-
}
6256
}
6357

6458
BraceStructTypeFoldableImpl! {

src/librustc/traits/query/type_op/prove_predicate.rs

+1-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::infer::canonical::{Canonical, Canonicalized, CanonicalizedQueryResponse, QueryResponse};
1+
use crate::infer::canonical::{Canonicalized, CanonicalizedQueryResponse};
22
use crate::traits::query::Fallible;
33
use crate::ty::{ParamEnvAnd, Predicate, TyCtxt};
44

@@ -43,12 +43,6 @@ impl<'tcx> super::QueryTypeOp<'tcx> for ProvePredicate<'tcx> {
4343
) -> Fallible<CanonicalizedQueryResponse<'tcx, ()>> {
4444
tcx.type_op_prove_predicate(canonicalized)
4545
}
46-
47-
fn shrink_to_tcx_lifetime(
48-
v: &'a CanonicalizedQueryResponse<'tcx, ()>,
49-
) -> &'a Canonical<'tcx, QueryResponse<'tcx, ()>> {
50-
v
51-
}
5246
}
5347

5448
BraceStructTypeFoldableImpl! {

src/librustc/traits/query/type_op/subtype.rs

+1-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::infer::canonical::{Canonical, Canonicalized, CanonicalizedQueryResponse, QueryResponse};
1+
use crate::infer::canonical::{Canonicalized, CanonicalizedQueryResponse};
22
use crate::traits::query::Fallible;
33
use crate::ty::{ParamEnvAnd, Ty, TyCtxt};
44

@@ -34,12 +34,6 @@ impl<'tcx> super::QueryTypeOp<'tcx> for Subtype<'tcx> {
3434
) -> Fallible<CanonicalizedQueryResponse<'tcx, ()>> {
3535
tcx.type_op_subtype(canonicalized)
3636
}
37-
38-
fn shrink_to_tcx_lifetime(
39-
v: &'a CanonicalizedQueryResponse<'tcx, ()>,
40-
) -> &'a Canonical<'tcx, QueryResponse<'tcx, ()>> {
41-
v
42-
}
4337
}
4438

4539
BraceStructTypeFoldableImpl! {

0 commit comments

Comments
 (0)