@@ -1014,7 +1014,11 @@ where
10141014 return Ok ( CandidateSource :: ParamEnv ( ParamEnvSource :: NonGlobal ) ) ;
10151015 }
10161016
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+ } ) {
10181022 ControlFlow :: Break ( Err ( NoSolution ) ) => Err ( NoSolution ) ,
10191023 ControlFlow :: Break ( Ok ( ( ) ) ) => Ok ( CandidateSource :: ParamEnv ( ParamEnvSource :: NonGlobal ) ) ,
10201024 ControlFlow :: Continue ( ( ) ) => Ok ( CandidateSource :: ParamEnv ( ParamEnvSource :: Global ) ) ,
@@ -1025,6 +1029,7 @@ where
10251029struct FindParamInClause < ' a , ' b , D : SolverDelegate < Interner = I > , I : Interner > {
10261030 ecx : & ' a mut EvalCtxt < ' b , D > ,
10271031 param_env : I :: ParamEnv ,
1032+ universes : Vec < Option < ty:: UniverseIndex > > ,
10281033}
10291034
10301035impl < D , I > TypeVisitor < I > for FindParamInClause < ' _ , ' _ , D , I >
@@ -1035,41 +1040,59 @@ where
10351040 type Result = ControlFlow < Result < ( ) , NoSolution > > ;
10361041
10371042 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 ( ( ) )
10411047 }
10421048
10431049 fn visit_ty ( & mut self , ty : I :: Ty ) -> Self :: Result {
1050+ let ty = self . ecx . replace_bound_vars ( ty, & mut self . universes ) ;
10441051 let Ok ( ty) = self . ecx . structurally_normalize_ty ( self . param_env , ty) else {
10451052 return ControlFlow :: Break ( Err ( NoSolution ) ) ;
10461053 } ;
10471054
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+ }
10501061 } else {
10511062 ty. super_visit_with ( self )
10521063 }
10531064 }
10541065
10551066 fn visit_const ( & mut self , ct : I :: Const ) -> Self :: Result {
1067+ let ct = self . ecx . replace_bound_vars ( ct, & mut self . universes ) ;
10561068 let Ok ( ct) = self . ecx . structurally_normalize_const ( self . param_env , ct) else {
10571069 return ControlFlow :: Break ( Err ( NoSolution ) ) ;
10581070 } ;
10591071
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+ }
10621078 } else {
10631079 ct. super_visit_with ( self )
10641080 }
10651081 }
10661082
10671083 fn visit_region ( & mut self , r : I :: Region ) -> Self :: Result {
10681084 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" )
10731096 }
10741097 }
10751098 }
0 commit comments