diff options
| author | Manish Goregaokar <manishsmail@gmail.com> | 2015-07-16 14:14:19 +0530 |
|---|---|---|
| committer | Manish Goregaokar <manishsmail@gmail.com> | 2015-07-16 16:37:39 +0530 |
| commit | b64af26625a699ae49403202f41cf2c0dfc449ff (patch) | |
| tree | e57d4d493bf92cfc140f6589b3ba6715e2fe9be9 /src | |
| parent | 31d6716d9c537ea6927824800a3aa6e8c90e1713 (diff) | |
| parent | a878f35d3b6669ca473dce7b741788abb95e061f (diff) | |
| download | rust-b64af26625a699ae49403202f41cf2c0dfc449ff.tar.gz rust-b64af26625a699ae49403202f41cf2c0dfc449ff.zip | |
Rollup merge of #27018 - arielb1:enum-update, r=eddyb
Fixes #26948. r? @eddyb
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc_typeck/check/mod.rs | 5 | ||||
| -rw-r--r-- | src/librustc_typeck/diagnostics.rs | 3 | ||||
| -rw-r--r-- | src/test/compile-fail/issue-26948.rs | 16 |
3 files changed, 23 insertions, 1 deletions
diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 5a71d1ed0b5..a2fee091689 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -3426,6 +3426,11 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>, let def = lookup_full_def(tcx, path.span, id); let struct_id = match def { def::DefVariant(enum_id, variant_id, true) => { + if let &Some(ref base_expr) = base_expr { + span_err!(tcx.sess, base_expr.span, E0401, + "functional record update syntax requires a struct"); + fcx.write_error(base_expr.id); + } check_struct_enum_variant(fcx, id, expr.span, enum_id, variant_id, &fields[..]); enum_id diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs index 5027be5fb62..636a8aeb544 100644 --- a/src/librustc_typeck/diagnostics.rs +++ b/src/librustc_typeck/diagnostics.rs @@ -2209,6 +2209,7 @@ register_diagnostics! { E0392, // parameter `{}` is never used E0393, // the type parameter `{}` must be explicitly specified in an object // type because its default value `{}` references the type `Self`" - E0399 // trait items need to be implemented because the associated + E0399, // trait items need to be implemented because the associated // type `{}` was overridden + E0401 // functional record update requires a struct } diff --git a/src/test/compile-fail/issue-26948.rs b/src/test/compile-fail/issue-26948.rs new file mode 100644 index 00000000000..c63cb5defb7 --- /dev/null +++ b/src/test/compile-fail/issue-26948.rs @@ -0,0 +1,16 @@ +// Copyright 2015 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 { A { x: u32 } } + let orig = Foo::A { x: 5 }; + Foo::A { x: 6, ..orig }; + //~^ ERROR functional record update syntax requires a struct +} |
