Auto merge of #131748 - lcnr:typing-mode, r= · rust-lang/rust@1001cfb (original) (raw)
`@@ -3,12 +3,16 @@ use std::rc::Rc;
`
3
3
``
4
4
`use rustc_errors::Diag;
`
5
5
`use rustc_hir::def_id::LocalDefId;
`
6
``
`-
use rustc_infer::infer::canonical::Canonical;
`
``
6
`+
use rustc_infer::infer::canonical::CanonicalQueryInput;
`
7
7
`use rustc_infer::infer::region_constraints::{Constraint, RegionConstraintData};
`
8
8
`use rustc_infer::infer::{
`
9
9
`InferCtxt, RegionResolutionError, RegionVariableOrigin, SubregionOrigin, TyCtxtInferExt as _,
`
10
10
`};
`
11
11
`use rustc_infer::traits::ObligationCause;
`
``
12
`+
use rustc_infer::traits::query::{
`
``
13
`+
CanonicalTypeOpAscribeUserTypeGoal, CanonicalTypeOpNormalizeGoal,
`
``
14
`+
CanonicalTypeOpProvePredicateGoal,
`
``
15
`+
};
`
12
16
`use rustc_middle::ty::error::TypeError;
`
13
17
`use rustc_middle::ty::{
`
14
18
`self, RePlaceholder, Region, RegionVid, Ty, TyCtxt, TypeFoldable, UniverseIndex,
`
`@@ -95,9 +99,7 @@ impl<'tcx> ToUniverseInfo<'tcx> for crate::type_check::InstantiateOpaqueType<'tc
`
95
99
`}
`
96
100
`}
`
97
101
``
98
``
`-
impl<'tcx> ToUniverseInfo<'tcx>
`
99
``
`-
for Canonical<'tcx, ty::ParamEnvAnd<'tcx, type_op::prove_predicate::ProvePredicate<'tcx>>>
`
100
``
`-
{
`
``
102
`+
impl<'tcx> ToUniverseInfo<'tcx> for CanonicalTypeOpProvePredicateGoal<'tcx> {
`
101
103
`fn to_universe_info(self, base_universe: ty::UniverseIndex) -> UniverseInfo<'tcx> {
`
102
104
`UniverseInfo(UniverseInfoInner::TypeOp(Rc::new(PredicateQuery {
`
103
105
`canonical_query: self,
`
`@@ -107,7 +109,7 @@ impl<'tcx> ToUniverseInfo<'tcx>
`
107
109
`}
`
108
110
``
109
111
`impl<'tcx, T: Copy + fmt::Display + TypeFoldable<TyCtxt<'tcx>> + 'tcx> ToUniverseInfo<'tcx>
`
110
``
`-
for Canonical<'tcx, ty::ParamEnvAnd<'tcx, type_op::Normalize>>
`
``
112
`+
for CanonicalTypeOpNormalizeGoal<'tcx, T>
`
111
113
`{
`
112
114
`fn to_universe_info(self, base_universe: ty::UniverseIndex) -> UniverseInfo<'tcx> {
`
113
115
`UniverseInfo(UniverseInfoInner::TypeOp(Rc::new(NormalizeQuery {
`
`@@ -117,9 +119,7 @@ impl<'tcx, T: Copy + fmt::Display + TypeFoldable<TyCtxt<'tcx>> + 'tcx> ToUnivers
`
117
119
`}
`
118
120
`}
`
119
121
``
120
``
`-
impl<'tcx> ToUniverseInfo<'tcx>
`
121
``
`-
for Canonical<'tcx, ty::ParamEnvAnd<'tcx, type_op::AscribeUserType<'tcx>>>
`
122
``
`-
{
`
``
122
`+
impl<'tcx> ToUniverseInfo<'tcx> for CanonicalTypeOpAscribeUserTypeGoal<'tcx> {
`
123
123
`fn to_universe_info(self, base_universe: ty::UniverseIndex) -> UniverseInfo<'tcx> {
`
124
124
`UniverseInfo(UniverseInfoInner::TypeOp(Rc::new(AscribeUserTypeQuery {
`
125
125
`canonical_query: self,
`
`@@ -128,7 +128,7 @@ impl<'tcx> ToUniverseInfo<'tcx>
`
128
128
`}
`
129
129
`}
`
130
130
``
131
``
`-
impl<'tcx, F> ToUniverseInfo<'tcx> for Canonical<'tcx, type_op::custom::CustomTypeOp> {
`
``
131
`+
impl<'tcx, F> ToUniverseInfo<'tcx> for CanonicalQueryInput<'tcx, type_op::custom::CustomTypeOp> {
`
132
132
`fn to_universe_info(self, _base_universe: ty::UniverseIndex) -> UniverseInfo<'tcx> {
`
133
133
`// We can't rerun custom type ops.
`
134
134
`UniverseInfo::other()
`
`@@ -211,16 +211,15 @@ trait TypeOpInfo<'tcx> {
`
211
211
`}
`
212
212
``
213
213
`struct PredicateQuery<'tcx> {
`
214
``
`-
canonical_query:
`
215
``
`-
Canonical<'tcx, ty::ParamEnvAnd<'tcx, type_op::prove_predicate::ProvePredicate<'tcx>>>,
`
``
214
`+
canonical_query: CanonicalTypeOpProvePredicateGoal<'tcx>,
`
216
215
`base_universe: ty::UniverseIndex,
`
217
216
`}
`
218
217
``
219
218
`impl<'tcx> TypeOpInfo<'tcx> for PredicateQuery<'tcx> {
`
220
219
`fn fallback_error(&self, tcx: TyCtxt<'tcx>, span: Span) -> Diag<'tcx> {
`
221
220
` tcx.dcx().create_err(HigherRankedLifetimeError {
`
222
221
`cause: Some(HigherRankedErrorCause::CouldNotProve {
`
223
``
`-
predicate: self.canonical_query.value.value.predicate.to_string(),
`
``
222
`+
predicate: self.canonical_query.canonical.value.value.predicate.to_string(),
`
224
223
`}),
`
225
224
` span,
`
226
225
`})
`
`@@ -253,7 +252,7 @@ impl<'tcx> TypeOpInfo<'tcx> for PredicateQuery<'tcx> {
`
253
252
`}
`
254
253
``
255
254
`struct NormalizeQuery<'tcx, T> {
`
256
``
`-
canonical_query: Canonical<'tcx, ty::ParamEnvAnd<'tcx, type_op::Normalize>>,
`
``
255
`+
canonical_query: CanonicalTypeOpNormalizeGoal<'tcx, T>,
`
257
256
`base_universe: ty::UniverseIndex,
`
258
257
`}
`
259
258
``
`@@ -264,7 +263,7 @@ where
`
264
263
`fn fallback_error(&self, tcx: TyCtxt<'tcx>, span: Span) -> Diag<'tcx> {
`
265
264
` tcx.dcx().create_err(HigherRankedLifetimeError {
`
266
265
`cause: Some(HigherRankedErrorCause::CouldNotNormalize {
`
267
``
`-
value: self.canonical_query.value.value.value.to_string(),
`
``
266
`+
value: self.canonical_query.canonical.value.value.value.to_string(),
`
268
267
`}),
`
269
268
` span,
`
270
269
`})
`
`@@ -306,7 +305,7 @@ where
`
306
305
`}
`
307
306
``
308
307
`struct AscribeUserTypeQuery<'tcx> {
`
309
``
`-
canonical_query: Canonical<'tcx, ty::ParamEnvAnd<'tcx, type_op::AscribeUserType<'tcx>>>,
`
``
308
`+
canonical_query: CanonicalTypeOpAscribeUserTypeGoal<'tcx>,
`
310
309
`base_universe: ty::UniverseIndex,
`
311
310
`}
`
312
311
``