@@ -51,9 +51,12 @@ pub enum SimplifiedType {
5151/// generic parameters as if they were inference variables in that case.
5252#[ derive( PartialEq , Eq , Debug , Clone , Copy ) ]
5353pub 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 ,
5760}
5861
5962/// During fast-rejection, we have the choice of treating projection types
@@ -67,13 +70,13 @@ pub enum TreatProjections {
6770 /// We must assume that the `impl<T> Trait<T> for <T as Id>::This`
6871 /// can apply to all self types so we don't return a simplified type
6972 /// for `<T as Id>::This`.
70- DefaultCandidate ,
73+ AsCandidateKey ,
7174 /// In the old solver we don't try to normalize projections
7275 /// when looking up impls and only access them by using the
7376 /// current self type. This means that if the self type is
7477 /// a projection which could later be normalized, we must not
7578 /// treat it as rigid.
76- DefaultLookup ,
79+ ForLookup ,
7780 /// We can treat projections in the self type as opaque as
7881 /// we separately look up impls for the normalized self type.
7982 NextSolverLookup ,
@@ -133,13 +136,13 @@ pub fn simplify_type<'tcx>(
133136 ty:: FnPtr ( f) => Some ( FunctionSimplifiedType ( f. skip_binder ( ) . inputs ( ) . len ( ) ) ) ,
134137 ty:: Placeholder ( ..) => Some ( PlaceholderSimplifiedType ) ,
135138 ty:: Param ( _) => match treat_params {
136- TreatParams :: AsPlaceholder => Some ( PlaceholderSimplifiedType ) ,
137- TreatParams :: AsInfer => None ,
139+ TreatParams :: ForLookup => Some ( PlaceholderSimplifiedType ) ,
140+ TreatParams :: AsCandidateKey => None ,
138141 } ,
139142 ty:: Alias ( ..) => match treat_projections {
140- TreatProjections :: DefaultLookup if !ty. needs_infer ( ) => Some ( PlaceholderSimplifiedType ) ,
143+ TreatProjections :: ForLookup if !ty. needs_infer ( ) => Some ( PlaceholderSimplifiedType ) ,
141144 TreatProjections :: NextSolverLookup => Some ( PlaceholderSimplifiedType ) ,
142- TreatProjections :: DefaultCandidate | TreatProjections :: DefaultLookup => None ,
145+ TreatProjections :: AsCandidateKey | TreatProjections :: ForLookup => None ,
143146 } ,
144147 ty:: Foreign ( def_id) => Some ( ForeignSimplifiedType ( def_id) ) ,
145148 ty:: Bound ( ..) | ty:: Infer ( _) | ty:: Error ( _) => None ,
@@ -307,8 +310,8 @@ impl DeepRejectCtxt {
307310 // Depending on the value of `treat_obligation_params`, we either
308311 // treat generic parameters like placeholders or like inference variables.
309312 ty:: Param ( _) => match self . treat_obligation_params {
310- TreatParams :: AsPlaceholder => false ,
311- TreatParams :: AsInfer => true ,
313+ TreatParams :: ForLookup => false ,
314+ TreatParams :: AsCandidateKey => true ,
312315 } ,
313316
314317 ty:: Infer ( _) => true ,
@@ -345,8 +348,8 @@ impl DeepRejectCtxt {
345348 let k = impl_ct. kind ( ) ;
346349 match obligation_ct. kind ( ) {
347350 ty:: ConstKind :: Param ( _) => match self . treat_obligation_params {
348- TreatParams :: AsPlaceholder => false ,
349- TreatParams :: AsInfer => true ,
351+ TreatParams :: ForLookup => false ,
352+ TreatParams :: AsCandidateKey => true ,
350353 } ,
351354
352355 // As we don't necessarily eagerly evaluate constants,
0 commit comments