From 388f822682ad63d3bb7b26ae33cb775681f8856e Mon Sep 17 00:00:00 2001 From: Lukasz Anforowicz Date: Wed, 10 Jan 2024 21:08:41 +0000 Subject: [PATCH] Explicitly specify `--config-path` when invoking `rustfmt`. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This prevents `rustfmt` from looking up directory-specific configs (e.g. `third_party/rust/chromium_crates_io/vendor/tinyvec-1.6.0/rustfmt.toml`) and using them instead of the Chromium config. Fixed: 1517348 Change-Id: I5231443479f1f417608ecac263808dc91963948f Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5185319 Reviewed-by: danakj Reviewed-by: Josip Sokcevic Commit-Queue: Josip Sokcevic Auto-Submit: Ɓukasz Anforowicz --- git_cl.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/git_cl.py b/git_cl.py index 9b8d91b8b..edafad647 100755 --- a/git_cl.py +++ b/git_cl.py @@ -6208,9 +6208,12 @@ def _RunRustFmt(opts, rust_diff_files, top_dir, upstream_commit): except rustfmt.NotFoundError as e: DieWithError(e) + chromium_src_path = gclient_paths.GetPrimarySolutionPath() + rustfmt_toml_path = os.path.join(chromium_src_path, '.rustfmt.toml') + # TODO(crbug.com/1440869): Support formatting only the changed lines # if `opts.full or settings.GetFormatFullByDefault()` is False. - cmd = [rustfmt_tool] + cmd = [rustfmt_tool, f'--config-path={rustfmt_toml_path}'] if opts.dry_run: cmd.append('--check') cmd += rust_diff_files