@@ -612,9 +612,19 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
612
612
ast:: ExprIndex ( ref base, ref index) => {
613
613
match const_eval:: eval_const_expr_partial ( cx. tcx ( ) , & e, None ) {
614
614
Ok ( val) => const_val_for_idx ( cx, val, param_substs, ety) ,
615
- Err ( NonConstPath ) => {
615
+ Err ( const_eval:: ConstEvalErr {
616
+ kind : const_eval:: ErrKind :: NonConstPath , ..
617
+ } ) | Err ( const_eval:: ConstEvalErr {
618
+ kind : const_eval:: ErrKind :: MiscCatchAll , ..
619
+ } ) => {
616
620
let ( bv, bt) = const_expr ( cx, & * * base, param_substs) ;
617
- let iv = try!( const_eval:: eval_const_index ( cx. tcx ( ) , & * * index) ) ;
621
+ let iv = match const_eval:: eval_const_index ( cx. tcx ( ) , & * * index) {
622
+ Ok ( idx) => idx,
623
+ Err ( err) => {
624
+ cx. sess ( ) . span_err ( err. span , & * err. description ( ) ) ;
625
+ cx. sess ( ) . span_fatal ( index. span , "constant evaluation of index failed" ) ;
626
+ } ,
627
+ } ;
618
628
let ( arr, len) = match bt. sty {
619
629
ty:: ty_vec( _, Some ( u) ) => ( bv, C_uint ( cx, u) ) ,
620
630
ty:: ty_vec( _, None ) | ty:: ty_str => {
@@ -659,10 +669,10 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
659
669
const_get_elt ( cx, arr, & [ iv as c_uint ] )
660
670
}
661
671
} ,
662
- Err ( err) => cx . sess ( ) . span_fatal (
663
- e . span ,
664
- & format ! ( "constant indexing failed: {}" , err . description ( ) ) ,
665
- ) ,
672
+ Err ( err) => {
673
+ cx . sess ( ) . span_err ( err . span , & * err . description ( ) ) ;
674
+ cx . sess ( ) . span_fatal ( e . span , "constant indexing failed" ) ;
675
+ } ,
666
676
}
667
677
}
668
678
ast:: ExprCast ( ref base, _) => {
0 commit comments