@@ -1182,46 +1182,40 @@ pub fn eval_const_expr_partial<'tcx>(tcx: &ty::ctxt<'tcx>,
11821182 } ,
11831183 hir:: ExprTupField ( ref base, index) => {
11841184 let base_hint = ty_hint. erase_hint ( ) ;
1185- if let Ok ( c) = eval_const_expr_partial ( tcx, base, base_hint, fn_args) {
1186- if let Tuple ( tup_id) = c {
1187- if let hir:: ExprTup ( ref fields) = tcx. map . expect_expr ( tup_id) . node {
1188- if index. node < fields. len ( ) {
1189- return eval_const_expr_partial ( tcx, & fields[ index. node ] , base_hint, fn_args)
1190- } else {
1191- signal ! ( e, TupleIndexOutOfBounds ) ;
1192- }
1185+ let c = try!( eval_const_expr_partial ( tcx, base, base_hint, fn_args) ) ;
1186+ if let Tuple ( tup_id) = c {
1187+ if let hir:: ExprTup ( ref fields) = tcx. map . expect_expr ( tup_id) . node {
1188+ if index. node < fields. len ( ) {
1189+ return eval_const_expr_partial ( tcx, & fields[ index. node ] , base_hint, fn_args)
11931190 } else {
1194- unreachable ! ( )
1191+ signal ! ( e , TupleIndexOutOfBounds ) ;
11951192 }
11961193 } else {
1197- signal ! ( base , ExpectedConstTuple ) ;
1194+ unreachable ! ( )
11981195 }
11991196 } else {
1200- signal ! ( base, NonConstPath )
1197+ signal ! ( base, ExpectedConstTuple ) ;
12011198 }
12021199 }
12031200 hir:: ExprField ( ref base, field_name) => {
12041201 let base_hint = ty_hint. erase_hint ( ) ;
12051202 // Get the base expression if it is a struct and it is constant
1206- if let Ok ( c) = eval_const_expr_partial ( tcx, base, base_hint, fn_args) {
1207- if let Struct ( struct_id) = c {
1208- if let hir:: ExprStruct ( _, ref fields, _) = tcx. map . expect_expr ( struct_id) . node {
1209- // Check that the given field exists and evaluate it
1210- // if the idents are compared run-pass/issue-19244 fails
1211- if let Some ( f) = fields. iter ( ) . find ( |f| f. name . node
1212- == field_name. node ) {
1213- return eval_const_expr_partial ( tcx, & * f. expr , base_hint, fn_args)
1214- } else {
1215- signal ! ( e, MissingStructField ) ;
1216- }
1203+ let c = try!( eval_const_expr_partial ( tcx, base, base_hint, fn_args) ) ;
1204+ if let Struct ( struct_id) = c {
1205+ if let hir:: ExprStruct ( _, ref fields, _) = tcx. map . expect_expr ( struct_id) . node {
1206+ // Check that the given field exists and evaluate it
1207+ // if the idents are compared run-pass/issue-19244 fails
1208+ if let Some ( f) = fields. iter ( ) . find ( |f| f. name . node
1209+ == field_name. node ) {
1210+ return eval_const_expr_partial ( tcx, & * f. expr , base_hint, fn_args)
12171211 } else {
1218- unreachable ! ( )
1212+ signal ! ( e , MissingStructField ) ;
12191213 }
12201214 } else {
1221- signal ! ( base , ExpectedConstStruct ) ;
1215+ unreachable ! ( )
12221216 }
12231217 } else {
1224- signal ! ( base, NonConstPath ) ;
1218+ signal ! ( base, ExpectedConstStruct ) ;
12251219 }
12261220 }
12271221 _ => signal ! ( e, MiscCatchAll )
0 commit comments