Description
After upgrading to d3eba76e4d63c08fa0c4406745d1f0cc0e576758
, I'm seeing some truly bizarre (and quite disturbing) behavior of rustfmt. Specifically, when I format a particular file in my project, rustfmt
overwrites a bunch of other files with the contents of that file! A console example will likely be most helpful:
$ rustfmt --version
0.6.3 (d3eba76)
$ cargo b
Compiling xxx v0.1.0 (file:///home/jon/dev/projects/xxx)
Finished debug [unoptimized + debuginfo] target(s) in 3.97 secs
$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working tree clean
$ diff -q benchmarks/targets/memcached.rs benchmarks/vote.rs
Files benchmarks/targets/memcached.rs and benchmarks/vote.rs differ
$ rustfmt benchmarks/vote.rs
$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: benchmarks/targets/memcached.rs
Untracked files:
(use "git add <file>..." to include in what will be committed)
benchmarks/targets/memcached.rs.bk
no changes added to commit (use "git add" and/or "git commit -a")
$ diff -q benchmarks/targets/memcached.rs benchmarks/vote.rs
$
This is a somewhat large codebase that isn't public (yet), and so I unfortunately can't point you at the source. The basic structure is as follows though:
$ cat Cargo.toml
...
[features]
b_memcached = ["memcache"]
...
[lib]
name = "xxx"
path = "src/lib.rs"
...
[[bin]]
name = "vote"
path = "benchmarks/vote.rs"
$ ls -laR benchmarks/
drwxr-xr-x 1 jon users 92 Nov 25 12:56 targets/
-rw-r--r-- 1 jon users 10598 Nov 25 12:53 vote.rs
benchmarks/targets:
-rw-r--r-- 1 jon users 1900 Nov 25 12:56 memcached.rs
-rw-r--r-- 1 jon users 524 Nov 25 12:47 mod.rs
$ grep -EB1 '^mod ' benchmarks/vote.rs
mod targets;
$ grep -EB1 '^pub mod ' benchmarks/targets/mod.rs
...
#[cfg(feature="b_memcached")]
pub mod memcached;
The other files that are overwritten are all of the same form as benchmarks/targets/memcached.rs
(i.e., they are compiled under a #[cfg(feature = ...)]
directive). I have other modules that work the same way, but that are not conditionally compiled, and they are not overwritten by rustfmt
.