Skip to content

Commit 88517f9

Browse files
committed
auto merge of #7000 : Blei/rust/fix-6155, r=catamorphism
2 parents 3fc0524 + 080a462 commit 88517f9

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-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);
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// Issue #6155
12+
13+
fn first((value, _): (int, float)) -> int { value }
14+
15+
fn main() {
16+
let y = first ((1,2,3)); //~ ERROR expected a tuple with 2 elements but found one with 3 elements
17+
}

0 commit comments

Comments
 (0)