@@ -820,7 +820,8 @@ impl<'tcx> TypeVisitor<'tcx> for BoundVarsCollector<'tcx> {
820820 fn visit_region ( & mut self , r : ty:: Region < ' tcx > ) -> ControlFlow < Self :: BreakTy > {
821821 match r {
822822 ty:: ReLateBound ( index, _br) if * index == self . binder_index => {
823- bug ! ( "{:?} {:?}" , index, _br)
823+ // If you hit this, you should be using `Binder::bind_with_vars` or `Binder::rebind`
824+ bug ! ( "Trying to collect bound vars with a bound region: {:?} {:?}" , index, _br)
824825 }
825826
826827 _ => ( ) ,
@@ -870,19 +871,19 @@ impl<'tcx> TypeVisitor<'tcx> for ValidateBoundVars<'tcx> {
870871 match * t. kind ( ) {
871872 ty:: Bound ( debruijn, bound_ty) if debruijn == self . binder_index => {
872873 if self . bound_vars . len ( ) <= bound_ty. var . as_usize ( ) {
873- panic ! ( "Not enough bound vars: {:?} not found in {:?}" , t, self . bound_vars) ;
874+ bug ! ( "Not enough bound vars: {:?} not found in {:?}" , t, self . bound_vars) ;
874875 }
875876 let list_var = self . bound_vars [ bound_ty. var . as_usize ( ) ] ;
876877 match list_var {
877878 ty:: BoundVariableKind :: Ty ( kind) => {
878879 if kind != bound_ty. kind {
879- panic ! (
880+ bug ! (
880881 "Mismatched type kinds: {:?} doesn't var in list {:?}" ,
881882 bound_ty. kind, list_var
882883 ) ;
883884 }
884885 }
885- _ => panic ! (
886+ _ => bug ! (
886887 "Mismatched bound variable kinds! Expected type, found {:?}" ,
887888 list_var
888889 ) ,
@@ -899,19 +900,19 @@ impl<'tcx> TypeVisitor<'tcx> for ValidateBoundVars<'tcx> {
899900 match r {
900901 ty:: ReLateBound ( index, br) if * index == self . binder_index => {
901902 if self . bound_vars . len ( ) <= br. var . as_usize ( ) {
902- panic ! ( "Not enough bound vars: {:?} not found in {:?}" , * br, self . bound_vars) ;
903+ bug ! ( "Not enough bound vars: {:?} not found in {:?}" , * br, self . bound_vars) ;
903904 }
904905 let list_var = self . bound_vars [ br. var . as_usize ( ) ] ;
905906 match list_var {
906907 ty:: BoundVariableKind :: Region ( kind) => {
907908 if kind != br. kind {
908- panic ! (
909+ bug ! (
909910 "Mismatched region kinds: {:?} doesn't match var ({:?}) in list ({:?})" ,
910911 br. kind, list_var, self . bound_vars
911912 ) ;
912913 }
913914 }
914- _ => panic ! (
915+ _ => bug ! (
915916 "Mismatched bound variable kinds! Expected region, found {:?}" ,
916917 list_var
917918 ) ,
0 commit comments