@@ -211,29 +211,18 @@ pub fn compare_impl_method<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
211211 return ;
212212 }
213213
214- // Depend on trait/impl predicates always being before method's own predicates,
215- // to be able to split method predicates into "inherited" and method-specific.
216- let trait_predicates = tcx. lookup_predicates ( trait_m. container_id ( ) ) . predicates ;
217- let impl_predicates = tcx. lookup_predicates ( impl_m. container_id ( ) ) . predicates ;
218- let trait_method_start = trait_predicates. len ( ) ;
219- let impl_method_start = impl_predicates. len ( ) ;
220- assert_eq ! ( & trait_predicates[ ..] , & trait_m. predicates. predicates[ ..trait_method_start] ) ;
221- assert_eq ! ( & impl_predicates[ ..] , & impl_m. predicates. predicates[ ..impl_method_start] ) ;
222-
223214 tcx. infer_ctxt ( None , None , Reveal :: NotSpecializable ) . enter ( |mut infcx| {
224215 let mut fulfillment_cx = traits:: FulfillmentContext :: new ( ) ;
225216
226- // Normalize the associated types in the trait_bounds.
227- let trait_bounds = trait_m. predicates . instantiate ( tcx, trait_to_skol_substs) ;
228-
229217 // Create obligations for each predicate declared by the impl
230218 // definition in the context of the trait's parameter
231219 // environment. We can't just use `impl_env.caller_bounds`,
232220 // however, because we want to replace all late-bound regions with
233221 // region variables.
234- let impl_bounds = impl_m. predicates . instantiate ( tcx, impl_to_skol_substs) ;
222+ let impl_predicates = tcx. lookup_predicates ( impl_m. predicates . parent . unwrap ( ) ) ;
223+ let mut hybrid_preds = impl_predicates. instantiate ( tcx, impl_to_skol_substs) ;
235224
236- debug ! ( "compare_impl_method: impl_bounds={:?}" , impl_bounds ) ;
225+ debug ! ( "compare_impl_method: impl_bounds={:?}" , hybrid_preds ) ;
237226
238227 // This is the only tricky bit of the new way we check implementation methods
239228 // We need to build a set of predicates where only the FnSpace bounds
@@ -242,14 +231,14 @@ pub fn compare_impl_method<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
242231 //
243232 // We then register the obligations from the impl_m and check to see
244233 // if all constraints hold.
245- let hybrid_preds = impl_bounds . predicates [ ..impl_method_start ] . iter ( )
246- . chain ( trait_bounds . predicates [ trait_method_start.. ] . iter ( ) ) ;
234+ hybrid_preds. predicates . extend (
235+ trait_m . predicates . instantiate_own ( tcx , trait_to_skol_substs ) . predicates ) ;
247236
248237 // Construct trait parameter environment and then shift it into the skolemized viewpoint.
249238 // The key step here is to update the caller_bounds's predicates to be
250239 // the new hybrid bounds we computed.
251240 let normalize_cause = traits:: ObligationCause :: misc ( impl_m_span, impl_m_body_id) ;
252- let trait_param_env = impl_param_env. with_caller_bounds ( hybrid_preds. cloned ( ) . collect ( ) ) ;
241+ let trait_param_env = impl_param_env. with_caller_bounds ( hybrid_preds. predicates ) ;
253242 let trait_param_env = traits:: normalize_param_env_or_error ( tcx,
254243 trait_param_env,
255244 normalize_cause. clone ( ) ) ;
@@ -261,12 +250,13 @@ pub fn compare_impl_method<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
261250
262251 let mut selcx = traits:: SelectionContext :: new ( & infcx) ;
263252
264- let ( impl_pred_fns, _) =
253+ let impl_m_own_bounds = impl_m. predicates . instantiate_own ( tcx, impl_to_skol_substs) ;
254+ let ( impl_m_own_bounds, _) =
265255 infcx. replace_late_bound_regions_with_fresh_var (
266256 impl_m_span,
267257 infer:: HigherRankedType ,
268- & ty:: Binder ( impl_bounds . predicates [ impl_method_start.. ] . to_vec ( ) ) ) ;
269- for predicate in impl_pred_fns {
258+ & ty:: Binder ( impl_m_own_bounds . predicates ) ) ;
259+ for predicate in impl_m_own_bounds {
270260 let traits:: Normalized { value : predicate, .. } =
271261 traits:: normalize ( & mut selcx, normalize_cause. clone ( ) , & predicate) ;
272262
0 commit comments