1 use crate::astconv::AstConv;
2 use crate::bounds::Bounds;
3 use crate::collect::ItemCtxt;
4 use crate::constrained_generic_params as cgp;
5 use hir::{HirId, Node};
6 use rustc_data_structures::fx::FxIndexSet;
8 use rustc_hir::def::DefKind;
9 use rustc_hir::def_id::{DefId, LocalDefId};
10 use rustc_hir::intravisit::{self, Visitor};
11 use rustc_middle::ty::subst::InternalSubsts;
12 use rustc_middle::ty::ToPredicate;
13 use rustc_middle::ty::{self, Ty, TyCtxt};
14 use rustc_span::symbol::{sym, Ident};
15 use rustc_span::{Span, DUMMY_SP};
18 struct OnlySelfBounds(bool);
20 /// Returns a list of all type predicates (explicit and implicit) for the definition with
21 /// ID `def_id`. This includes all predicates returned by `predicates_defined_on`, plus
22 /// `Self: Trait` predicates for traits.
23 pub(super) fn predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericPredicates<'_> {
24 let mut result = tcx.predicates_defined_on(def_id);
26 if tcx.is_trait(def_id) {
27 // For traits, add `Self: Trait` predicate. This is
28 // not part of the predicates that a user writes, but it
29 // is something that one must prove in order to invoke a
30 // method or project an associated type.
32 // In the chalk setup, this predicate is not part of the
33 // "predicates" for a trait item. But it is useful in
34 // rustc because if you directly (e.g.) invoke a trait
35 // method like `Trait::method(...)`, you must naturally
36 // prove that the trait applies to the types that were
37 // used, and adding the predicate into this list ensures
40 // We use a DUMMY_SP here as a way to signal trait bounds that come
41 // from the trait itself that *shouldn't* be shown as the source of
42 // an obligation and instead be skipped. Otherwise we'd use
43 // `tcx.def_span(def_id);`
45 let constness = if tcx.has_attr(def_id, sym::const_trait) {
46 ty::BoundConstness::ConstIfConst
48 ty::BoundConstness::NotConst
51 let span = rustc_span::DUMMY_SP;
53 tcx.arena.alloc_from_iter(result.predicates.iter().copied().chain(std::iter::once((
54 ty::TraitRef::identity(tcx, def_id).with_constness(constness).to_predicate(tcx),
58 debug!("predicates_of(def_id={:?}) = {:?}", def_id, result);
62 /// Returns a list of user-specified type predicates for the definition with ID `def_id`.
63 /// N.B., this does not include any implied/inferred constraints.
64 #[instrument(level = "trace", skip(tcx), ret)]
65 fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericPredicates<'_> {
68 let hir_id = tcx.hir().local_def_id_to_hir_id(def_id.expect_local());
69 let node = tcx.hir().get(hir_id);
71 let mut is_trait = None;
72 let mut is_default_impl_trait = None;
74 let icx = ItemCtxt::new(tcx, def_id);
76 const NO_GENERICS: &hir::Generics<'_> = hir::Generics::empty();
78 // We use an `IndexSet` to preserves order of insertion.
79 // Preserving the order of insertion is important here so as not to break UI tests.
80 let mut predicates: FxIndexSet<(ty::Predicate<'_>, Span)> = FxIndexSet::default();
82 let ast_generics = match node {
83 Node::TraitItem(item) => item.generics,
85 Node::ImplItem(item) => item.generics,
89 ItemKind::Impl(ref impl_) => {
90 if impl_.defaultness.is_default() {
91 is_default_impl_trait = tcx.impl_trait_ref(def_id).map(ty::Binder::dummy);
95 ItemKind::Fn(.., ref generics, _)
96 | ItemKind::TyAlias(_, ref generics)
97 | ItemKind::Enum(_, ref generics)
98 | ItemKind::Struct(_, ref generics)
99 | ItemKind::Union(_, ref generics) => *generics,
101 ItemKind::Trait(_, _, ref generics, ..) => {
102 is_trait = Some(ty::TraitRef::identity(tcx, def_id));
105 ItemKind::TraitAlias(ref generics, _) => {
106 is_trait = Some(ty::TraitRef::identity(tcx, def_id));
109 ItemKind::OpaqueTy(OpaqueTy {
110 origin: hir::OpaqueTyOrigin::AsyncFn(..) | hir::OpaqueTyOrigin::FnReturn(..),
113 // return-position impl trait
115 // We don't inherit predicates from the parent here:
116 // If we have, say `fn f<'a, T: 'a>() -> impl Sized {}`
117 // then the return type is `f::<'static, T>::{{opaque}}`.
119 // If we inherited the predicates of `f` then we would
120 // require that `T: 'static` to show that the return
121 // type is well-formed.
123 // The only way to have something with this opaque type
124 // is from the return type of the containing function,
125 // which will ensure that the function's predicates
127 return ty::GenericPredicates { parent: None, predicates: &[] };
129 ItemKind::OpaqueTy(OpaqueTy {
131 origin: hir::OpaqueTyOrigin::TyAlias,
134 // type-alias impl trait
142 Node::ForeignItem(item) => match item.kind {
143 ForeignItemKind::Static(..) => NO_GENERICS,
144 ForeignItemKind::Fn(_, _, ref generics) => *generics,
145 ForeignItemKind::Type => NO_GENERICS,
151 let generics = tcx.generics_of(def_id);
152 let parent_count = generics.parent_count as u32;
153 let has_own_self = generics.has_self && parent_count == 0;
155 // Below we'll consider the bounds on the type parameters (including `Self`)
156 // and the explicit where-clauses, but to get the full set of predicates
157 // on a trait we need to add in the supertrait bounds and bounds found on
159 if let Some(_trait_ref) = is_trait {
160 predicates.extend(tcx.super_predicates_of(def_id).predicates.iter().cloned());
163 // In default impls, we can assume that the self type implements
166 // default impl Foo for Bar { .. }
168 // we add a default where clause `Foo: Bar`. We do a similar thing for traits
169 // (see below). Recall that a default impl is not itself an impl, but rather a
170 // set of defaults that can be incorporated into another impl.
171 if let Some(trait_ref) = is_default_impl_trait {
172 predicates.insert((trait_ref.without_const().to_predicate(tcx), tcx.def_span(def_id)));
175 // Collect the region predicates that were declared inline as
176 // well. In the case of parameters declared on a fn or method, we
177 // have to be careful to only iterate over early-bound regions.
178 let mut index = parent_count
179 + has_own_self as u32
180 + super::early_bound_lifetimes_from_generics(tcx, ast_generics).count() as u32;
183 trace!(?ast_generics);
185 // Collect the predicates that were written inline by the user on each
186 // type parameter (e.g., `<T: Foo>`).
187 for param in ast_generics.params {
189 // We already dealt with early bound lifetimes above.
190 GenericParamKind::Lifetime { .. } => (),
191 GenericParamKind::Type { .. } => {
192 let name = param.name.ident().name;
193 let param_ty = ty::ParamTy::new(index, name).to_ty(tcx);
196 let mut bounds = Bounds::default();
197 // Params are implicitly sized unless a `?Sized` bound is found
198 <dyn AstConv<'_>>::add_implicitly_sized(
202 Some((param.hir_id, ast_generics.predicates)),
206 predicates.extend(bounds.predicates(tcx, param_ty));
209 GenericParamKind::Const { .. } => {
210 // Bounds on const parameters are currently not possible.
217 // Add in the bounds that appear in the where-clause.
218 for predicate in ast_generics.predicates {
220 hir::WherePredicate::BoundPredicate(bound_pred) => {
221 let ty = icx.to_ty(bound_pred.bounded_ty);
222 let bound_vars = icx.tcx.late_bound_vars(bound_pred.hir_id);
224 // Keep the type around in a dummy predicate, in case of no bounds.
225 // That way, `where Ty:` is not a complete noop (see #53696) and `Ty`
226 // is still checked for WF.
227 if bound_pred.bounds.is_empty() {
228 if let ty::Param(_) = ty.kind() {
229 // This is a `where T:`, which can be in the HIR from the
230 // transformation that moves `?Sized` to `T`'s declaration.
231 // We can skip the predicate because type parameters are
232 // trivially WF, but also we *should*, to avoid exposing
233 // users who never wrote `where Type:,` themselves, to
234 // compiler/tooling bugs from not handling WF predicates.
236 let span = bound_pred.bounded_ty.span;
237 let predicate = ty::Binder::bind_with_vars(
238 ty::PredicateKind::WellFormed(ty.into()),
241 predicates.insert((predicate.to_predicate(tcx), span));
245 let mut bounds = Bounds::default();
246 <dyn AstConv<'_>>::add_bounds(
249 bound_pred.bounds.iter(),
253 predicates.extend(bounds.predicates(tcx, ty));
256 hir::WherePredicate::RegionPredicate(region_pred) => {
257 let r1 = <dyn AstConv<'_>>::ast_region_to_region(&icx, ®ion_pred.lifetime, None);
258 predicates.extend(region_pred.bounds.iter().map(|bound| {
259 let (r2, span) = match bound {
260 hir::GenericBound::Outlives(lt) => {
261 (<dyn AstConv<'_>>::ast_region_to_region(&icx, lt, None), lt.span)
265 let pred = ty::Binder::dummy(ty::PredicateKind::RegionOutlives(
266 ty::OutlivesPredicate(r1, r2),
268 .to_predicate(icx.tcx);
274 hir::WherePredicate::EqPredicate(..) => {
280 if tcx.features().generic_const_exprs {
281 predicates.extend(const_evaluatable_predicates_of(tcx, def_id.expect_local()));
284 let mut predicates: Vec<_> = predicates.into_iter().collect();
286 // Subtle: before we store the predicates into the tcx, we
287 // sort them so that predicates like `T: Foo<Item=U>` come
288 // before uses of `U`. This avoids false ambiguity errors
289 // in trait checking. See `setup_constraining_predicates`
291 if let Node::Item(&Item { kind: ItemKind::Impl { .. }, .. }) = node {
292 let self_ty = tcx.type_of(def_id);
293 let trait_ref = tcx.impl_trait_ref(def_id);
294 cgp::setup_constraining_predicates(
298 &mut cgp::parameters_for_impl(self_ty, trait_ref),
302 ty::GenericPredicates {
303 parent: generics.parent,
304 predicates: tcx.arena.alloc_from_iter(predicates),
308 fn const_evaluatable_predicates_of<'tcx>(
311 ) -> FxIndexSet<(ty::Predicate<'tcx>, Span)> {
312 struct ConstCollector<'tcx> {
314 preds: FxIndexSet<(ty::Predicate<'tcx>, Span)>,
317 impl<'tcx> intravisit::Visitor<'tcx> for ConstCollector<'tcx> {
318 fn visit_anon_const(&mut self, c: &'tcx hir::AnonConst) {
319 let def_id = self.tcx.hir().local_def_id(c.hir_id);
320 let ct = ty::Const::from_anon_const(self.tcx, def_id);
321 if let ty::ConstKind::Unevaluated(_) = ct.kind() {
322 let span = self.tcx.hir().span(c.hir_id);
324 ty::Binder::dummy(ty::PredicateKind::ConstEvaluatable(ct))
325 .to_predicate(self.tcx),
331 fn visit_const_param_default(&mut self, _param: HirId, _ct: &'tcx hir::AnonConst) {
332 // Do not look into const param defaults,
333 // these get checked when they are actually instantiated.
335 // We do not want the following to error:
337 // struct Foo<const N: usize, const M: usize = { N + 1 }>;
338 // struct Bar<const N: usize>(Foo<N, 3>);
342 let hir_id = tcx.hir().local_def_id_to_hir_id(def_id);
343 let node = tcx.hir().get(hir_id);
345 let mut collector = ConstCollector { tcx, preds: FxIndexSet::default() };
346 if let hir::Node::Item(item) = node && let hir::ItemKind::Impl(ref impl_) = item.kind {
347 if let Some(of_trait) = &impl_.of_trait {
348 debug!("const_evaluatable_predicates_of({:?}): visit impl trait_ref", def_id);
349 collector.visit_trait_ref(of_trait);
352 debug!("const_evaluatable_predicates_of({:?}): visit_self_ty", def_id);
353 collector.visit_ty(impl_.self_ty);
356 if let Some(generics) = node.generics() {
357 debug!("const_evaluatable_predicates_of({:?}): visit_generics", def_id);
358 collector.visit_generics(generics);
361 if let Some(fn_sig) = tcx.hir().fn_sig_by_hir_id(hir_id) {
362 debug!("const_evaluatable_predicates_of({:?}): visit_fn_decl", def_id);
363 collector.visit_fn_decl(fn_sig.decl);
365 debug!("const_evaluatable_predicates_of({:?}) = {:?}", def_id, collector.preds);
370 pub(super) fn trait_explicit_predicates_and_bounds(
373 ) -> ty::GenericPredicates<'_> {
374 assert_eq!(tcx.def_kind(def_id), DefKind::Trait);
375 gather_explicit_predicates_of(tcx, def_id.to_def_id())
378 pub(super) fn explicit_predicates_of<'tcx>(
381 ) -> ty::GenericPredicates<'tcx> {
382 let def_kind = tcx.def_kind(def_id);
383 if let DefKind::Trait = def_kind {
384 // Remove bounds on associated types from the predicates, they will be
385 // returned by `explicit_item_bounds`.
386 let predicates_and_bounds = tcx.trait_explicit_predicates_and_bounds(def_id.expect_local());
387 let trait_identity_substs = InternalSubsts::identity_for_item(tcx, def_id);
389 let is_assoc_item_ty = |ty: Ty<'tcx>| {
390 // For a predicate from a where clause to become a bound on an
392 // * It must use the identity substs of the item.
393 // * Since any generic parameters on the item are not in scope,
394 // this means that the item is not a GAT, and its identity
395 // substs are the same as the trait's.
396 // * It must be an associated type for this trait (*not* a
398 if let ty::Projection(projection) = ty.kind() {
399 projection.substs == trait_identity_substs
400 && tcx.associated_item(projection.item_def_id).container_id(tcx) == def_id
406 let predicates: Vec<_> = predicates_and_bounds
410 .filter(|(pred, _)| match pred.kind().skip_binder() {
411 ty::PredicateKind::Trait(tr) => !is_assoc_item_ty(tr.self_ty()),
412 ty::PredicateKind::Projection(proj) => {
413 !is_assoc_item_ty(proj.projection_ty.self_ty())
415 ty::PredicateKind::TypeOutlives(outlives) => !is_assoc_item_ty(outlives.0),
419 if predicates.len() == predicates_and_bounds.predicates.len() {
420 predicates_and_bounds
422 ty::GenericPredicates {
423 parent: predicates_and_bounds.parent,
424 predicates: tcx.arena.alloc_slice(&predicates),
428 if matches!(def_kind, DefKind::AnonConst) && tcx.lazy_normalization() {
429 let hir_id = tcx.hir().local_def_id_to_hir_id(def_id.expect_local());
430 if tcx.hir().opt_const_param_default_param_hir_id(hir_id).is_some() {
431 // In `generics_of` we set the generics' parent to be our parent's parent which means that
432 // we lose out on the predicates of our actual parent if we dont return those predicates here.
433 // (See comment in `generics_of` for more information on why the parent shenanigans is necessary)
435 // struct Foo<T, const N: usize = { <T as Trait>::ASSOC }>(T) where T: Trait;
436 // ^^^ ^^^^^^^^^^^^^^^^^^^^^^^ the def id we are calling
437 // ^^^ explicit_predicates_of on
438 // parent item we dont have set as the
439 // parent of generics returned by `generics_of`
441 // In the above code we want the anon const to have predicates in its param env for `T: Trait`
442 let item_def_id = tcx.hir().get_parent_item(hir_id);
443 // In the above code example we would be calling `explicit_predicates_of(Foo)` here
444 return tcx.explicit_predicates_of(item_def_id);
447 gather_explicit_predicates_of(tcx, def_id)
451 /// Ensures that the super-predicates of the trait with a `DefId`
452 /// of `trait_def_id` are converted and stored. This also ensures that
453 /// the transitive super-predicates are converted.
454 pub(super) fn super_predicates_of(
457 ) -> ty::GenericPredicates<'_> {
458 tcx.super_predicates_that_define_assoc_type((trait_def_id, None))
461 /// Ensures that the super-predicates of the trait with a `DefId`
462 /// of `trait_def_id` are converted and stored. This also ensures that
463 /// the transitive super-predicates are converted.
464 pub(super) fn super_predicates_that_define_assoc_type(
466 (trait_def_id, assoc_name): (DefId, Option<Ident>),
467 ) -> ty::GenericPredicates<'_> {
468 if trait_def_id.is_local() {
469 debug!("local trait");
470 let trait_hir_id = tcx.hir().local_def_id_to_hir_id(trait_def_id.expect_local());
472 let Node::Item(item) = tcx.hir().get(trait_hir_id) else {
473 bug!("trait_node_id {} is not an item", trait_hir_id);
476 let (generics, bounds) = match item.kind {
477 hir::ItemKind::Trait(.., ref generics, ref supertraits, _) => (generics, supertraits),
478 hir::ItemKind::TraitAlias(ref generics, ref supertraits) => (generics, supertraits),
479 _ => span_bug!(item.span, "super_predicates invoked on non-trait"),
482 let icx = ItemCtxt::new(tcx, trait_def_id);
484 // Convert the bounds that follow the colon, e.g., `Bar + Zed` in `trait Foo: Bar + Zed`.
485 let self_param_ty = tcx.types.self_param;
486 let superbounds1 = if let Some(assoc_name) = assoc_name {
487 <dyn AstConv<'_>>::compute_bounds_that_match_assoc_type(
494 <dyn AstConv<'_>>::compute_bounds(&icx, self_param_ty, bounds)
497 let superbounds1 = superbounds1.predicates(tcx, self_param_ty);
499 // Convert any explicit superbounds in the where-clause,
500 // e.g., `trait Foo where Self: Bar`.
501 // In the case of trait aliases, however, we include all bounds in the where-clause,
502 // so e.g., `trait Foo = where u32: PartialEq<Self>` would include `u32: PartialEq<Self>`
503 // as one of its "superpredicates".
504 let is_trait_alias = tcx.is_trait_alias(trait_def_id);
505 let superbounds2 = icx.type_parameter_bounds_in_generics(
509 OnlySelfBounds(!is_trait_alias),
513 // Combine the two lists to form the complete set of superbounds:
514 let superbounds = &*tcx.arena.alloc_from_iter(superbounds1.into_iter().chain(superbounds2));
515 debug!(?superbounds);
517 // Now require that immediate supertraits are converted,
518 // which will, in turn, reach indirect supertraits.
519 if assoc_name.is_none() {
520 // Now require that immediate supertraits are converted,
521 // which will, in turn, reach indirect supertraits.
522 for &(pred, span) in superbounds {
523 debug!("superbound: {:?}", pred);
524 if let ty::PredicateKind::Trait(bound) = pred.kind().skip_binder() {
525 tcx.at(span).super_predicates_of(bound.def_id());
530 ty::GenericPredicates { parent: None, predicates: superbounds }
532 // if `assoc_name` is None, then the query should've been redirected to an
534 assert!(assoc_name.is_some());
535 tcx.super_predicates_of(trait_def_id)
539 /// Returns the predicates defined on `item_def_id` of the form
540 /// `X: Foo` where `X` is the type parameter `def_id`.
541 #[instrument(level = "trace", skip(tcx))]
542 pub(super) fn type_param_predicates(
544 (item_def_id, def_id, assoc_name): (DefId, LocalDefId, Ident),
545 ) -> ty::GenericPredicates<'_> {
548 // In the AST, bounds can derive from two places. Either
549 // written inline like `<T: Foo>` or in a where-clause like
552 let param_id = tcx.hir().local_def_id_to_hir_id(def_id);
553 let param_owner = tcx.hir().ty_param_owner(def_id);
554 let generics = tcx.generics_of(param_owner);
555 let index = generics.param_def_id_to_index[&def_id.to_def_id()];
556 let ty = tcx.mk_ty_param(index, tcx.hir().ty_param_name(def_id));
558 // Don't look for bounds where the type parameter isn't in scope.
559 let parent = if item_def_id == param_owner.to_def_id() {
562 tcx.generics_of(item_def_id).parent
565 let mut result = parent
567 let icx = ItemCtxt::new(tcx, parent);
568 icx.get_type_parameter_bounds(DUMMY_SP, def_id.to_def_id(), assoc_name)
570 .unwrap_or_default();
571 let mut extend = None;
573 let item_hir_id = tcx.hir().local_def_id_to_hir_id(item_def_id.expect_local());
574 let ast_generics = match tcx.hir().get(item_hir_id) {
575 Node::TraitItem(item) => &item.generics,
577 Node::ImplItem(item) => &item.generics,
579 Node::Item(item) => {
581 ItemKind::Fn(.., ref generics, _)
582 | ItemKind::Impl(hir::Impl { ref generics, .. })
583 | ItemKind::TyAlias(_, ref generics)
584 | ItemKind::OpaqueTy(OpaqueTy {
586 origin: hir::OpaqueTyOrigin::TyAlias,
589 | ItemKind::Enum(_, ref generics)
590 | ItemKind::Struct(_, ref generics)
591 | ItemKind::Union(_, ref generics) => generics,
592 ItemKind::Trait(_, _, ref generics, ..) => {
593 // Implied `Self: Trait` and supertrait bounds.
594 if param_id == item_hir_id {
595 let identity_trait_ref = ty::TraitRef::identity(tcx, item_def_id);
597 Some((identity_trait_ref.without_const().to_predicate(tcx), item.span));
605 Node::ForeignItem(item) => match item.kind {
606 ForeignItemKind::Fn(_, _, ref generics) => generics,
613 let icx = ItemCtxt::new(tcx, item_def_id);
614 let extra_predicates = extend.into_iter().chain(
615 icx.type_parameter_bounds_in_generics(
619 OnlySelfBounds(true),
623 .filter(|(predicate, _)| match predicate.kind().skip_binder() {
624 ty::PredicateKind::Trait(data) => data.self_ty().is_param(index),
629 tcx.arena.alloc_from_iter(result.predicates.iter().copied().chain(extra_predicates));
633 impl<'tcx> ItemCtxt<'tcx> {
634 /// Finds bounds from `hir::Generics`. This requires scanning through the
635 /// AST. We do this to avoid having to convert *all* the bounds, which
636 /// would create artificial cycles. Instead, we can only convert the
637 /// bounds for a type parameter `X` if `X::Foo` is used.
638 #[instrument(level = "trace", skip(self, ast_generics))]
639 fn type_parameter_bounds_in_generics(
641 ast_generics: &'tcx hir::Generics<'tcx>,
642 param_id: hir::HirId,
644 only_self_bounds: OnlySelfBounds,
645 assoc_name: Option<Ident>,
646 ) -> Vec<(ty::Predicate<'tcx>, Span)> {
647 let param_def_id = self.tcx.hir().local_def_id(param_id).to_def_id();
648 trace!(?param_def_id);
652 .filter_map(|wp| match *wp {
653 hir::WherePredicate::BoundPredicate(ref bp) => Some(bp),
657 let bt = if bp.is_param_bound(param_def_id) {
659 } else if !only_self_bounds.0 {
660 Some(self.to_ty(bp.bounded_ty))
664 let bvars = self.tcx.late_bound_vars(bp.hir_id);
666 bp.bounds.iter().filter_map(move |b| bt.map(|bt| (bt, b, bvars))).filter(
667 |(_, b, _)| match assoc_name {
668 Some(assoc_name) => self.bound_defines_assoc_item(b, assoc_name),
673 .flat_map(|(bt, b, bvars)| predicates_from_bound(self, bt, b, bvars))
677 #[instrument(level = "trace", skip(self))]
678 fn bound_defines_assoc_item(&self, b: &hir::GenericBound<'_>, assoc_name: Ident) -> bool {
680 hir::GenericBound::Trait(poly_trait_ref, _) => {
681 let trait_ref = &poly_trait_ref.trait_ref;
682 if let Some(trait_did) = trait_ref.trait_def_id() {
683 self.tcx.trait_may_define_assoc_type(trait_did, assoc_name)
693 /// Converts a specific `GenericBound` from the AST into a set of
694 /// predicates that apply to the self type. A vector is returned
695 /// because this can be anywhere from zero predicates (`T: ?Sized` adds no
696 /// predicates) to one (`T: Foo`) to many (`T: Bar<X = i32>` adds `T: Bar`
697 /// and `<T as Bar>::X == i32`).
698 fn predicates_from_bound<'tcx>(
699 astconv: &dyn AstConv<'tcx>,
701 bound: &'tcx hir::GenericBound<'tcx>,
702 bound_vars: &'tcx ty::List<ty::BoundVariableKind>,
703 ) -> Vec<(ty::Predicate<'tcx>, Span)> {
704 let mut bounds = Bounds::default();
705 astconv.add_bounds(param_ty, [bound].into_iter(), &mut bounds, bound_vars);
706 bounds.predicates(astconv.tcx(), param_ty).collect()