Explicitly specify `--config-path` when invoking `rustfmt`.

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 <danakj@chromium.org>
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Josip Sokcevic <sokcevic@chromium.org>
Auto-Submit: Łukasz Anforowicz <lukasza@chromium.org>
changes/19/5185319/3
Lukasz Anforowicz 2 years ago committed by LUCI CQ
parent 85142e0ee1
commit 388f822682

@ -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

Loading…
Cancel
Save