Open
Description
As of 8b0b213, the help text is:
$ rustfmt -h
...
--config-path [Path for the configuration file]
Recursively searches the given path for the
rustfmt.toml config file. If not found reverts to the
input file path
Some points of confusion:
- How can there be a recursive search if the configure is a "file":
[Path for the configuration file]
?
a. It seems like this option can take a directory withrustfmt.toml
OR the file itself. - When passed a directory,
rustfmt
does not appear to search recursively for a config file through ancestors or decedent directories:$ mkdir -p /tmp/dir1/dir2/dir3 $ find /tmp/dir1/ /tmp/dir1/ /tmp/dir1/dir2 /tmp/dir1/dir2/dir3 $ strace target/debug/rustfmt --config-path=/tmp/dir1/dir2/ /dev/null |& rg dir1 -C1 execve("target/debug/rustfmt", ["target/debug/rustfmt", "--config-path=/tmp/dir1/dir2/", "/dev/null"], 0x7ffc4c2ad340 /* 61 vars */) = 0 brk(NULL) = 0x5607c5058000 -- statx(0, NULL, AT_STATX_SYNC_AS_STAT, STATX_ALL, NULL) = -1 EFAULT (Bad address) statx(AT_FDCWD, "/tmp/dir1/dir2/", AT_STATX_SYNC_AS_STAT, STATX_ALL, {stx_mask=STATX_ALL|0x1000, stx_attributes=0, stx_mode=S_IFDIR|0775, stx_size=4096, ...}) = 0 statx(AT_FDCWD, "/tmp/dir1/dir2/", AT_STATX_SYNC_AS_STAT, STATX_ALL, {stx_mask=STATX_ALL|0x1000, stx_attributes=0, stx_mode=S_IFDIR|0775, stx_size=4096, ...}) = 0 statx(AT_FDCWD, "/tmp/dir1/dir2/.rustfmt.toml", AT_STATX_SYNC_AS_STAT, STATX_ALL, 0x7ffc9118d8b0) = -1 ENOENT (No such file or directory) statx(AT_FDCWD, "/tmp/dir1/dir2/rustfmt.toml", AT_STATX_SYNC_AS_STAT, STATX_ALL, 0x7ffc9118d8b0) = -1 ENOENT (No such file or directory) write(2, "Error: unable to find a config f"..., 73Error: unable to find a config file for the given path: `/tmp/dir1/dir2/`) = 73 write(2, "\n", 1
- The last sentence says that if the file is not found, then "reverts to the input file path", but it seems like
rustfmt
will emit an error when the file does not existrustfmt --config-path=/does/not/exist /dev/null Error: unable to find a config file for the given path: `/does/not/exist`