) -> bool { let dummy_cause = ObligationCause::misc(DUMMY_SP, ast::DUMMY_NODE_ID); <del> for (obligation, predicate) in nested .filter(|o| o.recursion_depth == 1) </del> <ins> for (obligation, mut predicate) in nested </ins> .map(|o| (o.clone(), o.predicate.clone())) { let is_new_pred = fresh_preds.insert(self.clean_pred(select.infcx(), predicate.clone())); <ins> // Resolve any inference variables that we can, to help selection succeed predicate = select.infcx().resolve_type_vars_if_possible(&predicate); // We only add a predicate as a user-displayable bound if // it involves a generic parameter, and doesn't contain // any inference variables. // // Displaying a bound involving a concrete type (instead of a generic // parameter) would be pointless, since it's always true // (e.g. u8: Copy) // Displaying an inference variable is impossible, since they're // an internal compiler detail without a defined visual representation // // We check this by calling is_of_param on the relevant types // from the various possible predicates </ins> match &predicate { &ty::Predicate::Trait(ref p) => { <del> let substs = &p.skip_binder().trait_ref.substs; </del> <ins> if self.is_param_no_infer(p.skip_binder().trait_ref.substs) && !only_projections && is_new_pred { </ins> <del> if self.is_of_param(substs) && !only_projections && is_new_pred { </del> self.add_user_pred(computed_preds, predicate); } predicates.push_back(p.clone()); } &ty::Predicate::Projection(p) => { <del> // If the projection isn't all type vars, then // we don't want to add it as a bound if self.is_of_param(p.skip_binder().projection_ty.substs) && is_new_pred { self.add_user_pred(computed_preds, predicate); } else { </del> <ins> debug!("evaluate_nested_obligations: examining projection predicate {:?}", predicate); // As described above, we only want to display // bounds which include a generic parameter but don't include // an inference variable. // Additionally, we check if we've seen this predicate before, // to avoid rendering duplicate bounds to the user. if self.is_param_no_infer(p.skip_binder().projection_ty.substs) && !p.ty().skip_binder().is_ty_infer() && is_new_pred { debug!("evaluate_nested_obligations: adding projection predicate to computed_preds: {:?}", predicate); // Under unusual circumstances, we can end up with a self-refeential // projection predicate. For example: // <T as MyType>::Value == <T as MyType>::Value // Not only is displaying this to the user pointless, // having it in the ParamEnv will cause an issue if we try to call // poly_project_and_unify_type on the predicate, since this kind of // predicate will normally never end up in a ParamEnv. // // For these reasons, we ignore these weird predicates, // ensuring that we're able to properly synthesize an auto trait impl if self.is_self_referential_projection(p) { debug!("evaluate_nested_obligations: encountered a projection predicate equating a type with itself! Skipping"); } else { self.add_user_pred(computed_preds, predicate); } } // We can only call poly_project_and_unify_type when our predicate's // Ty is an inference variable - otherwise, there won't be anything to // unify if p.ty().skip_binder().is_ty_infer() { debug!("Projecting and unifying projection predicate {:?}", predicate); </ins> match poly_project_and_unify_type(select, &obligation.with(p.clone())) { Err(e) => { debug!(