@@ -1177,46 +1177,40 @@ pub fn eval_const_expr_partial<'tcx>(tcx: &ty::ctxt<'tcx>,
1177
1177
} ,
1178
1178
hir:: ExprTupField ( ref base, index) => {
1179
1179
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)
1188
1185
} else {
1189
- unreachable ! ( )
1186
+ signal ! ( e , TupleIndexOutOfBounds ) ;
1190
1187
}
1191
1188
} else {
1192
- signal ! ( base , ExpectedConstTuple ) ;
1189
+ unreachable ! ( )
1193
1190
}
1194
1191
} else {
1195
- signal ! ( base, NonConstPath )
1192
+ signal ! ( base, ExpectedConstTuple ) ;
1196
1193
}
1197
1194
}
1198
1195
hir:: ExprField ( ref base, field_name) => {
1199
1196
let base_hint = ty_hint. erase_hint ( ) ;
1200
1197
// 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)
1212
1206
} else {
1213
- unreachable ! ( )
1207
+ signal ! ( e , MissingStructField ) ;
1214
1208
}
1215
1209
} else {
1216
- signal ! ( base , ExpectedConstStruct ) ;
1210
+ unreachable ! ( )
1217
1211
}
1218
1212
} else {
1219
- signal ! ( base, NonConstPath ) ;
1213
+ signal ! ( base, ExpectedConstStruct ) ;
1220
1214
}
1221
1215
}
1222
1216
_ => signal ! ( e, MiscCatchAll )
0 commit comments