@@ -13,7 +13,6 @@ use rustc_span::{DUMMY_SP, Ident, Span};
1313use tracing:: { debug, instrument, trace} ;
1414
1515use super :: item_bounds:: explicit_item_bounds_with_filter;
16- use crate :: bounds:: Bounds ;
1716use crate :: collect:: ItemCtxt ;
1817use crate :: constrained_generic_params as cgp;
1918use crate :: delegation:: inherit_predicates_for_delegation_item;
@@ -178,15 +177,15 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen
178177 // on a trait we must also consider the bounds that follow the trait's name,
179178 // like `trait Foo: A + B + C`.
180179 if let Some ( self_bounds) = is_trait {
181- let mut bounds = Bounds :: default ( ) ;
180+ let mut bounds = Vec :: new ( ) ;
182181 icx. lowerer ( ) . lower_bounds (
183182 tcx. types . self_param ,
184183 self_bounds,
185184 & mut bounds,
186185 ty:: List :: empty ( ) ,
187186 PredicateFilter :: All ,
188187 ) ;
189- predicates. extend ( bounds. clauses ( ) ) ;
188+ predicates. extend ( bounds) ;
190189 }
191190
192191 // In default impls, we can assume that the self type implements
@@ -209,7 +208,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen
209208 GenericParamKind :: Lifetime { .. } => ( ) ,
210209 GenericParamKind :: Type { .. } => {
211210 let param_ty = icx. lowerer ( ) . lower_ty_param ( param. hir_id ) ;
212- let mut bounds = Bounds :: default ( ) ;
211+ let mut bounds = Vec :: new ( ) ;
213212 // Params are implicitly sized unless a `?Sized` bound is found
214213 icx. lowerer ( ) . add_sized_bound (
215214 & mut bounds,
@@ -219,7 +218,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen
219218 param. span ,
220219 ) ;
221220 trace ! ( ?bounds) ;
222- predicates. extend ( bounds. clauses ( ) ) ;
221+ predicates. extend ( bounds) ;
223222 trace ! ( ?predicates) ;
224223 }
225224 hir:: GenericParamKind :: Const { .. } => {
@@ -264,15 +263,15 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen
264263 }
265264 }
266265
267- let mut bounds = Bounds :: default ( ) ;
266+ let mut bounds = Vec :: new ( ) ;
268267 icx. lowerer ( ) . lower_bounds (
269268 ty,
270269 bound_pred. bounds ,
271270 & mut bounds,
272271 bound_vars,
273272 PredicateFilter :: All ,
274273 ) ;
275- predicates. extend ( bounds. clauses ( ) ) ;
274+ predicates. extend ( bounds) ;
276275 }
277276
278277 hir:: WherePredicateKind :: RegionPredicate ( region_pred) => {
@@ -627,15 +626,15 @@ pub(super) fn implied_predicates_with_filter<'tcx>(
627626 let icx = ItemCtxt :: new ( tcx, trait_def_id) ;
628627
629628 let self_param_ty = tcx. types . self_param ;
630- let mut bounds = Bounds :: default ( ) ;
629+ let mut bounds = Vec :: new ( ) ;
631630 icx. lowerer ( ) . lower_bounds ( self_param_ty, superbounds, & mut bounds, ty:: List :: empty ( ) , filter) ;
632631
633632 let where_bounds_that_match =
634633 icx. probe_ty_param_bounds_in_generics ( generics, item. owner_id . def_id , filter) ;
635634
636635 // Combine the two lists to form the complete set of superbounds:
637636 let implied_bounds =
638- & * tcx. arena . alloc_from_iter ( bounds. clauses ( ) . chain ( where_bounds_that_match) ) ;
637+ & * tcx. arena . alloc_from_iter ( bounds. into_iter ( ) . chain ( where_bounds_that_match) ) ;
639638 debug ! ( ?implied_bounds) ;
640639
641640 // Now require that immediate supertraits are lowered, which will, in
@@ -904,7 +903,7 @@ impl<'tcx> ItemCtxt<'tcx> {
904903 param_def_id : LocalDefId ,
905904 filter : PredicateFilter ,
906905 ) -> Vec < ( ty:: Clause < ' tcx > , Span ) > {
907- let mut bounds = Bounds :: default ( ) ;
906+ let mut bounds = Vec :: new ( ) ;
908907
909908 for predicate in hir_generics. predicates {
910909 let hir_id = predicate. hir_id ;
@@ -938,7 +937,7 @@ impl<'tcx> ItemCtxt<'tcx> {
938937 ) ;
939938 }
940939
941- bounds. clauses ( ) . collect ( )
940+ bounds
942941 }
943942}
944943
@@ -1007,7 +1006,7 @@ pub(super) fn const_conditions<'tcx>(
10071006 } ;
10081007
10091008 let icx = ItemCtxt :: new ( tcx, def_id) ;
1010- let mut bounds = Bounds :: default ( ) ;
1009+ let mut bounds = Vec :: new ( ) ;
10111010
10121011 for pred in generics. predicates {
10131012 match pred. kind {
@@ -1027,12 +1026,12 @@ pub(super) fn const_conditions<'tcx>(
10271026 }
10281027
10291028 if let Some ( ( def_id, supertraits) ) = trait_def_id_and_supertraits {
1030- bounds . push_const_bound (
1031- tcx ,
1032- ty:: Binder :: dummy ( ty:: TraitRef :: identity ( tcx, def_id. to_def_id ( ) ) ) ,
1033- ty:: BoundConstness :: Maybe ,
1029+ // We've checked above that the trait is conditionally const.
1030+ bounds . push ( (
1031+ ty:: Binder :: dummy ( ty:: TraitRef :: identity ( tcx, def_id. to_def_id ( ) ) )
1032+ . to_host_effect_clause ( tcx , ty:: BoundConstness :: Maybe ) ,
10341033 DUMMY_SP ,
1035- ) ;
1034+ ) ) ;
10361035
10371036 icx. lowerer ( ) . lower_bounds (
10381037 tcx. types . self_param ,
@@ -1045,7 +1044,7 @@ pub(super) fn const_conditions<'tcx>(
10451044
10461045 ty:: ConstConditions {
10471046 parent : has_parent. then ( || tcx. local_parent ( def_id) . to_def_id ( ) ) ,
1048- predicates : tcx. arena . alloc_from_iter ( bounds. clauses ( ) . map ( |( clause, span) | {
1047+ predicates : tcx. arena . alloc_from_iter ( bounds. into_iter ( ) . map ( |( clause, span) | {
10491048 (
10501049 clause. kind ( ) . map_bound ( |clause| match clause {
10511050 ty:: ClauseKind :: HostEffect ( ty:: HostEffectPredicate {
0 commit comments