Skip to content

serde_json json! macro content got corrupted after cargo fmt #2340

Closed
@autozimu

Description

@autozimu

Simplified example main.rs

#[macro_use]
extern crate serde_json;

fn main() {
    let l = vec![1, 2, 3];
    let ret: Vec<_> = l
        .into_iter()
        .map(|i| {
            json!({
                "value": i,
                "value2": i * 2,
            })
        })
    .collect();
}

After running cargo fmt, it becomes

#[macro_use]
extern crate serde_json;

fn main() {
    let l = vec![1, 2, 3];
    let ret: Vec<_> = l.into_iter().map(|i| json!({ "value": i })).collect();
}

As it shows, the second property inside json! was removed.

Expected

cargo fmt/rustfmt should not remove the second property inside json! macro.

Extra Info

$ rustc --version
rustc 1.24.0-nightly (0a3761e63 2018-01-03)
$ cargo fmt --version
0.3.4-nightly ( )

Let me know if extra info is needed. Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions