Skip to content

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

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
autozimu opened this issue Jan 5, 2018 · 1 comment
Closed

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

autozimu opened this issue Jan 5, 2018 · 1 comment

Comments

@autozimu
Copy link
Member

autozimu commented Jan 5, 2018

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.

@nrc
Copy link
Member

nrc commented Jan 5, 2018

dup of #2338

@nrc nrc closed this as completed Jan 5, 2018
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

No branches or pull requests

2 participants