@@ -1177,46 +1177,40 @@ pub fn eval_const_expr_partial<'tcx>(tcx: &ty::ctxt<'tcx>,
11771177 } ,
11781178 hir:: ExprTupField ( ref base, index) => {
11791179 let base_hint = ty_hint. erase_hint ( ) ;
1180- if let Ok ( c) = eval_const_expr_partial ( tcx, base, base_hint, fn_args) {
1181- if let Tuple ( tup_id) = c {
1182- if let hir:: ExprTup ( ref fields) = tcx. map . expect_expr ( tup_id) . node {
1183- if index. node < fields. len ( ) {
1184- return eval_const_expr_partial ( tcx, & fields[ index. node ] , base_hint, fn_args)
1185- } else {
1186- signal ! ( e, TupleIndexOutOfBounds ) ;
1187- }
1180+ let c = try!( eval_const_expr_partial ( tcx, base, base_hint, fn_args) ) ;
1181+ if let Tuple ( tup_id) = c {
1182+ if let hir:: ExprTup ( ref fields) = tcx. map . expect_expr ( tup_id) . node {
1183+ if index. node < fields. len ( ) {
1184+ return eval_const_expr_partial ( tcx, & fields[ index. node ] , base_hint, fn_args)
11881185 } else {
1189- unreachable ! ( )
1186+ signal ! ( e , TupleIndexOutOfBounds ) ;
11901187 }
11911188 } else {
1192- signal ! ( base , ExpectedConstTuple ) ;
1189+ unreachable ! ( )
11931190 }
11941191 } else {
1195- signal ! ( base, NonConstPath )
1192+ signal ! ( base, ExpectedConstTuple ) ;
11961193 }
11971194 }
11981195 hir:: ExprField ( ref base, field_name) => {
11991196 let base_hint = ty_hint. erase_hint ( ) ;
12001197 // Get the base expression if it is a struct and it is constant
1201- if let Ok ( c) = eval_const_expr_partial ( tcx, base, base_hint, fn_args) {
1202- if let Struct ( struct_id) = c {
1203- if let hir:: ExprStruct ( _, ref fields, _) = tcx. map . expect_expr ( struct_id) . node {
1204- // Check that the given field exists and evaluate it
1205- // if the idents are compared run-pass/issue-19244 fails
1206- if let Some ( f) = fields. iter ( ) . find ( |f| f. name . node
1207- == field_name. node ) {
1208- return eval_const_expr_partial ( tcx, & * f. expr , base_hint, fn_args)
1209- } else {
1210- signal ! ( e, MissingStructField ) ;
1211- }
1198+ let c = try!( eval_const_expr_partial ( tcx, base, base_hint, fn_args) ) ;
1199+ if let Struct ( struct_id) = c {
1200+ if let hir:: ExprStruct ( _, ref fields, _) = tcx. map . expect_expr ( struct_id) . node {
1201+ // Check that the given field exists and evaluate it
1202+ // if the idents are compared run-pass/issue-19244 fails
1203+ if let Some ( f) = fields. iter ( ) . find ( |f| f. name . node
1204+ == field_name. node ) {
1205+ return eval_const_expr_partial ( tcx, & * f. expr , base_hint, fn_args)
12121206 } else {
1213- unreachable ! ( )
1207+ signal ! ( e , MissingStructField ) ;
12141208 }
12151209 } else {
1216- signal ! ( base , ExpectedConstStruct ) ;
1210+ unreachable ! ( )
12171211 }
12181212 } else {
1219- signal ! ( base, NonConstPath ) ;
1213+ signal ! ( base, ExpectedConstStruct ) ;
12201214 }
12211215 }
12221216 _ => signal ! ( e, MiscCatchAll )
0 commit comments