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 or the MIT license +// , 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() {}