@@ -123,7 +123,7 @@ where
123
123
result : Ok ( candidate. result ) ,
124
124
} ,
125
125
Err ( NoSolution ) => inspect:: ProbeKind :: TraitCandidate {
126
- source : CandidateSource :: BuiltinImpl ( BuiltinImplSource :: Misc ) ,
126
+ source : CandidateSource :: ParamEnv ( ParamEnvSource :: Global ) ,
127
127
result : Err ( NoSolution ) ,
128
128
} ,
129
129
} )
@@ -157,7 +157,7 @@ where
157
157
}
158
158
159
159
/// Try to reject the assumption based off of simple heuristics, such as [`ty::ClauseKind`]
160
- /// and [`I:: DefId`] .
160
+ /// and ` DefId`.
161
161
fn fast_reject_assumption (
162
162
ecx : & mut EvalCtxt < ' _ , D > ,
163
163
goal : Goal < I , Self > ,
@@ -990,12 +990,26 @@ where
990
990
}
991
991
}
992
992
993
+ /// Compute whether a param-env assumption is global or non-global after normalizing it.
994
+ ///
995
+ /// This is necessary because, for example, given:
996
+ ///
997
+ /// ```ignore,rust
998
+ /// where
999
+ /// T: Trait<Assoc = u32>,
1000
+ /// i32: From<T::Assoc>,
1001
+ /// ```
1002
+ ///
1003
+ /// The `i32: From<T::Assoc>` bound is non-global before normalization, but is global after.
1004
+ /// Since the old trait solver normalized param-envs eagerly, we want to emulate this
1005
+ /// behavior lazily.
993
1006
fn characterize_param_env_assumption (
994
1007
& mut self ,
995
1008
param_env : I :: ParamEnv ,
996
1009
assumption : I :: Clause ,
997
1010
) -> Result < CandidateSource < I > , NoSolution > {
998
- // FIXME:
1011
+ // FIXME: This should be fixed, but it also requires changing the behavior
1012
+ // in the old solver which is currently relied on.
999
1013
if assumption. has_bound_vars ( ) {
1000
1014
return Ok ( CandidateSource :: ParamEnv ( ParamEnvSource :: NonGlobal ) ) ;
1001
1015
}
@@ -1030,7 +1044,6 @@ where
1030
1044
let Ok ( ty) = self . ecx . structurally_normalize_ty ( self . param_env , ty) else {
1031
1045
return ControlFlow :: Break ( Err ( NoSolution ) ) ;
1032
1046
} ;
1033
- let ty = self . ecx . eager_resolve ( ty) ;
1034
1047
1035
1048
if let ty:: Placeholder ( _) = ty. kind ( ) {
1036
1049
ControlFlow :: Break ( Ok ( ( ) ) )
@@ -1043,7 +1056,6 @@ where
1043
1056
let Ok ( ct) = self . ecx . structurally_normalize_const ( self . param_env , ct) else {
1044
1057
return ControlFlow :: Break ( Err ( NoSolution ) ) ;
1045
1058
} ;
1046
- let ct = self . ecx . eager_resolve ( ct) ;
1047
1059
1048
1060
if let ty:: ConstKind :: Placeholder ( _) = ct. kind ( ) {
1049
1061
ControlFlow :: Break ( Ok ( ( ) ) )
@@ -1053,7 +1065,7 @@ where
1053
1065
}
1054
1066
1055
1067
fn visit_region ( & mut self , r : I :: Region ) -> Self :: Result {
1056
- match r . kind ( ) {
1068
+ match self . ecx . eager_resolve_region ( r ) . kind ( ) {
1057
1069
ty:: ReStatic | ty:: ReError ( _) => ControlFlow :: Continue ( ( ) ) ,
1058
1070
ty:: ReVar ( _) | ty:: RePlaceholder ( _) => ControlFlow :: Break ( Ok ( ( ) ) ) ,
1059
1071
ty:: ReErased | ty:: ReEarlyParam ( _) | ty:: ReLateParam ( _) | ty:: ReBound ( ..) => {
0 commit comments