rust-lang / rustfmt

Format Rust code
https://rust-lang.github.io/rustfmt/
Apache License 2.0
6.06k stars 892 forks source link

cargo fmt --all succeeds but --check fails #3136

Closed gnzlbg closed 6 years ago

gnzlbg commented 6 years ago

For the ctest crate, https://github.com/alexcrichton/ctest/commit/9480ee376ef3b24567ca0b208b7e9b9faa19f82b (hash: 9480ee376ef3b24567ca0b208b7e9b9faa19f82b).

cargo fmt --all succeeds but cargo fmt --all -- --check fails with:

Diff in /home/travis/build/gnzlbg/ctest/src/lib.rs at line 721:
             should_test: false,
             sess: &sess,
             features: None,
-        }
-        .fold_crate(krate);
+        }.fold_crate(krate);

         // Probe the crate to find all structs, unions and type aliases (used to convert type names
         // to names in C).
Diff in /home/travis/build/gnzlbg/ctest/src/lib.rs at line 1816:
                         parse_sess: self.parse_sess,
                         features: &features,
                         map: &mut self.map,
-                    }
-                    .visit_item(item);
+                    }.visit_item(item);
                 }
             }
             _ => {}
Diff in /home/travis/build/gnzlbg/ctest/testcrate/build.rs at line 24:
             t if is_struct => format!("struct {}", t),
             t if is_union => format!("union {}", t),
             t => t.to_string(),
-        })
-        .generate("src/t1.rs", "t1gen.rs");
+        }).generate("src/t1.rs", "t1gen.rs");
     ctest::TestGenerator::new()
         .header("t2.h")
         .include("src")
Diff in /home/travis/build/gnzlbg/ctest/testcrate/build.rs at line 33:
             t if is_struct => format!("struct {}", t),
             t if is_union => format!("union {}", t),
             t => t.to_string(),
-        })
-        .generate("src/t2.rs", "t2gen.rs");
+        }).generate("src/t2.rs", "t2gen.rs");
 }

cc @nrc @topecongiro - this makes rustfmt not usable on ctest's CI :/

FWIW I cannot reproduce this on MacOSX, but I do reproduce this on travis-CI linux (x86_64-unknown-linux-gnu): https://travis-ci.org/gnzlbg/ctest/jobs/446071507#L459

gnzlbg commented 6 years ago

Duh, CI was using stable rust, and I was using nightly rust, i'm truly sorry for the noise!