From 39ef61c324da49308bc4e796d6f5ac1257dd9c9b Mon Sep 17 00:00:00 2001 From: Samson <16504129+sagudev@users.noreply.github.com> Date: Fri, 8 Nov 2024 11:08:49 +0100 Subject: [PATCH] Exclude `crown` from the root Cargo workspace (#34173) * Exclude crown from workspace Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> * Update shell.nix and remove filterlock Signed-off-by: Delan Azabani --------- Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> Signed-off-by: Delan Azabani Co-authored-by: Delan Azabani --- Cargo.lock | 102 ---- Cargo.toml | 3 +- etc/shell.nix | 45 +- python/servo/testing_commands.py | 18 +- rust-toolchain.toml | 2 +- servo-tidy.toml | 1 + support/crown/.cargo/config.toml | 3 + support/crown/.gitignore | 1 + support/crown/Cargo.lock | 624 ++++++++++++++++++++++++ support/crown/crown.code-workspace | 22 + support/crown/rust-toolchain.toml | 13 + support/crown/rustfmt.toml | 2 + support/crown/src/crown_is_not_used.rs | 2 +- support/crown/src/trace_in_no_trace.rs | 3 +- support/crown/src/unrooted_must_root.rs | 3 +- support/filterlock/Cargo.lock | 147 ------ support/filterlock/Cargo.toml | 14 - support/filterlock/src/main.rs | 83 ---- 18 files changed, 693 insertions(+), 395 deletions(-) create mode 100644 support/crown/.gitignore create mode 100644 support/crown/Cargo.lock create mode 100644 support/crown/crown.code-workspace create mode 100644 support/crown/rust-toolchain.toml create mode 100644 support/crown/rustfmt.toml delete mode 100644 support/filterlock/Cargo.lock delete mode 100644 support/filterlock/Cargo.toml delete mode 100644 support/filterlock/src/main.rs diff --git a/Cargo.lock b/Cargo.lock index 90e2de2fab4..a4189886fc4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -963,29 +963,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "compiletest_rs" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71fcc3c0c91b59c137b3cf8073cbc2f72a49b3d5505660ec88f94da3ed4bb1de" -dependencies = [ - "diff", - "filetime", - "getopts", - "lazy_static", - "libc", - "log", - "miow", - "regex", - "rustfix", - "serde", - "serde_derive", - "serde_json", - "tempfile", - "tester", - "windows-sys 0.59.0", -] - [[package]] name = "compositing" version = "0.0.1" @@ -1298,13 +1275,6 @@ version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" -[[package]] -name = "crown" -version = "0.0.1" -dependencies = [ - "compiletest_rs", -] - [[package]] name = "crunchy" version = "0.2.2" @@ -1500,12 +1470,6 @@ dependencies = [ "uuid", ] -[[package]] -name = "diff" -version = "0.1.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56254986775e3233ffa9c4d7d3faaf6d36a2c09d30b20687e9f88bc8bafc16c8" - [[package]] name = "digest" version = "0.10.7" @@ -1561,16 +1525,6 @@ dependencies = [ "dirs-sys", ] -[[package]] -name = "dirs-next" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1" -dependencies = [ - "cfg-if", - "dirs-sys-next", -] - [[package]] name = "dirs-sys" version = "0.4.1" @@ -1583,17 +1537,6 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "dirs-sys-next" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d" -dependencies = [ - "libc", - "redox_users", - "winapi", -] - [[package]] name = "dispatch" version = "0.2.0" @@ -4474,15 +4417,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "miow" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "359f76430b20a79f9e20e115b3428614e654f04fab314482fc0fda0ebd3c6044" -dependencies = [ - "windows-sys 0.48.0", -] - [[package]] name = "mozangle" version = "0.5.2" @@ -5947,18 +5881,6 @@ dependencies = [ "semver", ] -[[package]] -name = "rustfix" -version = "0.8.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fb2b066405a6d48a1b39c0022270503e352ae84da0c24e1d5f8ffc38e97a325" -dependencies = [ - "serde", - "serde_json", - "thiserror", - "tracing", -] - [[package]] name = "rustix" version = "0.38.39" @@ -7199,17 +7121,6 @@ dependencies = [ "utf-8", ] -[[package]] -name = "term" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c59df8ac95d96ff9bede18eb7300b0fda5e5d8d90960e76f8e14ae765eedbf1f" -dependencies = [ - "dirs-next", - "rustversion", - "winapi", -] - [[package]] name = "termcolor" version = "1.4.1" @@ -7219,19 +7130,6 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "tester" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89e8bf7e0eb2dd7b4228cc1b6821fc5114cd6841ae59f652a85488c016091e5f" -dependencies = [ - "cfg-if", - "getopts", - "libc", - "num_cpus", - "term", -] - [[package]] name = "thin-vec" version = "0.2.13" diff --git a/Cargo.toml b/Cargo.toml index 52ff0ec90f8..ac9d8f076d0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,11 +2,10 @@ resolver = "2" members = [ "ports/servoshell", - "support/crown", "tests/unit/*", ] default-members = ["ports/servoshell"] -exclude = [".cargo"] +exclude = [".cargo", "support/crown"] [workspace.package] version = "0.0.1" diff --git a/etc/shell.nix b/etc/shell.nix index 79b02dcda1a..fe91b94bb63 100644 --- a/etc/shell.nix +++ b/etc/shell.nix @@ -92,52 +92,17 @@ stdenv.mkDerivation (androidEnvironment // { # See https://github.com/servo/mozjs/issues/375 pkgs_gnumake_4_3.gnumake - # crown needs to be in our Cargo workspace so we can test it with `mach test`. This means its - # dependency tree is listed in the main Cargo.lock, making it awkward to build with Nix because - # all of Servo’s dependencies get pulled into the Nix store too, wasting over 1GB of disk space. - # Filtering the lockfile to only the parts needed by crown saves space and builds faster. - (let - - # Build and run filterlock over the main Cargo.lock. - filteredLockFile = (clangStdenv.mkDerivation { - name = "lock"; - buildInputs = [ rustToolchain ]; - nativeBuildInputs = [ rustPlatform.cargoSetupHook ]; - src = ../support/filterlock; - cargoDeps = rustPlatform.importCargoLock { - lockFile = ../support/filterlock/Cargo.lock; - }; - buildPhase = '' - > $out cargo run --offline -- ${../Cargo.lock} crown - ''; - dontInstall = true; - }); - in (rustPlatform.buildRustPackage { + (rustPlatform.buildRustPackage { name = "crown"; src = ../support/crown; doCheck = false; cargoLock = { - lockFileContents = builtins.readFile filteredLockFile; - - # Needed when not filtering (filteredLockFile = ../Cargo.lock), else we’ll get errors like - # “error: No hash was found while vendoring the git dependency blurmac-0.1.0.” - # allowBuiltinFetchGit = true; + # crown is not in our Cargo workspace, so this only pulls crown and crown’s dependencies + # into the Nix store, not Servo and Servo’s dependencies. + lockFile = ../support/crown/Cargo.lock; }; - - # Copy the filtered lockfile, making it writable by cargo --offline. - postPatch = '' - install -m 644 ${filteredLockFile} Cargo.lock - ''; - - # Reformat the filtered lockfile, so that cargo --frozen won’t complain - # about the lockfile being dirty. - # TODO maybe this can be avoided by using toml_edit in filterlock? - preConfigure = '' - cargo update --offline - ''; - RUSTC_BOOTSTRAP = "crown"; - })) + }) ] ++ (lib.optionals stdenv.isDarwin [ darwin.apple_sdk.frameworks.AppKit ]) ++ (lib.optionals buildAndroid [ diff --git a/python/servo/testing_commands.py b/python/servo/testing_commands.py index 6837f855afb..de421068050 100644 --- a/python/servo/testing_commands.py +++ b/python/servo/testing_commands.py @@ -75,6 +75,16 @@ def format_toml_files_with_taplo(check_only: bool = True) -> int: return call([taplo, "fmt", *TOML_GLOBS], env={'RUST_LOG': 'error'}) +def format_with_rustfmt(check_only: bool = True) -> int: + maybe_check_only = ["--check"] if check_only else [] + result = call(["cargo", "fmt", "--", *UNSTABLE_RUSTFMT_ARGUMENTS, *maybe_check_only]) + if result != 0: + return result + + return call(["cargo", "fmt", "--manifest-path", "support/crown/Cargo.toml", + "--", *UNSTABLE_RUSTFMT_ARGUMENTS, *maybe_check_only]) + + @CommandProvider class MachCommands(CommandBase): DEFAULT_RENDER_MODE = "cpu" @@ -153,7 +163,6 @@ class MachCommands(CommandBase): "base", "compositing", "constellation", - "crown", "fonts", "hyper_serde", "layout_2013", @@ -205,6 +214,9 @@ class MachCommands(CommandBase): args += ["--", "--nocapture"] env = self.build_env() + result = call(["cargo", "bench" if bench else "test"], cwd="support/crown") + if result != 0: + return result return self.run_cargo_build_like_command( "bench" if bench else "test", args, @@ -231,7 +243,7 @@ class MachCommands(CommandBase): tidy_failed = tidy.scan(not all_files, not no_progress) print("\r ➤ Checking formatting of Rust files...") - rustfmt_failed = call(["cargo", "fmt", "--", *UNSTABLE_RUSTFMT_ARGUMENTS, "--check"]) + rustfmt_failed = format_with_rustfmt(check_only=True) if rustfmt_failed: print("Run `./mach fmt` to fix the formatting") @@ -344,7 +356,7 @@ class MachCommands(CommandBase): if result != 0: return result - return call(["cargo", "fmt", "--", *UNSTABLE_RUSTFMT_ARGUMENTS]) + return format_with_rustfmt(check_only=False) @Command('update-wpt', description='Update the web platform tests', diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 9542e0d8103..4a558ecd14a 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,5 +1,5 @@ [toolchain] -# Be sure to update etc/shell.nix when bumping this! +# Be sure to update etc/shell.nix and support/crown/rust-toolchain.toml when bumping this! channel = "1.80.1" components = [ diff --git a/servo-tidy.toml b/servo-tidy.toml index f23d222aa4b..04db7e8fa5f 100644 --- a/servo-tidy.toml +++ b/servo-tidy.toml @@ -122,6 +122,7 @@ directories = [ "./python/mach", # Generated and upstream code combined with our own. Could use cleanup "./target", + "./support/crown/target", "./third_party", ] diff --git a/support/crown/.cargo/config.toml b/support/crown/.cargo/config.toml index 66822bc1830..bcc884013e6 100644 --- a/support/crown/.cargo/config.toml +++ b/support/crown/.cargo/config.toml @@ -1,2 +1,5 @@ [build] rustc = "rustc" + +[env] +RUSTC_BOOTSTRAP = "1" diff --git a/support/crown/.gitignore b/support/crown/.gitignore new file mode 100644 index 00000000000..eb5a316cbd1 --- /dev/null +++ b/support/crown/.gitignore @@ -0,0 +1 @@ +target diff --git a/support/crown/Cargo.lock b/support/crown/Cargo.lock new file mode 100644 index 00000000000..b44fee0c3c8 --- /dev/null +++ b/support/crown/Cargo.lock @@ -0,0 +1,624 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "aho-corasick" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +dependencies = [ + "memchr", +] + +[[package]] +name = "bitflags" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "compiletest_rs" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71fcc3c0c91b59c137b3cf8073cbc2f72a49b3d5505660ec88f94da3ed4bb1de" +dependencies = [ + "diff", + "filetime", + "getopts", + "lazy_static", + "libc", + "log", + "miow", + "regex", + "rustfix", + "serde", + "serde_derive", + "serde_json", + "tempfile", + "tester", + "windows-sys 0.59.0", +] + +[[package]] +name = "crown" +version = "0.0.1" +dependencies = [ + "compiletest_rs", +] + +[[package]] +name = "diff" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56254986775e3233ffa9c4d7d3faaf6d36a2c09d30b20687e9f88bc8bafc16c8" + +[[package]] +name = "dirs-next" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1" +dependencies = [ + "cfg-if", + "dirs-sys-next", +] + +[[package]] +name = "dirs-sys-next" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d" +dependencies = [ + "libc", + "redox_users", + "winapi", +] + +[[package]] +name = "errno" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + +[[package]] +name = "fastrand" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6" + +[[package]] +name = "filetime" +version = "0.2.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35c0522e981e68cbfa8c3f978441a5f34b30b96e146b33cd3359176b50fe8586" +dependencies = [ + "cfg-if", + "libc", + "libredox", + "windows-sys 0.59.0", +] + +[[package]] +name = "getopts" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14dbbfd5c71d70241ecf9e6f13737f7b5ce823821063188d7e46c41d371eebd5" +dependencies = [ + "unicode-width", +] + +[[package]] +name = "getrandom" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "hermit-abi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" + +[[package]] +name = "itoa" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" + +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" + +[[package]] +name = "libc" +version = "0.2.161" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9489c2807c139ffd9c1794f4af0ebe86a828db53ecdc7fea2111d0fed085d1" + +[[package]] +name = "libredox" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" +dependencies = [ + "bitflags", + "libc", + "redox_syscall", +] + +[[package]] +name = "linux-raw-sys" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" + +[[package]] +name = "log" +version = "0.4.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" + +[[package]] +name = "memchr" +version = "2.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" + +[[package]] +name = "miow" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "359f76430b20a79f9e20e115b3428614e654f04fab314482fc0fda0ebd3c6044" +dependencies = [ + "windows-sys 0.48.0", +] + +[[package]] +name = "num_cpus" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" +dependencies = [ + "hermit-abi", + "libc", +] + +[[package]] +name = "once_cell" +version = "1.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" + +[[package]] +name = "pin-project-lite" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "915a1e146535de9163f3987b8944ed8cf49a18bb0056bcebcdcece385cece4ff" + +[[package]] +name = "proc-macro2" +version = "1.0.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "redox_syscall" +version = "0.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b6dfecf2c74bce2466cabf93f6664d6998a69eb21e39f4207930065b27b771f" +dependencies = [ + "bitflags", +] + +[[package]] +name = "redox_users" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43" +dependencies = [ + "getrandom", + "libredox", + "thiserror", +] + +[[package]] +name = "regex" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" + +[[package]] +name = "rustfix" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fb2b066405a6d48a1b39c0022270503e352ae84da0c24e1d5f8ffc38e97a325" +dependencies = [ + "serde", + "serde_json", + "thiserror", + "tracing", +] + +[[package]] +name = "rustix" +version = "0.38.39" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "375116bee2be9ed569afe2154ea6a99dfdffd257f533f187498c2a8f5feaf4ee" +dependencies = [ + "bitflags", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.52.0", +] + +[[package]] +name = "rustversion" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e819f2bc632f285be6d7cd36e25940d45b2391dd6d9b939e79de557f7014248" + +[[package]] +name = "ryu" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" + +[[package]] +name = "serde" +version = "1.0.214" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f55c3193aca71c12ad7890f1785d2b73e1b9f63a0bbc353c08ef26fe03fc56b5" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.214" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de523f781f095e28fa605cdce0f8307e451cc0fd14e2eb4cd2e98a355b147766" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.132" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d726bfaff4b320266d395898905d0eba0345aae23b54aee3a737e260fd46db03" +dependencies = [ + "itoa", + "memchr", + "ryu", + "serde", +] + +[[package]] +name = "syn" +version = "2.0.87" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "tempfile" +version = "3.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0f2c9fc62d0beef6951ccffd757e241266a2c833136efbe35af6cd2567dca5b" +dependencies = [ + "cfg-if", + "fastrand", + "once_cell", + "rustix", + "windows-sys 0.59.0", +] + +[[package]] +name = "term" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c59df8ac95d96ff9bede18eb7300b0fda5e5d8d90960e76f8e14ae765eedbf1f" +dependencies = [ + "dirs-next", + "rustversion", + "winapi", +] + +[[package]] +name = "tester" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89e8bf7e0eb2dd7b4228cc1b6821fc5114cd6841ae59f652a85488c016091e5f" +dependencies = [ + "cfg-if", + "getopts", + "libc", + "num_cpus", + "term", +] + +[[package]] +name = "thiserror" +version = "1.0.68" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02dd99dc800bbb97186339685293e1cc5d9df1f8fae2d0aecd9ff1c77efea892" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.68" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7c61ec9a6f64d2793d8a45faba21efbe3ced62a886d44c36a009b2b519b4c7e" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tracing" +version = "0.1.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" +dependencies = [ + "pin-project-lite", + "tracing-core", +] + +[[package]] +name = "tracing-core" +version = "0.1.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" +dependencies = [ + "once_cell", +] + +[[package]] +name = "unicode-ident" +version = "1.0.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" + +[[package]] +name = "unicode-width" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.5", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", + "windows_i686_gnullvm", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" diff --git a/support/crown/crown.code-workspace b/support/crown/crown.code-workspace new file mode 100644 index 00000000000..f150941df74 --- /dev/null +++ b/support/crown/crown.code-workspace @@ -0,0 +1,22 @@ +{ + "folders": [ + { + "name": "crown", + "path": "." + }, + ], + "settings": { + "rust-analyzer.check.command": "clippy", + "rust-analyzer.rustc.source": "discover", + "rust-analyzer.rustfmt.extraArgs": [ + "--config", + "unstable_features=true", + "--config", + "binop_separator=Back", + "--config", + "imports_granularity=Module", + "--config", + "group_imports=StdExternalCrate" + ] + }, +} \ No newline at end of file diff --git a/support/crown/rust-toolchain.toml b/support/crown/rust-toolchain.toml new file mode 100644 index 00000000000..2d13bc995bc --- /dev/null +++ b/support/crown/rust-toolchain.toml @@ -0,0 +1,13 @@ +[toolchain] +channel = "1.80.1" + +components = [ + "clippy", + # For support/crown + "llvm-tools", + # For support/crown + "rustc-dev", + # For formatting + "rustfmt", +] +profile = "minimal" diff --git a/support/crown/rustfmt.toml b/support/crown/rustfmt.toml new file mode 100644 index 00000000000..ecd1b1465d0 --- /dev/null +++ b/support/crown/rustfmt.toml @@ -0,0 +1,2 @@ +match_block_trailing_comma = true +reorder_imports = true diff --git a/support/crown/src/crown_is_not_used.rs b/support/crown/src/crown_is_not_used.rs index 66593a31e05..58515d6ed43 100644 --- a/support/crown/src/crown_is_not_used.rs +++ b/support/crown/src/crown_is_not_used.rs @@ -12,5 +12,5 @@ declare_lint! { } pub fn register(lint_store: &mut LintStore) { - lint_store.register_lints(&[&CROWN_IS_NOT_USED]); + lint_store.register_lints(&[CROWN_IS_NOT_USED]); } diff --git a/support/crown/src/trace_in_no_trace.rs b/support/crown/src/trace_in_no_trace.rs index c021c8ae245..059f1cd4894 100644 --- a/support/crown/src/trace_in_no_trace.rs +++ b/support/crown/src/trace_in_no_trace.rs @@ -34,7 +34,7 @@ empty Traceable (like primitive types). Consider removing the wrapper."; pub fn register(lint_store: &mut LintStore) { let symbols = Symbols::new(); - lint_store.register_lints(&[&TRACE_IN_NO_TRACE, &EMPTY_TRACE_IN_NO_TRACE]); + lint_store.register_lints(&[TRACE_IN_NO_TRACE, EMPTY_TRACE_IN_NO_TRACE]); lint_store.register_late_pass(move |_| Box::new(NotracePass::new(symbols.clone()))); } @@ -175,6 +175,7 @@ impl<'tcx> LateLintPass<'tcx> for NotracePass { } fn check_variant(&mut self, cx: &LateContext, var: &hir::Variant) { + #[allow(clippy::single_match)] match var.data { hir::VariantData::Tuple(fields, ..) => { for field in fields { diff --git a/support/crown/src/unrooted_must_root.rs b/support/crown/src/unrooted_must_root.rs index f870c021a8e..fa843731b3a 100644 --- a/support/crown/src/unrooted_must_root.rs +++ b/support/crown/src/unrooted_must_root.rs @@ -20,7 +20,7 @@ declare_tool_lint! { pub fn register(lint_store: &mut LintStore) { let symbols = Symbols::new(); - lint_store.register_lints(&[&UNROOTED_MUST_ROOT]); + lint_store.register_lints(&[UNROOTED_MUST_ROOT]); lint_store.register_late_pass(move |_| Box::new(UnrootedPass::new(symbols.clone()))); } @@ -210,6 +210,7 @@ impl<'tcx> LateLintPass<'tcx> for UnrootedPass { parent_item.hir_id().expect_owner(), &[sym.crown, sym.unrooted_must_root_lint, sym.must_root], ) { + #[allow(clippy::single_match)] match var.data { hir::VariantData::Tuple(fields, ..) => { for field in fields { diff --git a/support/filterlock/Cargo.lock b/support/filterlock/Cargo.lock deleted file mode 100644 index c286458744d..00000000000 --- a/support/filterlock/Cargo.lock +++ /dev/null @@ -1,147 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "equivalent" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" - -[[package]] -name = "filterlock" -version = "0.1.0" -dependencies = [ - "serde", - "toml", -] - -[[package]] -name = "hashbrown" -version = "0.14.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" - -[[package]] -name = "indexmap" -version = "2.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b0b929d511467233429c45a44ac1dcaa21ba0f5ba11e4879e6ed28ddb4f9df4" -dependencies = [ - "equivalent", - "hashbrown", -] - -[[package]] -name = "memchr" -version = "2.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" - -[[package]] -name = "proc-macro2" -version = "1.0.79" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "quote" -version = "1.0.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "serde" -version = "1.0.197" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" -dependencies = [ - "serde_derive", -] - -[[package]] -name = "serde_derive" -version = "1.0.197" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "serde_spanned" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb3622f419d1296904700073ea6cc23ad690adbd66f13ea683df73298736f0c1" -dependencies = [ - "serde", -] - -[[package]] -name = "syn" -version = "2.0.53" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7383cd0e49fff4b6b90ca5670bfd3e9d6a733b3f90c686605aa7eec8c4996032" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "toml" -version = "0.8.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9dd1545e8208b4a5af1aa9bbd0b4cf7e9ea08fabc5d0a5c67fcaafa17433aa3" -dependencies = [ - "indexmap", - "serde", - "serde_spanned", - "toml_datetime", - "toml_edit", -] - -[[package]] -name = "toml_datetime" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" -dependencies = [ - "serde", -] - -[[package]] -name = "toml_edit" -version = "0.22.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e40bb779c5187258fd7aad0eb68cb8706a0a81fa712fbea808ab43c4b8374c4" -dependencies = [ - "indexmap", - "serde", - "serde_spanned", - "toml_datetime", - "winnow", -] - -[[package]] -name = "unicode-ident" -version = "1.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" - -[[package]] -name = "winnow" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dffa400e67ed5a4dd237983829e66475f0a4a26938c4b04c21baede6262215b8" -dependencies = [ - "memchr", -] diff --git a/support/filterlock/Cargo.toml b/support/filterlock/Cargo.toml deleted file mode 100644 index 72fe6e9f985..00000000000 --- a/support/filterlock/Cargo.toml +++ /dev/null @@ -1,14 +0,0 @@ -# NOTE: The hash for the `vendorTarball` in etc/shell.nix should be -# regenerated when this file is changed. -[workspace] - -[package] -name = "filterlock" -authors = ["The Servo Project Developers"] -version = "0.1.0" -edition = "2021" -license = "MPL-2.0" - -[dependencies] -serde = { version = "1.0.194", features = ["derive"] } -toml = { version = "0.8.9", features = ["preserve_order"] } diff --git a/support/filterlock/src/main.rs b/support/filterlock/src/main.rs deleted file mode 100644 index e012dcde037..00000000000 --- a/support/filterlock/src/main.rs +++ /dev/null @@ -1,83 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ - -// NOTE: The hash for the `vendorTarball` in etc/shell.nix should be -// regenerated when this file is changed. - -//! Filter the given lockfile to only the given package and its dependencies. -//! -//! Usage: `filterlock ` -//! -//! This helper is used only by the Nix shell environment (etc/shell.nix). - -use std::{fs::File, env::{args_os, args}, io::Read, collections::BTreeSet}; - -use serde::{Deserialize, Serialize}; -use toml::{map::Map, Value}; - -#[derive(Deserialize, Serialize)] -struct LockFile { - package: Vec, - #[serde(flatten)] - other: Map, -} - -#[derive(Deserialize, Serialize)] -struct Package { - name: String, - version: String, - dependencies: Option>, - #[serde(flatten)] - other: Map, -} - -fn main() { - let usage = "Usage: filterlock "; - let path = args_os().nth(1).expect(usage); - let package = args().nth(2).expect(usage); - - let mut file = File::open(path).expect("Failed to open lockfile"); - let mut toml = String::new(); - file.read_to_string(&mut toml).expect("Failed to read lockfile"); - let toml: LockFile = toml::from_str(&toml).expect("Failed to parse lockfile"); - - // Find the closure of the given package and its dependencies. - let mut keep = BTreeSet::new(); - let mut queue = vec![ - toml.package.iter() - .find(|p| p.matches(&package)) - .expect("Failed to find package"), - ]; - while !queue.is_empty() { - let package = queue.pop().expect("Guaranteed by while"); - keep.insert((package.name.clone(), package.version.clone())); - if let Some(dependencies) = package.dependencies.as_ref() { - for dependency in dependencies { - let package = toml.package.iter() - .find(|p| p.matches(&dependency)) - .expect("Failed to find package"); - queue.push(package); - } - } - } - - // Remove packages that are not in the closure. - let mut toml = toml; - let filtered_packages = toml.package.drain(..) - .filter(|p| keep.contains(&(p.name.clone(), p.version.clone()))) - .collect(); - let toml = LockFile { package: filtered_packages, ..toml }; - - println!("{}", toml::to_string(&toml).expect("Failed to serialise lockfile")); -} - -impl Package { - fn matches(&self, spec: &str) -> bool { - if let Some((name, version)) = spec.split_once(" ") { - self.name == name && self.version == version - } else { - self.name == spec - } - } -}