@@ -550,17 +550,32 @@ impl<'a, 'gcx, 'tcx> SubstFolder<'a, 'gcx, 'tcx> {
550
550
let opt_ty = self . substs . get ( p. idx as usize ) . map ( |k| k. unpack ( ) ) ;
551
551
let ty = match opt_ty {
552
552
Some ( UnpackedKind :: Type ( ty) ) => ty,
553
- _ => {
553
+ Some ( kind ) => {
554
554
let span = self . span . unwrap_or ( DUMMY_SP ) ;
555
555
span_bug ! (
556
556
span,
557
- "Type parameter `{:?}` ({:?}/{}) out of range \
557
+ "expected type for `{:?}` ({:?}/{}) but found {:?} \
558
558
when substituting (root type={:?}) substs={:?}",
559
559
p,
560
560
source_ty,
561
561
p. idx,
562
+ kind,
562
563
self . root_ty,
563
- self . substs) ;
564
+ self . substs,
565
+ ) ;
566
+ }
567
+ None => {
568
+ let span = self . span . unwrap_or ( DUMMY_SP ) ;
569
+ span_bug ! (
570
+ span,
571
+ "type parameter `{:?}` ({:?}/{}) out of range \
572
+ when substituting (root type={:?}) substs={:?}",
573
+ p,
574
+ source_ty,
575
+ p. idx,
576
+ self . root_ty,
577
+ self . substs,
578
+ ) ;
564
579
}
565
580
} ;
566
581
@@ -570,29 +585,41 @@ impl<'a, 'gcx, 'tcx> SubstFolder<'a, 'gcx, 'tcx> {
570
585
fn const_for_param (
571
586
& self ,
572
587
p : ParamConst ,
573
- source_cn : & ' tcx ty:: Const < ' tcx >
588
+ source_ct : & ' tcx ty:: Const < ' tcx >
574
589
) -> & ' tcx ty:: Const < ' tcx > {
575
590
// Look up the const in the substitutions. It really should be in there.
576
- let opt_cn = self . substs . get ( p. index as usize ) . map ( |k| k. unpack ( ) ) ;
577
- let cn = match opt_cn {
578
- Some ( UnpackedKind :: Const ( cn ) ) => cn ,
579
- _ => {
591
+ let opt_ct = self . substs . get ( p. index as usize ) . map ( |k| k. unpack ( ) ) ;
592
+ let ct = match opt_ct {
593
+ Some ( UnpackedKind :: Const ( ct ) ) => ct ,
594
+ Some ( kind ) => {
580
595
let span = self . span . unwrap_or ( DUMMY_SP ) ;
581
596
span_bug ! (
582
597
span,
583
- "Const parameter `{:?}` ({:?}/{}) out of range \
584
- when substituting (root type={:?}) substs={:?}",
598
+ "expected const for `{:?}` ({:?}/{}) but found {:?} \
599
+ when substituting substs={:?}",
585
600
p,
586
- source_cn,
601
+ source_ct,
602
+ p. index,
603
+ kind,
604
+ self . substs,
605
+ ) ;
606
+ }
607
+ None => {
608
+ let span = self . span . unwrap_or ( DUMMY_SP ) ;
609
+ span_bug ! (
610
+ span,
611
+ "const parameter `{:?}` ({:?}/{}) out of range \
612
+ when substituting substs={:?}",
613
+ p,
614
+ source_ct,
587
615
p. index,
588
- self . root_ty,
589
616
self . substs,
590
617
) ;
591
618
}
592
619
} ;
593
620
594
621
// FIXME(const_generics): shift const through binders
595
- cn
622
+ ct
596
623
}
597
624
598
625
/// It is sometimes necessary to adjust the De Bruijn indices during substitution. This occurs
0 commit comments