@@ -1400,8 +1400,17 @@ fn assemble_candidates_from_impls<'cx, 'tcx>(
14001400 // Any type with multiple potential metadata types is therefore not eligible.
14011401 let self_ty = selcx. infcx ( ) . shallow_resolve ( obligation. predicate . self_ty ( ) ) ;
14021402
1403- // FIXME: should this normalize?
1404- let tail = selcx. tcx ( ) . struct_tail_without_normalization ( self_ty) ;
1403+ let tail = selcx. tcx ( ) . struct_tail_with_normalize ( self_ty, |ty| {
1404+ normalize_with_depth (
1405+ selcx,
1406+ obligation. param_env ,
1407+ obligation. cause . clone ( ) ,
1408+ obligation. recursion_depth + 1 ,
1409+ ty,
1410+ )
1411+ . value
1412+ } ) ;
1413+
14051414 match tail. kind ( ) {
14061415 ty:: Bool
14071416 | ty:: Char
@@ -1435,7 +1444,12 @@ fn assemble_candidates_from_impls<'cx, 'tcx>(
14351444 | ty:: Bound ( ..)
14361445 | ty:: Placeholder ( ..)
14371446 | ty:: Infer ( ..)
1438- | ty:: Error ( _) => false ,
1447+ | ty:: Error ( _) => {
1448+ if tail. has_infer_types ( ) {
1449+ candidate_set. mark_ambiguous ( ) ;
1450+ }
1451+ false
1452+ } ,
14391453 }
14401454 }
14411455 super :: ImplSource :: Param ( ..) => {
@@ -1640,18 +1654,30 @@ fn confirm_pointee_candidate<'cx, 'tcx>(
16401654 _: ImplSourcePointeeData ,
16411655) -> Progress < ' tcx > {
16421656 let tcx = selcx. tcx ( ) ;
1643-
16441657 let self_ty = selcx. infcx ( ) . shallow_resolve ( obligation. predicate . self_ty ( ) ) ;
1645- let substs = tcx. mk_substs ( [ self_ty. into ( ) ] . iter ( ) ) ;
16461658
1659+ let mut obligations = vec ! [ ] ;
1660+ let metadata_ty = self_ty. ptr_metadata_ty ( tcx, |ty| {
1661+ normalize_with_depth_to (
1662+ selcx,
1663+ obligation. param_env ,
1664+ obligation. cause . clone ( ) ,
1665+ obligation. recursion_depth + 1 ,
1666+ ty,
1667+ & mut obligations,
1668+ )
1669+ } ) ;
1670+
1671+ let substs = tcx. mk_substs ( [ self_ty. into ( ) ] . iter ( ) ) ;
16471672 let metadata_def_id = tcx. require_lang_item ( LangItem :: Metadata , None ) ;
16481673
16491674 let predicate = ty:: ProjectionPredicate {
16501675 projection_ty : ty:: ProjectionTy { substs, item_def_id : metadata_def_id } ,
1651- ty : self_ty . ptr_metadata_ty ( tcx ) ,
1676+ ty : metadata_ty ,
16521677 } ;
16531678
16541679 confirm_param_env_candidate ( selcx, obligation, ty:: Binder :: dummy ( predicate) , false )
1680+ . with_addl_obligations ( obligations)
16551681}
16561682
16571683fn confirm_fn_pointer_candidate < ' cx , ' tcx > (
0 commit comments