@@ -13,7 +13,6 @@ use rustc_span::{DUMMY_SP, Ident, Span};
13
13
use tracing:: { debug, instrument, trace} ;
14
14
15
15
use super :: item_bounds:: explicit_item_bounds_with_filter;
16
- use crate :: bounds:: Bounds ;
17
16
use crate :: collect:: ItemCtxt ;
18
17
use crate :: constrained_generic_params as cgp;
19
18
use crate :: delegation:: inherit_predicates_for_delegation_item;
@@ -178,15 +177,15 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen
178
177
// on a trait we must also consider the bounds that follow the trait's name,
179
178
// like `trait Foo: A + B + C`.
180
179
if let Some ( self_bounds) = is_trait {
181
- let mut bounds = Bounds :: default ( ) ;
180
+ let mut bounds = Vec :: new ( ) ;
182
181
icx. lowerer ( ) . lower_bounds (
183
182
tcx. types . self_param ,
184
183
self_bounds,
185
184
& mut bounds,
186
185
ty:: List :: empty ( ) ,
187
186
PredicateFilter :: All ,
188
187
) ;
189
- predicates. extend ( bounds. clauses ( ) ) ;
188
+ predicates. extend ( bounds) ;
190
189
}
191
190
192
191
// 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
209
208
GenericParamKind :: Lifetime { .. } => ( ) ,
210
209
GenericParamKind :: Type { .. } => {
211
210
let param_ty = icx. lowerer ( ) . lower_ty_param ( param. hir_id ) ;
212
- let mut bounds = Bounds :: default ( ) ;
211
+ let mut bounds = Vec :: new ( ) ;
213
212
// Params are implicitly sized unless a `?Sized` bound is found
214
213
icx. lowerer ( ) . add_sized_bound (
215
214
& mut bounds,
@@ -219,7 +218,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen
219
218
param. span ,
220
219
) ;
221
220
trace ! ( ?bounds) ;
222
- predicates. extend ( bounds. clauses ( ) ) ;
221
+ predicates. extend ( bounds) ;
223
222
trace ! ( ?predicates) ;
224
223
}
225
224
hir:: GenericParamKind :: Const { .. } => {
@@ -264,15 +263,15 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen
264
263
}
265
264
}
266
265
267
- let mut bounds = Bounds :: default ( ) ;
266
+ let mut bounds = Vec :: new ( ) ;
268
267
icx. lowerer ( ) . lower_bounds (
269
268
ty,
270
269
bound_pred. bounds ,
271
270
& mut bounds,
272
271
bound_vars,
273
272
PredicateFilter :: All ,
274
273
) ;
275
- predicates. extend ( bounds. clauses ( ) ) ;
274
+ predicates. extend ( bounds) ;
276
275
}
277
276
278
277
hir:: WherePredicateKind :: RegionPredicate ( region_pred) => {
@@ -627,15 +626,15 @@ pub(super) fn implied_predicates_with_filter<'tcx>(
627
626
let icx = ItemCtxt :: new ( tcx, trait_def_id) ;
628
627
629
628
let self_param_ty = tcx. types . self_param ;
630
- let mut bounds = Bounds :: default ( ) ;
629
+ let mut bounds = Vec :: new ( ) ;
631
630
icx. lowerer ( ) . lower_bounds ( self_param_ty, superbounds, & mut bounds, ty:: List :: empty ( ) , filter) ;
632
631
633
632
let where_bounds_that_match =
634
633
icx. probe_ty_param_bounds_in_generics ( generics, item. owner_id . def_id , filter) ;
635
634
636
635
// Combine the two lists to form the complete set of superbounds:
637
636
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) ) ;
639
638
debug ! ( ?implied_bounds) ;
640
639
641
640
// Now require that immediate supertraits are lowered, which will, in
@@ -904,7 +903,7 @@ impl<'tcx> ItemCtxt<'tcx> {
904
903
param_def_id : LocalDefId ,
905
904
filter : PredicateFilter ,
906
905
) -> Vec < ( ty:: Clause < ' tcx > , Span ) > {
907
- let mut bounds = Bounds :: default ( ) ;
906
+ let mut bounds = Vec :: new ( ) ;
908
907
909
908
for predicate in hir_generics. predicates {
910
909
let hir_id = predicate. hir_id ;
@@ -938,7 +937,7 @@ impl<'tcx> ItemCtxt<'tcx> {
938
937
) ;
939
938
}
940
939
941
- bounds. clauses ( ) . collect ( )
940
+ bounds
942
941
}
943
942
}
944
943
@@ -1007,7 +1006,7 @@ pub(super) fn const_conditions<'tcx>(
1007
1006
} ;
1008
1007
1009
1008
let icx = ItemCtxt :: new ( tcx, def_id) ;
1010
- let mut bounds = Bounds :: default ( ) ;
1009
+ let mut bounds = Vec :: new ( ) ;
1011
1010
1012
1011
for pred in generics. predicates {
1013
1012
match pred. kind {
@@ -1027,12 +1026,12 @@ pub(super) fn const_conditions<'tcx>(
1027
1026
}
1028
1027
1029
1028
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 ) ,
1034
1033
DUMMY_SP ,
1035
- ) ;
1034
+ ) ) ;
1036
1035
1037
1036
icx. lowerer ( ) . lower_bounds (
1038
1037
tcx. types . self_param ,
@@ -1045,7 +1044,7 @@ pub(super) fn const_conditions<'tcx>(
1045
1044
1046
1045
ty:: ConstConditions {
1047
1046
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) | {
1049
1048
(
1050
1049
clause. kind ( ) . map_bound ( |clause| match clause {
1051
1050
ty:: ClauseKind :: HostEffect ( ty:: HostEffectPredicate {
0 commit comments