mirror of
https://github.com/servo/servo.git
synced 2025-06-08 08:33:26 +00:00
mach: Do not use unstable rust for rustfmt
(#31441)
We can use stable rust if we pass the unstable configuration as command-line arguments to rustfmt itself. This prevents needing to install an unstable rust toolchain. The one downside here is that it doesn't seem that "ignore" is supported so we have to start formatting the files in "third_party." This shouldn't be a huge issue because we don't plan to check much more rust code into those directories.
This commit is contained in:
parent
2afd5431b1
commit
98bd306816
7 changed files with 32 additions and 21 deletions
|
@ -39,6 +39,15 @@ PROJECT_TOPLEVEL_PATH = os.path.abspath(os.path.join(SCRIPT_PATH, "..", ".."))
|
|||
WEB_PLATFORM_TESTS_PATH = os.path.join("tests", "wpt", "tests")
|
||||
SERVO_TESTS_PATH = os.path.join("tests", "wpt", "mozilla", "tests")
|
||||
|
||||
# Servo depends on several `rustfmt` options that are unstable. These are still
|
||||
# supported by stable `rustfmt` if they are passed as these command-line arguments.
|
||||
UNSTABLE_RUSTFMT_ARGUMENTS = [
|
||||
"--config", "unstable_features=true",
|
||||
"--config", "binop_separator=Back",
|
||||
"--config", "imports_granularity=Module",
|
||||
"--config", "group_imports=StdExternalCrate",
|
||||
]
|
||||
|
||||
|
||||
def format_toml_files_with_taplo(check_only: bool = True) -> int:
|
||||
taplo = shutil.which("taplo")
|
||||
|
@ -206,12 +215,12 @@ class MachCommands(CommandBase):
|
|||
def test_tidy(self, all_files, no_progress):
|
||||
tidy_failed = tidy.scan(not all_files, not no_progress)
|
||||
|
||||
call(["rustup", "install", "nightly-2023-03-18"])
|
||||
call(["rustup", "component", "add", "rustfmt", "--toolchain", "nightly-2023-03-18"])
|
||||
rustfmt_failed = call(["cargo", "+nightly-2023-03-18", "fmt", "--", "--check"])
|
||||
print("\r ➤ Checking formatting of rust files...")
|
||||
rustfmt_failed = call(["cargo", "fmt", "--", *UNSTABLE_RUSTFMT_ARGUMENTS, "--check"])
|
||||
if rustfmt_failed:
|
||||
print("Run `./mach fmt` to fix the formatting")
|
||||
|
||||
print("\r ➤ Checking formatting of toml files...")
|
||||
taplo_failed = format_toml_files_with_taplo()
|
||||
|
||||
tidy_failed = tidy_failed or rustfmt_failed or taplo_failed
|
||||
|
@ -323,9 +332,7 @@ class MachCommands(CommandBase):
|
|||
if result != 0:
|
||||
return result
|
||||
|
||||
call(["rustup", "install", "nightly-2023-03-18"])
|
||||
call(["rustup", "component", "add", "rustfmt", "--toolchain", "nightly-2023-03-18"])
|
||||
return call(["cargo", "+nightly-2023-03-18", "fmt"])
|
||||
return call(["cargo", "fmt", "--", *UNSTABLE_RUSTFMT_ARGUMENTS])
|
||||
|
||||
@Command('update-wpt',
|
||||
description='Update the web platform tests',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue