Skip to content

Commit 080a462

Browse files
committed
rustc::typeck: fix array out of bounds
Fixes #6155
1 parent 3209951 commit 080a462

File tree

1 file changed

+6
-1
lines changed
  • src/librustc/middle/typeck/check

1 file changed

+6
-1
lines changed

src/librustc/middle/typeck/check/mod.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2728,8 +2728,13 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
27282728
});
27292729
let mut bot_field = false;
27302730
let mut err_field = false;
2731+
27312732
let elt_ts = do elts.mapi |i, e| {
2732-
check_expr_with_opt_hint(fcx, *e, flds.map(|fs| fs[i]));
2733+
let opt_hint = match flds {
2734+
Some(ref fs) if i < fs.len() => Some(fs[i]),
2735+
_ => None
2736+
};
2737+
check_expr_with_opt_hint(fcx, *e, opt_hint);
27332738
let t = fcx.expr_ty(*e);
27342739
err_field = err_field || ty::type_is_error(t);
27352740
bot_field = bot_field || ty::type_is_bot(t);

0 commit comments

Comments
 (0)