mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-06-15 05:01:02 +00:00
Test the new errors on conflicting enum tags
This commit is contained in:
@@ -229,7 +229,7 @@ fn check_adjacent_tag_conflict(cx: &Ctxt, cont: &Container) {
|
|||||||
|
|
||||||
if type_tag == content_tag {
|
if type_tag == content_tag {
|
||||||
let message = format!(
|
let message = format!(
|
||||||
"Enum tags `{}` for type and content conflict with each other",
|
"enum tags `{}` for type and content conflict with each other",
|
||||||
type_tag
|
type_tag
|
||||||
);
|
);
|
||||||
cx.error(message);
|
cx.error(message);
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
// 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
|
||||||
|
#[serde(tag = "conflict", content = "conflict")]
|
||||||
|
//~^^ HELP: enum tags `conflict` for type and content conflict with each other
|
||||||
|
enum E {
|
||||||
|
A,
|
||||||
|
B,
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
// 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
|
||||||
|
#[serde(tag = "conflict")]
|
||||||
|
//~^^ HELP: variant field name `conflict` conflicts with internal tag
|
||||||
|
enum E {
|
||||||
|
A {
|
||||||
|
#[serde(rename = "conflict")]
|
||||||
|
x: (),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
||||||
Reference in New Issue
Block a user