Conversation
ba0a09c to
6bc2a74
Compare
|
I still some concerns regarding the distinction between the dir mode and the TOML mode, so reconverting to draft. |
6bc2a74 to
3f3d54b
Compare
|
Addressed the concern regarding mode switching; updated both the PR description accordingly to reflect the new design. This PR is ready for review 🙏 |
Could you expand more on this use case, where is |
|
@matthewhughes934 TLDR, I'll interpret this case as "I want to override the config file name, but at the same time I also want to override the base directory, but unfortunately they are under the same flag". In the case I posted above, I have Unfortunately, Looking back, of course you can argue that it's not
If you agree with this, I can change the feature commit quite quickly to reflect it. |
👍 this sounds good to me, I think the directory behaviour sounds closer to what's documented in the help output. It might be worth further discussing the file behaviour (there's also some discussion on it with #5206), but that's best done separately to this change. CC @ytmimi since you were discussing on the original issue |
3f3d54b to
4270e15
Compare
|
@matthewhughes934 No problem, I have rewritten the PR as suggested. Please review! |
4270e15 to
8ac9f20
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
8ac9f20 to
975aac6
Compare
975aac6 to
1d459ca
Compare
|
Also probably r? @ytmimi |
|
@rustbot ready |
Note
LLM has been used to analyze the existing usage of directory walking behavior.
The implementation of this patch is otherwise fully manual.
Closes #4660 based on the design discussed in #4660 (comment).
Background
The
--config-pathhelp description says:However this description is not quite appropriate because:
rustfmt.To be more precise, the current semantics of
--config-pathis that when it receives apath, it chooses to enter one of the following modes in the below fallback order:pathis exists and metadata says it's a dir, then search for predefined names ([".rustfmt.toml", "rustfmt.toml"]) underpathonly. Bails out if none is found.pathexists and the metadata says it's not a dir, then interpret it as a TOML file. Bails out if none is found.Proposed solution
This PR changes it to:
pathterminates withexists and metadata says it's a dir, then search for predefined names (/, or if it[".rustfmt.toml", "rustfmt.toml"]) underpathand all its parents. Bails out if none is found.Otherwise, interpret it as a TOML file by searching for its filename under its parent dir and all parents of the latter. Bails out if none is found.Remains unchanged as per fix(config): search for config file recursively on--config-path#7115 (comment).