From 99614c72664d887ac586aa0d30831ff3e614f004 Mon Sep 17 00:00:00 2001
From: Armin Ronacher <armin.ronacher@active-4.com>
Date: Tue, 20 Mar 2018 22:15:47 +0100
Subject: [PATCH] Added flatten on enum compile fail test

---
 serde_derive_internals/src/check.rs           |  2 +-
 .../enum-representation/flatten-enum.rs       | 21 +++++++++++++++++++
 2 files changed, 22 insertions(+), 1 deletion(-)
 create mode 100644 test_suite/tests/compile-fail/enum-representation/flatten-enum.rs

diff --git a/serde_derive_internals/src/check.rs b/serde_derive_internals/src/check.rs
index 7afe42ca..0ed8afe6 100644
--- a/serde_derive_internals/src/check.rs
+++ b/serde_derive_internals/src/check.rs
@@ -46,7 +46,7 @@ fn check_flatten(cx: &Ctxt, cont: &Container) {
     match cont.data {
         Data::Enum(_) => {
             if cont.attrs.has_flatten() {
-                cx.error("#[serde(flatten)] is not allowed in an enum");
+                cx.error("#[serde(flatten)] is not supported on enums");
             }
         }
         Data::Struct(_, _) => {
diff --git a/test_suite/tests/compile-fail/enum-representation/flatten-enum.rs b/test_suite/tests/compile-fail/enum-representation/flatten-enum.rs
new file mode 100644
index 00000000..87fba41c
--- /dev/null
+++ b/test_suite/tests/compile-fail/enum-representation/flatten-enum.rs
@@ -0,0 +1,21 @@
+// Copyright 2018 Serde Developers
+//
+// 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.
+
+#[macro_use]
+extern crate serde_derive;
+
+#[derive(Serialize)] //~ ERROR: proc-macro derive panicked
+//~^ HELP: #[serde(flatten] is not supported on enums
+enum Foo {
+    #[serde(flatten)]
+    Foo {
+        x: u32,
+    }
+}
+
+fn main() {}