@@ -51,9 +51,12 @@ pub enum SimplifiedType {
51
51
/// generic parameters as if they were inference variables in that case.
52
52
#[ derive( PartialEq , Eq , Debug , Clone , Copy ) ]
53
53
pub enum TreatParams {
54
- /// Treat parameters as placeholders in the given environment.
55
- AsPlaceholder ,
56
- AsInfer ,
54
+ /// Treat parameters as infer vars. This is the correct mode for caching
55
+ /// an impl's type for lookup.
56
+ AsCandidateKey ,
57
+ /// Treat parameters as placeholders in the given environment. This is the
58
+ /// correct mode for *lookup*, as during candidate selection.
59
+ ForLookup ,
57
60
}
58
61
59
62
/// During fast-rejection, we have the choice of treating projection types
@@ -67,13 +70,13 @@ pub enum TreatProjections {
67
70
/// We must assume that the `impl<T> Trait<T> for <T as Id>::This`
68
71
/// can apply to all self types so we don't return a simplified type
69
72
/// for `<T as Id>::This`.
70
- DefaultCandidate ,
73
+ AsCandidateKey ,
71
74
/// In the old solver we don't try to normalize projections
72
75
/// when looking up impls and only access them by using the
73
76
/// current self type. This means that if the self type is
74
77
/// a projection which could later be normalized, we must not
75
78
/// treat it as rigid.
76
- DefaultLookup ,
79
+ ForLookup ,
77
80
/// We can treat projections in the self type as opaque as
78
81
/// we separately look up impls for the normalized self type.
79
82
NextSolverLookup ,
@@ -133,13 +136,13 @@ pub fn simplify_type<'tcx>(
133
136
ty:: FnPtr ( f) => Some ( FunctionSimplifiedType ( f. skip_binder ( ) . inputs ( ) . len ( ) ) ) ,
134
137
ty:: Placeholder ( ..) => Some ( PlaceholderSimplifiedType ) ,
135
138
ty:: Param ( _) => match treat_params {
136
- TreatParams :: AsPlaceholder => Some ( PlaceholderSimplifiedType ) ,
137
- TreatParams :: AsInfer => None ,
139
+ TreatParams :: ForLookup => Some ( PlaceholderSimplifiedType ) ,
140
+ TreatParams :: AsCandidateKey => None ,
138
141
} ,
139
142
ty:: Alias ( ..) => match treat_projections {
140
- TreatProjections :: DefaultLookup if !ty. needs_infer ( ) => Some ( PlaceholderSimplifiedType ) ,
143
+ TreatProjections :: ForLookup if !ty. needs_infer ( ) => Some ( PlaceholderSimplifiedType ) ,
141
144
TreatProjections :: NextSolverLookup => Some ( PlaceholderSimplifiedType ) ,
142
- TreatProjections :: DefaultCandidate | TreatProjections :: DefaultLookup => None ,
145
+ TreatProjections :: AsCandidateKey | TreatProjections :: ForLookup => None ,
143
146
} ,
144
147
ty:: Foreign ( def_id) => Some ( ForeignSimplifiedType ( def_id) ) ,
145
148
ty:: Bound ( ..) | ty:: Infer ( _) | ty:: Error ( _) => None ,
@@ -307,8 +310,8 @@ impl DeepRejectCtxt {
307
310
// Depending on the value of `treat_obligation_params`, we either
308
311
// treat generic parameters like placeholders or like inference variables.
309
312
ty:: Param ( _) => match self . treat_obligation_params {
310
- TreatParams :: AsPlaceholder => false ,
311
- TreatParams :: AsInfer => true ,
313
+ TreatParams :: ForLookup => false ,
314
+ TreatParams :: AsCandidateKey => true ,
312
315
} ,
313
316
314
317
ty:: Infer ( _) => true ,
@@ -345,8 +348,8 @@ impl DeepRejectCtxt {
345
348
let k = impl_ct. kind ( ) ;
346
349
match obligation_ct. kind ( ) {
347
350
ty:: ConstKind :: Param ( _) => match self . treat_obligation_params {
348
- TreatParams :: AsPlaceholder => false ,
349
- TreatParams :: AsInfer => true ,
351
+ TreatParams :: ForLookup => false ,
352
+ TreatParams :: AsCandidateKey => true ,
350
353
} ,
351
354
352
355
// As we don't necessarily eagerly evaluate constants,
0 commit comments