diff options
| author | bors <bors@rust-lang.org> | 2014-06-30 10:26:28 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-06-30 10:26:28 +0000 |
| commit | 287dcb77b34b421256c1d9cf26f3101276d2f486 (patch) | |
| tree | 6cca8c6a154e4e8e454f97a01d76f4e5c212bcf5 | |
| parent | 2735c7bb104d0938bccd261c5ea0d083f05ceba5 (diff) | |
| parent | 6821a18122826f051f07e9255c8ef5fe93f7e364 (diff) | |
| download | rust-287dcb77b34b421256c1d9cf26f3101276d2f486.tar.gz rust-287dcb77b34b421256c1d9cf26f3101276d2f486.zip | |
auto merge of #15262 : zecozephyr/rust/15620, r=luqmana
Fixes #15260
| -rw-r--r-- | src/librustc/middle/typeck/check/_match.rs | 3 | ||||
| -rw-r--r-- | src/test/compile-fail/issue-15260.rs | 19 |
2 files changed, 22 insertions, 0 deletions
diff --git a/src/librustc/middle/typeck/check/_match.rs b/src/librustc/middle/typeck/check/_match.rs index 67437da44c5..60ce9508dc4 100644 --- a/src/librustc/middle/typeck/check/_match.rs +++ b/src/librustc/middle/typeck/check/_match.rs @@ -318,6 +318,9 @@ pub fn check_struct_pat_fields(pcx: &pat_ctxt, for field in fields.iter() { match field_map.find_mut(&field.ident.name) { Some(&(_, true)) => { + // Check the pattern anyway, so that attempts to look + // up its type won't fail + check_pat(pcx, &*field.pat, ty::mk_err()); tcx.sess.span_err(span, format!("field `{}` bound twice in pattern", token::get_ident(field.ident)).as_slice()); diff --git a/src/test/compile-fail/issue-15260.rs b/src/test/compile-fail/issue-15260.rs new file mode 100644 index 00000000000..06826139884 --- /dev/null +++ b/src/test/compile-fail/issue-15260.rs @@ -0,0 +1,19 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct Foo { + a: uint, +} + +fn main(){ + let Foo {a: _, a: _} = Foo {a: 29}; + //~^ ERROR field `a` bound twice in pattern +} + |
