Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deserialize failed to derive on enums with tuple variant and flatten struct variant #1904

Closed
Mingun opened this issue Oct 7, 2020 · 0 comments · Fixed by #2567
Closed

Deserialize failed to derive on enums with tuple variant and flatten struct variant #1904

Mingun opened this issue Oct 7, 2020 · 0 comments · Fixed by #2567

Comments

@Mingun
Copy link
Contributor

Mingun commented Oct 7, 2020

Instead of thousand of words

This code is failed to compile due to panic in serde derive:

#[derive(Deserialize)]
enum Failed {
    Tuple(f64, String),
    Flatten {
        #[serde(flatten)]
        nested: Nested,
    },
}

Output:

   Compiling playground v0.0.1 (/playground)
error: proc-macro derive panicked
  --> src/lib.rs:30:10
   |
30 | #[derive(Deserialize)]
   |          ^^^^^^^^^^^
   |
   = help: message: assertion failed: !cattrs.has_flatten()

error: aborting due to previous error

error: could not compile `playground`.

To learn more, run the command again with --verbose.

Each variant individually and Serialize derive works well, problem is only in combination of tuple variant and struct variant, when struct variant contains flattened field.

Mingun added a commit to Mingun/serde that referenced this issue Jul 23, 2023
Currently panics in derive
Mingun added a commit to Mingun/serde that referenced this issue Aug 1, 2023
Currently panics in derive
Mingun added a commit to Mingun/serde that referenced this issue Aug 10, 2023
Currently panics in derive
Mingun added a commit to Mingun/serde that referenced this issue Jul 23, 2024
Currently panics in derive
Mingun added a commit to Mingun/serde that referenced this issue Jul 23, 2024
Currently panics in derive
Mingun added a commit to Mingun/serde that referenced this issue Aug 9, 2024
Currently panics in derive:

error: proc-macro derive panicked
    --> test_suite\tests\test_annotations.rs:2386:25
     |
2386 |     #[derive(Serialize, Deserialize, PartialEq, Debug)]
     |                         ^^^^^^^^^^^
     |
     = help: message: assertion failed: !cattrs.has_flatten()

error: proc-macro derive panicked
  --> test_suite\tests\regression\issue1904.rs:57:10
   |
57 | #[derive(Deserialize)]
   |          ^^^^^^^^^^^
   |
   = help: message: assertion failed: !cattrs.has_flatten()

error: proc-macro derive panicked
  --> test_suite\tests\regression\issue1904.rs:47:10
   |
47 | #[derive(Deserialize)]
   |          ^^^^^^^^^^^
   |
   = help: message: assertion failed: !cattrs.has_flatten()

error: proc-macro derive panicked
  --> test_suite\tests\regression\issue1904.rs:37:10
   |
37 | #[derive(Deserialize)]
   |          ^^^^^^^^^^^
   |
   = help: message: assertion failed: !cattrs.has_flatten()

error: proc-macro derive panicked
  --> test_suite\tests\regression\issue1904.rs:27:10
   |
27 | #[derive(Deserialize)]
   |          ^^^^^^^^^^^
   |
   = help: message: assertion failed: !cattrs.has_flatten()

error: proc-macro derive panicked
  --> test_suite\tests\regression\issue1904.rs:16:10
   |
16 | #[derive(Deserialize)]
   |          ^^^^^^^^^^^
   |
   = help: message: assertion failed: !cattrs.has_flatten()

error: proc-macro derive panicked
 --> test_suite\tests\regression\issue1904.rs:7:10
  |
7 | #[derive(Deserialize)]
  |          ^^^^^^^^^^^
  |
  = help: message: assertion failed: !cattrs.has_flatten()
dtolnay added a commit that referenced this issue Aug 11, 2024
    warning: you should put bare URLs between `<`/`>` or make a proper Markdown link
        --> test_suite/tests/test_annotations.rs:2383:25
         |
    2383 | /// Regression test for #1904
         |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `<https://github.com/serde-rs/serde/issues/1904>`
         |
         = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#doc_markdown
         = note: `-W clippy::doc-markdown` implied by `-W clippy::pedantic`
         = help: to override `-W clippy::pedantic` add `#[allow(clippy::doc_markdown)]`
Mingun added a commit to Mingun/quick-xml that referenced this issue Oct 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant