Skip to content

Cannot use #[deriving(Encodable)] on unit-like struct #14021

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

Closed
andrewd18 opened this issue May 7, 2014 · 0 comments · Fixed by #14596
Closed

Cannot use #[deriving(Encodable)] on unit-like struct #14021

andrewd18 opened this issue May 7, 2014 · 0 comments · Fixed by #14596

Comments

@andrewd18
Copy link

I have a nested data structure with a few unit-like structs as placeholders. When I tried to encode the structure, I received a "not all control paths return a value" when using #[deriving(Encodable] on said unit-like structs. Works great when I take said structs out or give them data.

Unsure if bug or feature.

extern crate serialize;
use serialize::{json};

#[deriving(Encodable)]
struct UnitLikeStruct;

fn main() {
    let to_encode_object = UnitLikeStruct;
    let encoded_str: ~str = json::Encoder::str_encode(&to_encode_object);

    println!("{}", encoded_str);
}

Using a slightly older pre-nightly on Windows 7:
C:\Program Files (x86)\Rust\bin\rustc.exe 0.11-pre-nightly (1853619 2014-04-17 01:31:27 -0700)

Sawyer47 added a commit to Sawyer47/rust that referenced this issue Jun 2, 2014
bors pushed a commit to rust-lang-ci/rust that referenced this issue Jan 28, 2025
…#14021)

part of rust-lang/rust-clippy#9100

The `obfuscated_if_else` lint currently only triggers for the pattern
`.then_some(..).unwrap_or(..)`, but there're other cases where this lint
should be triggered, one of which is `.then(..).unwrap_or(..)`.

changelog: [`obfuscated_if_else`]: trigger lint for the
`.then(..).unwrap_or(..)` pattern as well
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant