@@ -258,18 +258,6 @@ fn project_and_unify_type<'cx, 'tcx>(
258258 debug ! ( ?normalized, ?obligations, "project_and_unify_type result" ) ;
259259 let actual = obligation. predicate . term ;
260260
261- // For an example where this is neccessary see src/test/ui/impl-trait/nested-return-type2.rs
262- // This allows users to omit re-mentioning all bounds on an associated type and just use an
263- // `impl Trait` for the assoc type to add more bounds.
264- let InferOk { value : actual, obligations : new } =
265- selcx. infcx ( ) . replace_opaque_types_with_inference_vars (
266- actual,
267- obligation. cause . body_id ,
268- obligation. cause . span ,
269- obligation. param_env ,
270- ) ;
271- obligations. extend ( new) ;
272-
273261 if let Some ( ty) = normalized. ty ( ) {
274262 if let & ty:: Projection ( projection) = ty. kind ( ) {
275263 match opt_normalize_projection_type (
@@ -322,10 +310,32 @@ fn project_and_unify_type<'cx, 'tcx>(
322310 obligation. recursion_depth ,
323311 & mut obligations,
324312 ) {
325- Ok ( Some ( _) ) => infcx
326- . at ( & obligation. cause , obligation. param_env )
327- . trace ( ty, actual)
328- . eq ( projection, normed_other) ,
313+ Ok ( Some ( _) ) => {
314+ // For an example where this is neccessary see src/test/ui/impl-trait/nested-return-type2.rs
315+ // This allows users to omit re-mentioning all bounds on an associated type and just use an
316+ // `impl Trait` for the assoc type to add more bounds.
317+ let InferOk {
318+ value : s_opaque_infer_actual,
319+ obligations : new,
320+ } = selcx. infcx ( ) . replace_opaque_types_with_inference_vars (
321+ actual,
322+ obligation. cause . body_id ,
323+ obligation. cause . span ,
324+ obligation. param_env ,
325+ ) ;
326+ obligations. extend ( new) ;
327+
328+ let s_opaque_infer_actual =
329+ match s_opaque_infer_actual. kind ( ) {
330+ & ty:: Projection ( actual) => actual,
331+ _ => unreachable ! ( ) ,
332+ } ;
333+
334+ infcx
335+ . at ( & obligation. cause , obligation. param_env )
336+ . trace ( ty, actual)
337+ . eq ( projection, s_opaque_infer_actual)
338+ }
329339 Ok ( None ) => Ok ( flipped_projection_eq) ,
330340 Err ( InProgress ) => unreachable ! ( ) ,
331341 }
@@ -357,6 +367,18 @@ fn project_and_unify_type<'cx, 'tcx>(
357367 }
358368 }
359369
370+ // For an example where this is neccessary see src/test/ui/impl-trait/nested-return-type2.rs
371+ // This allows users to omit re-mentioning all bounds on an associated type and just use an
372+ // `impl Trait` for the assoc type to add more bounds.
373+ let InferOk { value : actual, obligations : new } =
374+ selcx. infcx ( ) . replace_opaque_types_with_inference_vars (
375+ actual,
376+ obligation. cause . body_id ,
377+ obligation. cause . span ,
378+ obligation. param_env ,
379+ ) ;
380+ obligations. extend ( new) ;
381+
360382 match infcx. at ( & obligation. cause , obligation. param_env ) . eq ( normalized, actual) {
361383 Ok ( InferOk { obligations : inferred_obligations, value : ( ) } ) => {
362384 obligations. extend ( inferred_obligations) ;
0 commit comments