@@ -49,7 +49,7 @@ pub struct Graph {
4949
5050/// Children of a given impl, grouped into blanket/non-blanket varieties as is
5151/// done in `TraitDef`.
52- #[ derive( RustcEncodable , RustcDecodable ) ]
52+ #[ derive( Default , RustcEncodable , RustcDecodable ) ]
5353struct Children {
5454 // Impls of a trait (or specializations of a given impl). To allow for
5555 // quicker lookup, the impls are indexed by a simplified version of their
@@ -81,21 +81,14 @@ enum Inserted {
8181}
8282
8383impl < ' a , ' gcx , ' tcx > Children {
84- fn new ( ) -> Children {
85- Children {
86- nonblanket_impls : FxHashMap ( ) ,
87- blanket_impls : vec ! [ ] ,
88- }
89- }
90-
9184 /// Insert an impl into this set of children without comparing to any existing impls
9285 fn insert_blindly ( & mut self ,
9386 tcx : TyCtxt < ' a , ' gcx , ' tcx > ,
9487 impl_def_id : DefId ) {
9588 let trait_ref = tcx. impl_trait_ref ( impl_def_id) . unwrap ( ) ;
9689 if let Some ( sty) = fast_reject:: simplify_type ( tcx, trait_ref. self_ty ( ) , false ) {
9790 debug ! ( "insert_blindly: impl_def_id={:?} sty={:?}" , impl_def_id, sty) ;
98- self . nonblanket_impls . entry ( sty) . or_insert ( vec ! [ ] ) . push ( impl_def_id)
91+ self . nonblanket_impls . entry ( sty) . or_default ( ) . push ( impl_def_id)
9992 } else {
10093 debug ! ( "insert_blindly: impl_def_id={:?} sty=None" , impl_def_id) ;
10194 self . blanket_impls . push ( impl_def_id)
@@ -230,7 +223,7 @@ impl<'a, 'gcx, 'tcx> Children {
230223 }
231224
232225 fn filtered ( & mut self , sty : SimplifiedType ) -> Box < dyn Iterator < Item = DefId > + ' _ > {
233- let nonblanket = self . nonblanket_impls . entry ( sty) . or_insert ( vec ! [ ] ) . iter ( ) ;
226+ let nonblanket = self . nonblanket_impls . entry ( sty) . or_default ( ) . iter ( ) ;
234227 Box :: new ( self . blanket_impls . iter ( ) . chain ( nonblanket) . cloned ( ) )
235228 }
236229}
@@ -268,7 +261,7 @@ impl<'a, 'gcx, 'tcx> Graph {
268261 trait_ref, impl_def_id, trait_def_id) ;
269262
270263 self . parent . insert ( impl_def_id, trait_def_id) ;
271- self . children . entry ( trait_def_id) . or_insert ( Children :: new ( ) )
264+ self . children . entry ( trait_def_id) . or_default ( )
272265 . insert_blindly ( tcx, impl_def_id) ;
273266 return Ok ( None ) ;
274267 }
@@ -281,7 +274,7 @@ impl<'a, 'gcx, 'tcx> Graph {
281274 loop {
282275 use self :: Inserted :: * ;
283276
284- let insert_result = self . children . entry ( parent) . or_insert ( Children :: new ( ) )
277+ let insert_result = self . children . entry ( parent) . or_default ( )
285278 . insert ( tcx, impl_def_id, simplified) ?;
286279
287280 match insert_result {
@@ -318,9 +311,8 @@ impl<'a, 'gcx, 'tcx> Graph {
318311 self . parent . insert ( impl_def_id, parent) ;
319312
320313 // Add G as N's child.
321- let mut grand_children = Children :: new ( ) ;
322- grand_children. insert_blindly ( tcx, grand_child_to_be) ;
323- self . children . insert ( impl_def_id, grand_children) ;
314+ self . children . entry ( impl_def_id) . or_default ( )
315+ . insert_blindly ( tcx, grand_child_to_be) ;
324316 break ;
325317 }
326318 ShouldRecurseOn ( new_parent) => {
@@ -343,7 +335,7 @@ impl<'a, 'gcx, 'tcx> Graph {
343335 was already present.") ;
344336 }
345337
346- self . children . entry ( parent) . or_insert ( Children :: new ( ) ) . insert_blindly ( tcx, child) ;
338+ self . children . entry ( parent) . or_default ( ) . insert_blindly ( tcx, child) ;
347339 }
348340
349341 /// The parent of a given impl, which is the def id of the trait when the
0 commit comments