@@ -538,6 +538,10 @@ impl<'cx,'tcx> BoundsChecker<'cx,'tcx> {
538
538
ty. fold_with ( self ) ;
539
539
self . binding_count -= 1 ;
540
540
}
541
+
542
+ fn cause ( & self , code : traits:: ObligationCauseCode < ' tcx > ) -> traits:: ObligationCause < ' tcx > {
543
+ traits:: ObligationCause :: new ( self . span , self . fcx . body_id , code)
544
+ }
541
545
}
542
546
543
547
impl < ' cx , ' tcx > TypeFolder < ' tcx > for BoundsChecker < ' cx , ' tcx > {
@@ -574,7 +578,22 @@ impl<'cx,'tcx> TypeFolder<'tcx> for BoundsChecker<'cx,'tcx> {
574
578
None => { }
575
579
}
576
580
577
- match t. sty {
581
+ match t. sty {
582
+ ty:: TyArray ( ety, _) | ty:: TySlice ( ety) => {
583
+ self . fcx . register_builtin_bound ( self . fold_ty ( ety) ,
584
+ ty:: BoundSized ,
585
+ self . cause ( traits:: MiscObligation ) ) ;
586
+ t
587
+ }
588
+ ty:: TyTuple ( ref tys) => {
589
+ for ty in tys {
590
+ self . fcx . register_builtin_bound ( self . fold_ty ( ty) ,
591
+ ty:: BoundSized ,
592
+ self . cause ( traits:: MiscObligation )
593
+ ) ;
594
+ }
595
+ t
596
+ }
578
597
ty:: TyStruct ( type_id, substs) |
579
598
ty:: TyEnum ( type_id, substs) => {
580
599
let type_predicates = self . fcx . tcx ( ) . lookup_predicates ( type_id) ;
@@ -583,9 +602,7 @@ impl<'cx,'tcx> TypeFolder<'tcx> for BoundsChecker<'cx,'tcx> {
583
602
584
603
if self . binding_count == 0 {
585
604
self . fcx . add_obligations_for_parameters (
586
- traits:: ObligationCause :: new ( self . span ,
587
- self . fcx . body_id ,
588
- traits:: ItemObligation ( type_id) ) ,
605
+ self . cause ( traits:: ItemObligation ( type_id) ) ,
589
606
& bounds) ;
590
607
} else {
591
608
// There are two circumstances in which we ignore
@@ -612,20 +629,17 @@ impl<'cx,'tcx> TypeFolder<'tcx> for BoundsChecker<'cx,'tcx> {
612
629
// that will require an RFC. -nmatsakis)
613
630
let bounds = filter_to_trait_obligations ( bounds) ;
614
631
self . fcx . add_obligations_for_parameters (
615
- traits:: ObligationCause :: new ( self . span ,
616
- self . fcx . body_id ,
617
- traits:: ItemObligation ( type_id) ) ,
632
+ self . cause ( traits:: ItemObligation ( type_id) ) ,
618
633
& bounds) ;
619
634
}
620
635
621
636
self . fold_substs ( substs) ;
637
+ t
622
638
}
623
639
_ => {
624
- super_fold_ty ( self , t) ;
640
+ super_fold_ty ( self , t)
625
641
}
626
642
}
627
-
628
- t // we're not folding to produce a new type, so just return `t` here
629
643
}
630
644
}
631
645
0 commit comments