rollup merge of #19087: jakub-/issue-19086

Fixes #19086.

Whilst the code that this PR renders invalid was never meant to be valid, this is still a...

[breaking-change]
This commit is contained in:
Jakub Bukaj 2014-11-19 22:39:29 +01:00
commit 7884dd9cec
2 changed files with 24 additions and 2 deletions

View File

@ -379,7 +379,8 @@ pub fn check_pat_enum<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>, pat: &ast::Pat,
let real_path_ty = fcx.node_ty(pat.id);
let (arg_tys, kind_name) = match real_path_ty.sty {
ty::ty_enum(enum_def_id, ref expected_substs) => {
ty::ty_enum(enum_def_id, ref expected_substs)
if def == def::DefVariant(enum_def_id, def.def_id(), false) => {
let variant = ty::enum_variant_with_id(tcx, enum_def_id, def.def_id());
(variant.args.iter().map(|t| t.subst(tcx, expected_substs)).collect::<Vec<_>>(),
"variant")
@ -392,7 +393,7 @@ pub fn check_pat_enum<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>, pat: &ast::Pat,
_ => {
let name = pprust::path_to_string(path);
span_err!(tcx.sess, pat.span, E0164,
"`{}` does not name a variant or a tuple struct", name);
"`{}` does not name a non-struct variant or a tuple struct", name);
fcx.write_error(pat.id);
if let Some(ref subpats) = *subpats {

View File

@ -0,0 +1,21 @@
// 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.
fn main() {
enum Foo {
FooB { x: i32, y: i32 }
}
let f = FooB { x: 3, y: 4 };
match f {
FooB(a, b) => println!("{} {}", a, b),
//~^ ERROR `FooB` does not name a non-struct variant or a tuple struct
}
}