@@ -199,61 +199,30 @@ fn project_and_unify_type<'cx, 'tcx>(
199199 let mut obligations = vec ! [ ] ;
200200
201201 let infcx = selcx. infcx ( ) ;
202- match obligation. predicate . term {
203- ty:: Term :: Ty ( obligation_pred_ty) => {
204- let normalized_ty = match opt_normalize_projection_type (
205- selcx,
206- obligation. param_env ,
207- obligation. predicate . projection_ty ,
208- obligation. cause . clone ( ) ,
209- obligation. recursion_depth ,
210- & mut obligations,
211- ) {
212- Ok ( Some ( n) ) => n. ty ( ) . unwrap ( ) ,
213- Ok ( None ) => return Ok ( Ok ( None ) ) ,
214- Err ( InProgress ) => return Ok ( Err ( InProgress ) ) ,
215- } ;
216- debug ! ( ?normalized_ty, ?obligations, "project_and_unify_type result" ) ;
217- match infcx
218- . at ( & obligation. cause , obligation. param_env )
219- . eq ( normalized_ty, obligation_pred_ty)
220- {
221- Ok ( InferOk { obligations : inferred_obligations, value : ( ) } ) => {
222- obligations. extend ( inferred_obligations) ;
223- Ok ( Ok ( Some ( obligations) ) )
224- }
225- Err ( err) => {
226- debug ! ( "project_and_unify_type: equating types encountered error {:?}" , err) ;
227- Err ( MismatchedProjectionTypes { err } )
228- }
229- }
202+ let normalized = match opt_normalize_projection_type (
203+ selcx,
204+ obligation. param_env ,
205+ obligation. predicate . projection_ty ,
206+ obligation. cause . clone ( ) ,
207+ obligation. recursion_depth ,
208+ & mut obligations,
209+ ) {
210+ Ok ( Some ( n) ) => n,
211+ Ok ( None ) => return Ok ( Ok ( None ) ) ,
212+ Err ( InProgress ) => return Ok ( Err ( InProgress ) ) ,
213+ } ;
214+ debug ! ( ?normalized, ?obligations, "project_and_unify_type result" ) ;
215+ match infcx
216+ . at ( & obligation. cause , obligation. param_env )
217+ . eq ( normalized, obligation. predicate . term )
218+ {
219+ Ok ( InferOk { obligations : inferred_obligations, value : ( ) } ) => {
220+ obligations. extend ( inferred_obligations) ;
221+ Ok ( Ok ( Some ( obligations) ) )
230222 }
231- ty:: Term :: Const ( obligation_pred_const) => {
232- let normalized_const = match opt_normalize_projection_type (
233- selcx,
234- obligation. param_env ,
235- obligation. predicate . projection_ty ,
236- obligation. cause . clone ( ) ,
237- obligation. recursion_depth ,
238- & mut obligations,
239- ) {
240- Ok ( Some ( n) ) => n. ct ( ) . unwrap ( ) ,
241- Ok ( None ) => return Ok ( Ok ( None ) ) ,
242- Err ( InProgress ) => return Ok ( Err ( InProgress ) ) ,
243- } ;
244- match infcx
245- . at ( & obligation. cause , obligation. param_env )
246- . eq ( normalized_const, obligation_pred_const)
247- {
248- Ok ( InferOk { obligations : inferred_obligations, value : ( ) } ) => {
249- obligations. extend ( inferred_obligations) ;
250- Ok ( Ok ( Some ( obligations) ) )
251- }
252- Err ( err) => {
253- debug ! ( "project_and_unify_type: equating consts encountered error {:?}" , err) ;
254- Err ( MismatchedProjectionTypes { err } )
255- }
256- }
223+ Err ( err) => {
224+ debug ! ( "project_and_unify_type: equating types encountered error {:?}" , err) ;
225+ Err ( MismatchedProjectionTypes { err } )
257226 }
258227 }
259228}
@@ -934,6 +903,8 @@ fn opt_normalize_projection_type<'a, 'b, 'tcx>(
934903 // created (and hence the new ones will quickly be
935904 // discarded as duplicated). But when doing trait
936905 // evaluation this is not the case, and dropping the trait
906+ // evaluations can causes ICEs (e.g., #43132).
907+ debug ! ( ?ty, "found normalized ty" ) ;
937908 obligations. extend ( ty. obligations ) ;
938909 return Ok ( Some ( ty. value ) ) ;
939910 }
@@ -1127,6 +1098,8 @@ fn project<'cx, 'tcx>(
11271098 Ok ( Projected :: Progress ( confirm_candidate ( selcx, obligation, candidate) ) )
11281099 }
11291100 ProjectionCandidateSet :: None => Ok ( Projected :: NoProgress (
1101+ // FIXME(associated_const_generics): this may need to change in the future?
1102+ // need to investigate whether or not this is fine.
11301103 selcx
11311104 . tcx ( )
11321105 . mk_projection ( obligation. predicate . item_def_id , obligation. predicate . substs )
0 commit comments