@@ -1014,7 +1014,11 @@ where
1014
1014
return Ok ( CandidateSource :: ParamEnv ( ParamEnvSource :: NonGlobal ) ) ;
1015
1015
}
1016
1016
1017
- match assumption. visit_with ( & mut FindParamInClause { ecx : self , param_env } ) {
1017
+ match assumption. visit_with ( & mut FindParamInClause {
1018
+ ecx : self ,
1019
+ param_env,
1020
+ universes : vec ! [ ] ,
1021
+ } ) {
1018
1022
ControlFlow :: Break ( Err ( NoSolution ) ) => Err ( NoSolution ) ,
1019
1023
ControlFlow :: Break ( Ok ( ( ) ) ) => Ok ( CandidateSource :: ParamEnv ( ParamEnvSource :: NonGlobal ) ) ,
1020
1024
ControlFlow :: Continue ( ( ) ) => Ok ( CandidateSource :: ParamEnv ( ParamEnvSource :: Global ) ) ,
@@ -1025,6 +1029,7 @@ where
1025
1029
struct FindParamInClause < ' a , ' b , D : SolverDelegate < Interner = I > , I : Interner > {
1026
1030
ecx : & ' a mut EvalCtxt < ' b , D > ,
1027
1031
param_env : I :: ParamEnv ,
1032
+ universes : Vec < Option < ty:: UniverseIndex > > ,
1028
1033
}
1029
1034
1030
1035
impl < D , I > TypeVisitor < I > for FindParamInClause < ' _ , ' _ , D , I >
@@ -1035,41 +1040,59 @@ where
1035
1040
type Result = ControlFlow < Result < ( ) , NoSolution > > ;
1036
1041
1037
1042
fn visit_binder < T : TypeFoldable < I > > ( & mut self , t : & ty:: Binder < I , T > ) -> Self :: Result {
1038
- self . ecx . enter_forall ( t. clone ( ) , |ecx, v| {
1039
- v. visit_with ( & mut FindParamInClause { ecx, param_env : self . param_env } )
1040
- } )
1043
+ self . universes . push ( None ) ;
1044
+ t. super_visit_with ( self ) ?;
1045
+ self . universes . pop ( ) ;
1046
+ ControlFlow :: Continue ( ( ) )
1041
1047
}
1042
1048
1043
1049
fn visit_ty ( & mut self , ty : I :: Ty ) -> Self :: Result {
1050
+ let ty = self . ecx . replace_bound_vars ( ty, & mut self . universes ) ;
1044
1051
let Ok ( ty) = self . ecx . structurally_normalize_ty ( self . param_env , ty) else {
1045
1052
return ControlFlow :: Break ( Err ( NoSolution ) ) ;
1046
1053
} ;
1047
1054
1048
- if let ty:: Placeholder ( _) = ty. kind ( ) {
1049
- ControlFlow :: Break ( Ok ( ( ) ) )
1055
+ if let ty:: Placeholder ( p) = ty. kind ( ) {
1056
+ if p. universe ( ) == ty:: UniverseIndex :: ROOT {
1057
+ ControlFlow :: Break ( Ok ( ( ) ) )
1058
+ } else {
1059
+ ControlFlow :: Continue ( ( ) )
1060
+ }
1050
1061
} else {
1051
1062
ty. super_visit_with ( self )
1052
1063
}
1053
1064
}
1054
1065
1055
1066
fn visit_const ( & mut self , ct : I :: Const ) -> Self :: Result {
1067
+ let ct = self . ecx . replace_bound_vars ( ct, & mut self . universes ) ;
1056
1068
let Ok ( ct) = self . ecx . structurally_normalize_const ( self . param_env , ct) else {
1057
1069
return ControlFlow :: Break ( Err ( NoSolution ) ) ;
1058
1070
} ;
1059
1071
1060
- if let ty:: ConstKind :: Placeholder ( _) = ct. kind ( ) {
1061
- ControlFlow :: Break ( Ok ( ( ) ) )
1072
+ if let ty:: ConstKind :: Placeholder ( p) = ct. kind ( ) {
1073
+ if p. universe ( ) == ty:: UniverseIndex :: ROOT {
1074
+ ControlFlow :: Break ( Ok ( ( ) ) )
1075
+ } else {
1076
+ ControlFlow :: Continue ( ( ) )
1077
+ }
1062
1078
} else {
1063
1079
ct. super_visit_with ( self )
1064
1080
}
1065
1081
}
1066
1082
1067
1083
fn visit_region ( & mut self , r : I :: Region ) -> Self :: Result {
1068
1084
match self . ecx . eager_resolve_region ( r) . kind ( ) {
1069
- ty:: ReStatic | ty:: ReError ( _) => ControlFlow :: Continue ( ( ) ) ,
1070
- ty:: ReVar ( _) | ty:: RePlaceholder ( _) => ControlFlow :: Break ( Ok ( ( ) ) ) ,
1071
- ty:: ReErased | ty:: ReEarlyParam ( _) | ty:: ReLateParam ( _) | ty:: ReBound ( ..) => {
1072
- unreachable ! ( )
1085
+ ty:: ReStatic | ty:: ReError ( _) | ty:: ReBound ( ..) => ControlFlow :: Continue ( ( ) ) ,
1086
+ ty:: RePlaceholder ( p) => {
1087
+ if p. universe ( ) == ty:: UniverseIndex :: ROOT {
1088
+ ControlFlow :: Break ( Ok ( ( ) ) )
1089
+ } else {
1090
+ ControlFlow :: Continue ( ( ) )
1091
+ }
1092
+ }
1093
+ ty:: ReVar ( _) => ControlFlow :: Break ( Ok ( ( ) ) ) ,
1094
+ ty:: ReErased | ty:: ReEarlyParam ( _) | ty:: ReLateParam ( _) => {
1095
+ unreachable ! ( "unexpected region in param-env clause" )
1073
1096
}
1074
1097
}
1075
1098
}
0 commit comments