@@ -389,6 +389,11 @@ impl<'a> UnionValues<'a> for allocator::Vec<'a, Entity<'a>> {
389389 has_unknown = true ;
390390 filtered. push ( * value)
391391 }
392+ UnionHint :: Object => {
393+ filtered = self ;
394+ has_unknown = false ;
395+ break ;
396+ }
392397 _ => filtered. push ( * value) ,
393398 }
394399 }
@@ -435,17 +440,21 @@ impl<'a> UnionValues<'a> for (Entity<'a>, Entity<'a>) {
435440 ( f ( self . 0 ) , f ( self . 1 ) )
436441 }
437442 fn union ( self , factory : & Factory < ' a > ) -> Entity < ' a > {
438- match ( self . 0 . get_union_hint ( ) , self . 1 . get_union_hint ( ) ) {
439- ( UnionHint :: Never , _) => self . 1 ,
440- ( _, UnionHint :: Never ) => self . 0 ,
441- ( UnionHint :: Unknown , _) | ( _, UnionHint :: Unknown ) => factory. computed_unknown ( self ) ,
442- _ => factory
443+ let no_merge = || {
444+ factory
443445 . alloc ( UnionValue {
444446 values : self ,
445447 consumed : Cell :: new ( false ) ,
446448 phantom : std:: marker:: PhantomData ,
447449 } )
448- . into ( ) ,
450+ . into ( )
451+ } ;
452+ match ( self . 0 . get_union_hint ( ) , self . 1 . get_union_hint ( ) ) {
453+ ( UnionHint :: Object , _) | ( _, UnionHint :: Object ) => no_merge ( ) ,
454+ ( UnionHint :: Never , _) => self . 1 ,
455+ ( _, UnionHint :: Never ) => self . 0 ,
456+ ( UnionHint :: Unknown , _) | ( _, UnionHint :: Unknown ) => factory. computed_unknown ( self ) ,
457+ _ => no_merge ( ) ,
449458 }
450459 }
451460}
0 commit comments