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

rustfmt destroys json! (and other?) macro calls #2347

Closed
chaaz opened this issue Jan 9, 2018 · 2 comments
Closed

rustfmt destroys json! (and other?) macro calls #2347

chaaz opened this issue Jan 9, 2018 · 2 comments

Comments

@chaaz
Copy link

chaaz commented Jan 9, 2018

I use the json! macro from serde_json (https://docs.serde.rs/serde_json/macro.json.html) quite a bit, but since version 0.3.4, rustfmt has been eating everything! This is not good.

$ git log -1
commit 6714a447d063b079de8fb2884ded2c8c3e96bc1d (HEAD, tag: 0.3.4)
Author: Seiichi Uchida <[email protected]>
Date:   Sat Dec 23 12:25:42 2017 +0900

    0.3.4
$ rustup run nightly cargo install --force --path .
  Installing rustfmt-nightly v0.3.4 (file:///.../rustfmt)
   Compiling rustfmt-nightly v0.3.4 (file:///.../rustfmt)
    Finished release [optimized] target(s) in 30.76 secs
   Replacing /.../.cargo/bin/rustfmt
   Replacing /.../.cargo/bin/cargo-fmt
   Replacing /.../.cargo/bin/rustfmt-format-diff
   Replacing /.../.cargo/bin/git-fmt
$ rustup run nightly rustfmt --write-mode=diff testme.rs
Diff in /Users/charlieozinga/Documents/Projects/gits/g2c/testme.rs at line 1:
 fn main() {⏎
-  let value = json!({⏎
-    "hello": "this is text",⏎
-    "goodbye": 123.4⏎
-  });⏎
+  let value = json!({});⏎
 }⏎
 ⏎
@chaaz
Copy link
Author

chaaz commented Jan 9, 2018

Hmm.. looks like there's already a test for this (sort of) that's failing? Maybe it's the latest rust toolchain that's the culprit?

$ rustc --version
rustc 1.25.0-nightly (ee220daca 2018-01-07)
$ cargo test
...
Mismatch at tests/target/macros.rs:213:
 ⏎
 // #1577⏎
 fn issue1577() {⏎
-    let json = json!({⏎
-        "foo": "bar",⏎
-    });⏎
+    let json =⏎
+        json!({});⏎

@nrc
Copy link
Member

nrc commented Jan 9, 2018

dup of #2338

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