Added flatten on enum compile fail test

This commit is contained in:
Armin Ronacher 2018-03-20 22:15:47 +01:00
parent bb2ecb3bc4
commit 99614c7266
2 changed files with 22 additions and 1 deletions

View File

@ -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(_, _) => {

View File

@ -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() {}