@@ -59,7 +59,8 @@ impl CollectedSizednessBounds {
5959
6060fn search_bounds_for < ' tcx > (
6161 hir_bounds : & ' tcx [ hir:: GenericBound < ' tcx > ] ,
62- context : ImpliedBoundsContext < ' tcx > ,
62+ where_bounds : & ' tcx [ hir:: WherePredicate < ' tcx > ] ,
63+ context : ImpliedBoundsContext ,
6364 mut f : impl FnMut ( & ' tcx PolyTraitRef < ' tcx > ) ,
6465) {
6566 let mut search_bounds = |hir_bounds : & ' tcx [ hir:: GenericBound < ' tcx > ] | {
@@ -73,8 +74,8 @@ fn search_bounds_for<'tcx>(
7374 } ;
7475
7576 search_bounds ( hir_bounds) ;
76- if let ImpliedBoundsContext :: TyParam ( self_ty, where_clause ) = context {
77- for clause in where_clause {
77+ if let ImpliedBoundsContext :: TyParam ( self_ty) = context {
78+ for clause in where_bounds {
7879 if let hir:: WherePredicateKind :: BoundPredicate ( pred) = clause. kind
7980 && pred. is_param_bound ( self_ty. to_def_id ( ) )
8081 {
@@ -86,11 +87,12 @@ fn search_bounds_for<'tcx>(
8687
8788fn collect_bounds < ' a , ' tcx > (
8889 hir_bounds : & ' a [ hir:: GenericBound < ' tcx > ] ,
89- context : ImpliedBoundsContext < ' tcx > ,
90+ where_bounds : & ' tcx [ hir:: WherePredicate < ' tcx > ] ,
91+ context : ImpliedBoundsContext ,
9092 target_did : DefId ,
9193) -> CollectedBound {
9294 let mut collect_into = CollectedBound :: default ( ) ;
93- search_bounds_for ( hir_bounds, context, |ptr| {
95+ search_bounds_for ( hir_bounds, where_bounds , context, |ptr| {
9496 if !matches ! ( ptr. trait_ref. path. res, Res :: Def ( DefKind :: Trait , did) if did == target_did) {
9597 return ;
9698 }
@@ -107,17 +109,18 @@ fn collect_bounds<'a, 'tcx>(
107109fn collect_sizedness_bounds < ' tcx > (
108110 tcx : TyCtxt < ' tcx > ,
109111 hir_bounds : & ' tcx [ hir:: GenericBound < ' tcx > ] ,
110- context : ImpliedBoundsContext < ' tcx > ,
112+ where_bounds : & ' tcx [ hir:: WherePredicate < ' tcx > ] ,
113+ context : ImpliedBoundsContext ,
111114 span : Span ,
112115) -> CollectedSizednessBounds {
113116 let sized_did = tcx. require_lang_item ( hir:: LangItem :: Sized , span) ;
114- let sized = collect_bounds ( hir_bounds, context, sized_did) ;
117+ let sized = collect_bounds ( hir_bounds, where_bounds , context, sized_did) ;
115118
116119 let meta_sized_did = tcx. require_lang_item ( hir:: LangItem :: MetaSized , span) ;
117- let meta_sized = collect_bounds ( hir_bounds, context, meta_sized_did) ;
120+ let meta_sized = collect_bounds ( hir_bounds, where_bounds , context, meta_sized_did) ;
118121
119122 let pointee_sized_did = tcx. require_lang_item ( hir:: LangItem :: PointeeSized , span) ;
120- let pointee_sized = collect_bounds ( hir_bounds, context, pointee_sized_did) ;
123+ let pointee_sized = collect_bounds ( hir_bounds, where_bounds , context, pointee_sized_did) ;
121124
122125 CollectedSizednessBounds { sized, meta_sized, pointee_sized }
123126}
@@ -150,7 +153,8 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
150153 bounds : & mut Vec < ( ty:: Clause < ' tcx > , Span ) > ,
151154 self_ty : Ty < ' tcx > ,
152155 hir_bounds : & ' tcx [ hir:: GenericBound < ' tcx > ] ,
153- context : ImpliedBoundsContext < ' tcx > ,
156+ where_bounds : & ' tcx [ hir:: WherePredicate < ' tcx > ] ,
157+ context : ImpliedBoundsContext ,
154158 span : Span ,
155159 ) {
156160 let tcx = self . tcx ( ) ;
@@ -181,7 +185,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
181185 }
182186 }
183187
184- let collected = collect_sizedness_bounds ( tcx, hir_bounds, context, span) ;
188+ let collected = collect_sizedness_bounds ( tcx, hir_bounds, where_bounds , context, span) ;
185189 if ( collected. sized . maybe || collected. sized . negative )
186190 && !collected. sized . positive
187191 && !collected. meta_sized . any ( )
@@ -213,11 +217,20 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
213217 bounds : & mut Vec < ( ty:: Clause < ' tcx > , Span ) > ,
214218 self_ty : Ty < ' tcx > ,
215219 hir_bounds : & [ hir:: GenericBound < ' tcx > ] ,
216- context : ImpliedBoundsContext < ' tcx > ,
220+ where_bounds : & ' tcx [ hir:: WherePredicate < ' tcx > ] ,
221+ context : ImpliedBoundsContext ,
217222 span : Span ,
218223 ) {
219224 self . tcx ( ) . default_traits ( ) . iter ( ) . for_each ( |default_trait| {
220- self . add_default_trait ( * default_trait, bounds, self_ty, hir_bounds, context, span) ;
225+ self . add_default_trait (
226+ * default_trait,
227+ bounds,
228+ self_ty,
229+ hir_bounds,
230+ where_bounds,
231+ context,
232+ span,
233+ ) ;
221234 } ) ;
222235 }
223236
@@ -230,7 +243,8 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
230243 bounds : & mut Vec < ( ty:: Clause < ' tcx > , Span ) > ,
231244 self_ty : Ty < ' tcx > ,
232245 hir_bounds : & [ hir:: GenericBound < ' tcx > ] ,
233- context : ImpliedBoundsContext < ' tcx > ,
246+ where_bounds : & ' tcx [ hir:: WherePredicate < ' tcx > ] ,
247+ context : ImpliedBoundsContext ,
234248 span : Span ,
235249 ) {
236250 let tcx = self . tcx ( ) ;
@@ -244,7 +258,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
244258 }
245259
246260 if let Some ( trait_did) = tcx. lang_items ( ) . get ( trait_)
247- && self . should_add_default_traits ( trait_did, hir_bounds, context)
261+ && self . should_add_default_traits ( trait_did, hir_bounds, where_bounds , context)
248262 {
249263 add_trait_bound ( tcx, bounds, self_ty, trait_did, span) ;
250264 }
@@ -255,9 +269,10 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
255269 & self ,
256270 trait_def_id : DefId ,
257271 hir_bounds : & ' a [ hir:: GenericBound < ' tcx > ] ,
258- context : ImpliedBoundsContext < ' tcx > ,
272+ where_bounds : & ' tcx [ hir:: WherePredicate < ' tcx > ] ,
273+ context : ImpliedBoundsContext ,
259274 ) -> bool {
260- let collected = collect_bounds ( hir_bounds, context, trait_def_id) ;
275+ let collected = collect_bounds ( hir_bounds, where_bounds , context, trait_def_id) ;
261276 !find_attr ! ( self . tcx( ) , crate , RustcNoImplicitBounds ) && !collected. any ( )
262277 }
263278
0 commit comments