@@ -2321,11 +2321,10 @@ fn assoc_ty_own_obligations<'cx, 'tcx>(
23212321 nested : & mut Vec < PredicateObligation < ' tcx > > ,
23222322) {
23232323 let tcx = selcx. tcx ( ) ;
2324- for predicate in tcx
2324+ let own = tcx
23252325 . predicates_of ( obligation. predicate . item_def_id )
2326- . instantiate_own ( tcx, obligation. predicate . substs )
2327- . predicates
2328- {
2326+ . instantiate_own ( tcx, obligation. predicate . substs ) ;
2327+ for ( predicate, span) in std:: iter:: zip ( own. predicates , own. spans ) {
23292328 let normalized = normalize_with_depth_to (
23302329 selcx,
23312330 obligation. param_env ,
@@ -2334,9 +2333,30 @@ fn assoc_ty_own_obligations<'cx, 'tcx>(
23342333 predicate,
23352334 nested,
23362335 ) ;
2336+
2337+ let nested_cause = if matches ! (
2338+ obligation. cause. code( ) ,
2339+ super :: CompareImplItemObligation { .. }
2340+ | super :: CheckAssociatedTypeBounds { .. }
2341+ | super :: AscribeUserTypeProvePredicate ( ..)
2342+ ) {
2343+ obligation. cause . clone ( )
2344+ } else if span. is_dummy ( ) {
2345+ ObligationCause :: new (
2346+ obligation. cause . span ,
2347+ obligation. cause . body_id ,
2348+ super :: ItemObligation ( obligation. predicate . item_def_id ) ,
2349+ )
2350+ } else {
2351+ ObligationCause :: new (
2352+ obligation. cause . span ,
2353+ obligation. cause . body_id ,
2354+ super :: BindingObligation ( obligation. predicate . item_def_id , span) ,
2355+ )
2356+ } ;
23372357 nested. push ( Obligation :: with_depth (
23382358 tcx,
2339- obligation . cause . clone ( ) ,
2359+ nested_cause ,
23402360 obligation. recursion_depth + 1 ,
23412361 obligation. param_env ,
23422362 normalized,
0 commit comments