From e5b27f553debff8696899ecd06c5ad880b4ea6df Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Tue, 24 Nov 2026 12:17:13 -0800 Subject: [PATCH] Remove rust-python-parser It is dead code. --- deps/rust/Cargo.lock | 175 +---- deps/rust/Cargo.toml | 2 - deps/rust/cargo-bazel-lock.json | 814 +--------------------- docs/reference/rust-review-checklist.md | 3 +- src/rust/AGENTS.md | 3 +- src/rust/python-parser/BUILD | 20 - src/rust/python-parser/import_parsing.c++ | 180 ----- src/rust/python-parser/lib.rs | 43 -- 8 files changed, 19 insertions(+), 1221 deletions(-) delete mode 100644 src/rust/python-parser/BUILD delete mode 100644 src/rust/python-parser/import_parsing.c++ delete mode 100644 src/rust/python-parser/lib.rs diff --git a/deps/rust/Cargo.lock b/deps/rust/Cargo.lock index d0cfe8a5f9c..a4c69e111a9 100644 --- a/deps/rust/Cargo.lock +++ b/deps/rust/Cargo.lock @@ -171,17 +171,6 @@ dependencies = [ "hybrid-array", ] -[[package]] -name = "bstr" -version = "1.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a680398c10c7bc0488067c4612226ea905a85f607134b69f3068d505d58c4214" -dependencies = [ - "memchr", - "regex-automata", - "serde_core", -] - [[package]] name = "bumpalo" version = "3.20.4" @@ -350,20 +339,6 @@ dependencies = [ "static_assertions", ] -[[package]] -name = "compact_str" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9dfdd1c2274d9aa354115b09dc9a901d6c5576818cdf70d14cae2bdb47df00ab" -dependencies = [ - "castaway", - "cfg-if", - "itoa", - "rustversion", - "ryu", - "static_assertions", -] - [[package]] name = "const-oid" version = "0.10.3" @@ -626,8 +601,6 @@ dependencies = [ "rand 0.9.5", "regex", "ring", - "ruff_python_ast", - "ruff_python_parser", "rust_icu_sys", "rustls", "rustls-platform-verifier", @@ -897,15 +870,6 @@ dependencies = [ "version_check", ] -[[package]] -name = "getopts" -version = "0.2.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfe4fbac503b8d1f88e6676011885f34b7174f46e59956bba534ba83abded4df" -dependencies = [ - "unicode-width", -] - [[package]] name = "getrandom" version = "0.2.17" @@ -1287,15 +1251,6 @@ dependencies = [ "syn 2.0.119", ] -[[package]] -name = "itertools" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285" -dependencies = [ - "either", -] - [[package]] name = "itertools" version = "0.15.0" @@ -1685,16 +1640,6 @@ dependencies = [ "serde", ] -[[package]] -name = "phf_codegen" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aef8048c789fa5e851558d709946d6d79a8ff88c0440c587967f8e94bfb1216a" -dependencies = [ - "phf_generator 0.11.3", - "phf_shared 0.11.3", -] - [[package]] name = "phf_generator" version = "0.11.3" @@ -1823,7 +1768,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1ad9c5423459fa2f729b8d9235fab810aa29628b171467744fc86d21460ad70d" dependencies = [ "anyhow", - "itertools 0.15.0", + "itertools", "proc-macro2", "quote", "syn 2.0.119", @@ -1862,8 +1807,6 @@ version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e058c7de0b26af77780c769414d6257830bb240f3c38477dbc2c16e5f54d6d4c" dependencies = [ - "libc", - "rand_chacha 0.3.1", "rand_core 0.6.4", ] @@ -1873,20 +1816,10 @@ version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9ef1d0d795eb7d84685bca4f72f3649f064e6641543d3a8c415898726a57b41" dependencies = [ - "rand_chacha 0.9.0", + "rand_chacha", "rand_core 0.9.5", ] -[[package]] -name = "rand_chacha" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" -dependencies = [ - "ppv-lite86", - "rand_core 0.6.4", -] - [[package]] name = "rand_chacha" version = "0.9.0" @@ -1902,9 +1835,6 @@ name = "rand_core" version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" -dependencies = [ - "getrandom 0.2.17", -] [[package]] name = "rand_core" @@ -1968,68 +1898,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "ruff_python_ast" -version = "0.0.0" -source = "git+https://github.com/astral-sh/ruff?tag=0.12.1#32c54189cb45a9d0409a1140265ce6d5fcec214d" -dependencies = [ - "aho-corasick", - "bitflags", - "compact_str 0.9.1", - "is-macro", - "itertools 0.14.0", - "memchr", - "ruff_python_trivia", - "ruff_source_file", - "ruff_text_size", - "rustc-hash", - "thiserror", -] - -[[package]] -name = "ruff_python_parser" -version = "0.0.0" -source = "git+https://github.com/astral-sh/ruff?tag=0.12.1#32c54189cb45a9d0409a1140265ce6d5fcec214d" -dependencies = [ - "bitflags", - "bstr", - "compact_str 0.9.1", - "memchr", - "ruff_python_ast", - "ruff_python_trivia", - "ruff_text_size", - "rustc-hash", - "static_assertions", - "unicode-ident", - "unicode-normalization", - "unicode_names2", -] - -[[package]] -name = "ruff_python_trivia" -version = "0.0.0" -source = "git+https://github.com/astral-sh/ruff?tag=0.12.1#32c54189cb45a9d0409a1140265ce6d5fcec214d" -dependencies = [ - "itertools 0.14.0", - "ruff_source_file", - "ruff_text_size", - "unicode-ident", -] - -[[package]] -name = "ruff_source_file" -version = "0.0.0" -source = "git+https://github.com/astral-sh/ruff?tag=0.12.1#32c54189cb45a9d0409a1140265ce6d5fcec214d" -dependencies = [ - "memchr", - "ruff_text_size", -] - -[[package]] -name = "ruff_text_size" -version = "0.0.0" -source = "git+https://github.com/astral-sh/ruff?tag=0.12.1#32c54189cb45a9d0409a1140265ce6d5fcec214d" - [[package]] name = "rust_icu_release" version = "5.8.0" @@ -2523,7 +2391,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a43ff5dc87e695cfa251e346df018b62d47a7db87e487c6254df4e28509ede7" dependencies = [ "ascii", - "compact_str 0.7.1", + "compact_str", "dragonbox_ecma", "memchr", "num-bigint", @@ -2876,12 +2744,6 @@ dependencies = [ "zerovec", ] -[[package]] -name = "tinyvec" -version = "1.13.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd3ca314f692efd6c868f8408f53fe444634a845f96c028b97d35f6a1f79f0ee" - [[package]] name = "tokio" version = "1.54.1" @@ -2978,43 +2840,12 @@ version = "1.0.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563" -[[package]] -name = "unicode-normalization" -version = "0.1.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75cd3fb03d5288b3ba9a1ee103ac7e9cbb59f0b03d64f8ddfcc04dd42758a85d" -dependencies = [ - "tinyvec", -] - [[package]] name = "unicode-width" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca718471876992059f251e33aafc334346ada08042b7661dd1fe313a9bced557" -[[package]] -name = "unicode_names2" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1673eca9782c84de5f81b82e4109dcfb3611c8ba0d52930ec4a9478f547b2dd" -dependencies = [ - "phf 0.11.3", - "unicode_names2_generator", -] - -[[package]] -name = "unicode_names2_generator" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b91e5b84611016120197efd7dc93ef76774f4e084cd73c9fb3ea4a86c570c56e" -dependencies = [ - "getopts", - "log", - "phf_codegen", - "rand 0.8.8", -] - [[package]] name = "untrusted" version = "0.9.0" diff --git a/deps/rust/Cargo.toml b/deps/rust/Cargo.toml index 1da6b60f178..46eeab6003a 100644 --- a/deps/rust/Cargo.toml +++ b/deps/rust/Cargo.toml @@ -79,8 +79,6 @@ prost = "0.14" # workspace (downstream repos include this one alongside their own) must request the same # major version, or crate_universe stops emitting the bare `rand` alias. rand = { version = "0.9", default-features = false, features = ["os_rng", "thread_rng"] } -ruff_python_ast = { git = "https://github.com/astral-sh/ruff", tag = "0.12.1" } -ruff_python_parser = { git = "https://github.com/astral-sh/ruff", tag = "0.12.1" } # cluster: SigV4's SHA-256 and HMAC, and its peer MACs. ring = { version = "0.17", default-features = false } # Use rust_icu's checked-in bindings for the Chromium ICU version linked by workerd. ICU itself is diff --git a/deps/rust/cargo-bazel-lock.json b/deps/rust/cargo-bazel-lock.json index 2430008f72a..f47cc4f5e74 100644 --- a/deps/rust/cargo-bazel-lock.json +++ b/deps/rust/cargo-bazel-lock.json @@ -2,7 +2,7 @@ "binary_crates": [ "capnpc 0.27.0" ], - "checksum": "fcfa1a9642445927d27ba7795d203ef1bf43abcc1924b1fb9e8f9728b40327bb", + "checksum": "fb001bc3f2609661f1a6a340a4c5c64cd2c15ad3e0cf738fe9794030279c5430", "conditions": { "aarch64-apple-darwin": [ "aarch64-apple-darwin" @@ -308,7 +308,6 @@ "aho-corasick 1.1.5": { "common_attrs": { "crate_features": [ - "default", "perf-literal", "std" ], @@ -965,51 +964,6 @@ ], "version": "0.12.1" }, - "bstr 1.14.0": { - "common_attrs": { - "crate_features": [ - "alloc", - "default", - "std", - "unicode" - ], - "deps": [ - { - "id": "memchr 2.8.3", - "target": "memchr" - }, - { - "id": "regex-automata 0.4.19", - "target": "regex_automata" - } - ], - "edition": "2021" - }, - "library_target_name": "bstr", - "license": "MIT OR Apache-2.0", - "license_file": "LICENSE-APACHE", - "license_ids": [ - "Apache-2.0", - "MIT" - ], - "name": "bstr", - "package_url": "https://github.com/BurntSushi/bstr", - "repository": { - "Http": { - "sha256": "a680398c10c7bc0488067c4612226ea905a85f607134b69f3068d505d58c4214", - "url": "https://static.crates.io/crates/bstr/1.14.0/download" - } - }, - "targets": [ - { - "Library": { - "crate_name": "bstr", - "crate_root": "src/lib.rs" - } - } - ], - "version": "1.14.0" - }, "bumpalo 3.20.4": { "common_attrs": { "crate_features": [ @@ -1742,66 +1696,6 @@ ], "version": "0.7.1" }, - "compact_str 0.9.1": { - "common_attrs": { - "crate_features": [ - "default", - "std" - ], - "deps": [ - { - "id": "castaway 0.2.4", - "target": "castaway" - }, - { - "id": "cfg-if 1.0.5", - "target": "cfg_if" - }, - { - "id": "itoa 1.0.19", - "target": "itoa" - }, - { - "id": "ryu 1.0.23", - "target": "ryu" - }, - { - "id": "static_assertions 1.1.0", - "target": "static_assertions" - } - ], - "edition": "2021", - "proc_macro_deps": [ - { - "id": "rustversion 1.0.23", - "target": "rustversion" - } - ] - }, - "library_target_name": "compact_str", - "license": "MIT", - "license_file": "LICENSE", - "license_ids": [ - "MIT" - ], - "name": "compact_str", - "package_url": "https://github.com/ParkMyCar/compact_str", - "repository": { - "Http": { - "sha256": "9dfdd1c2274d9aa354115b09dc9a901d6c5576818cdf70d14cae2bdb47df00ab", - "url": "https://static.crates.io/crates/compact_str/0.9.1/download" - } - }, - "targets": [ - { - "Library": { - "crate_name": "compact_str", - "crate_root": "src/lib.rs" - } - } - ], - "version": "0.9.1" - }, "const-oid 0.10.3": { "common_attrs": { "crate_features": [ @@ -2947,14 +2841,6 @@ "id": "ring 0.17.14", "target": "ring" }, - { - "id": "ruff_python_ast 0.0.0", - "target": "ruff_python_ast" - }, - { - "id": "ruff_python_parser 0.0.0", - "target": "ruff_python_parser" - }, { "id": "rust_icu_sys 5.8.0", "target": "rust_icu_sys" @@ -4254,50 +4140,8 @@ ], "version": "0.14.7" }, - "getopts 0.2.24": { - "common_attrs": { - "crate_features": [ - "default", - "unicode" - ], - "deps": [ - { - "id": "unicode-width 0.2.3", - "target": "unicode_width" - } - ], - "edition": "2021" - }, - "library_target_name": "getopts", - "license": "MIT OR Apache-2.0", - "license_file": "LICENSE-APACHE", - "license_ids": [ - "Apache-2.0", - "MIT" - ], - "name": "getopts", - "package_url": "https://github.com/rust-lang/getopts", - "repository": { - "Http": { - "sha256": "cfe4fbac503b8d1f88e6676011885f34b7174f46e59956bba534ba83abded4df", - "url": "https://static.crates.io/crates/getopts/0.2.24/download" - } - }, - "targets": [ - { - "Library": { - "crate_name": "getopts", - "crate_root": "src/lib.rs" - } - } - ], - "version": "0.2.24" - }, "getrandom 0.2.17": { "common_attrs": { - "crate_features": [ - "std" - ], "deps": { "common": [ { @@ -6118,46 +5962,6 @@ ], "version": "0.3.8" }, - "itertools 0.14.0": { - "common_attrs": { - "crate_features": [ - "default", - "use_alloc", - "use_std" - ], - "deps": [ - { - "id": "either 1.19.0", - "target": "either" - } - ], - "edition": "2018" - }, - "library_target_name": "itertools", - "license": "MIT OR Apache-2.0", - "license_file": "LICENSE-APACHE", - "license_ids": [ - "Apache-2.0", - "MIT" - ], - "name": "itertools", - "package_url": "https://github.com/rust-itertools/itertools", - "repository": { - "Http": { - "sha256": "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285", - "url": "https://static.crates.io/crates/itertools/0.14.0/download" - } - }, - "targets": [ - { - "Library": { - "crate_name": "itertools", - "crate_root": "src/lib.rs" - } - } - ], - "version": "0.14.0" - }, "itertools 0.15.0": { "common_attrs": { "crate_features": [ @@ -8043,44 +7847,6 @@ ], "version": "0.14.0" }, - "phf_codegen 0.11.3": { - "common_attrs": { - "deps": [ - { - "id": "phf_generator 0.11.3", - "target": "phf_generator" - }, - { - "id": "phf_shared 0.11.3", - "target": "phf_shared" - } - ], - "edition": "2021" - }, - "library_target_name": "phf_codegen", - "license": "MIT", - "license_file": "LICENSE", - "license_ids": [ - "MIT" - ], - "name": "phf_codegen", - "package_url": "https://github.com/rust-phf/rust-phf", - "repository": { - "Http": { - "sha256": "aef8048c789fa5e851558d709946d6d79a8ff88c0440c587967f8e94bfb1216a", - "url": "https://static.crates.io/crates/phf_codegen/0.11.3/download" - } - }, - "targets": [ - { - "Library": { - "crate_name": "phf_codegen", - "crate_root": "src/lib.rs" - } - } - ], - "version": "0.11.3" - }, "phf_generator 0.11.3": { "common_attrs": { "deps": [ @@ -8260,7 +8026,6 @@ "phf_shared 0.11.3": { "common_attrs": { "crate_features": [ - "default", "std" ], "deps": [ @@ -8795,53 +8560,14 @@ "rand 0.8.8": { "common_attrs": { "crate_features": [ - "alloc", - "default", - "getrandom", - "libc", - "rand_chacha", - "small_rng", - "std", - "std_rng" + "small_rng" ], - "deps": { - "common": [ - { - "id": "rand_chacha 0.3.1", - "target": "rand_chacha" - }, - { - "id": "rand_core 0.6.4", - "target": "rand_core" - } - ], - "selects": { - "aarch64-apple-darwin": [ - { - "id": "libc 0.2.191", - "target": "libc" - } - ], - "aarch64-unknown-linux-gnu": [ - { - "id": "libc 0.2.191", - "target": "libc" - } - ], - "x86_64-apple-darwin": [ - { - "id": "libc 0.2.191", - "target": "libc" - } - ], - "x86_64-unknown-linux-gnu": [ - { - "id": "libc 0.2.191", - "target": "libc" - } - ] + "deps": [ + { + "id": "rand_core 0.6.4", + "target": "rand_core" } - }, + ], "edition": "2018" }, "library_target_name": "rand", @@ -8915,7 +8641,7 @@ ], "version": "0.9.5" }, - "rand_chacha 0.3.1": { + "rand_chacha 0.9.0": { "common_attrs": { "crate_features": [ "std" @@ -8926,11 +8652,11 @@ "target": "ppv_lite86" }, { - "id": "rand_core 0.6.4", + "id": "rand_core 0.9.5", "target": "rand_core" } ], - "edition": "2018" + "edition": "2021" }, "library_target_name": "rand_chacha", "license": "MIT OR Apache-2.0", @@ -8943,8 +8669,8 @@ "package_url": "https://github.com/rust-random/rand", "repository": { "Http": { - "sha256": "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88", - "url": "https://static.crates.io/crates/rand_chacha/0.3.1/download" + "sha256": "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb", + "url": "https://static.crates.io/crates/rand_chacha/0.9.0/download" } }, "targets": [ @@ -8955,63 +8681,10 @@ } } ], - "version": "0.3.1" + "version": "0.9.0" }, - "rand_chacha 0.9.0": { + "rand_core 0.6.4": { "common_attrs": { - "crate_features": [ - "std" - ], - "deps": [ - { - "id": "ppv-lite86 0.2.21", - "target": "ppv_lite86" - }, - { - "id": "rand_core 0.9.5", - "target": "rand_core" - } - ], - "edition": "2021" - }, - "library_target_name": "rand_chacha", - "license": "MIT OR Apache-2.0", - "license_file": "LICENSE-APACHE", - "license_ids": [ - "Apache-2.0", - "MIT" - ], - "name": "rand_chacha", - "package_url": "https://github.com/rust-random/rand", - "repository": { - "Http": { - "sha256": "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb", - "url": "https://static.crates.io/crates/rand_chacha/0.9.0/download" - } - }, - "targets": [ - { - "Library": { - "crate_name": "rand_chacha", - "crate_root": "src/lib.rs" - } - } - ], - "version": "0.9.0" - }, - "rand_core 0.6.4": { - "common_attrs": { - "crate_features": [ - "alloc", - "getrandom", - "std" - ], - "deps": [ - { - "id": "getrandom 0.2.17", - "target": "getrandom" - } - ], "edition": "2018" }, "library_target_name": "rand_core", @@ -9149,7 +8822,6 @@ "crate_features": [ "alloc", "dfa-onepass", - "dfa-search", "hybrid", "meta", "nfa-backtrack", @@ -9379,282 +9051,6 @@ ], "version": "0.17.14" }, - "ruff_python_ast 0.0.0": { - "common_attrs": { - "deps": [ - { - "id": "aho-corasick 1.1.5", - "target": "aho_corasick" - }, - { - "id": "bitflags 2.13.2", - "target": "bitflags" - }, - { - "id": "compact_str 0.9.1", - "target": "compact_str" - }, - { - "id": "itertools 0.14.0", - "target": "itertools" - }, - { - "id": "memchr 2.8.3", - "target": "memchr" - }, - { - "id": "ruff_python_trivia 0.0.0", - "target": "ruff_python_trivia" - }, - { - "id": "ruff_source_file 0.0.0", - "target": "ruff_source_file" - }, - { - "id": "ruff_text_size 0.0.0", - "target": "ruff_text_size" - }, - { - "id": "rustc-hash 2.1.3", - "target": "rustc_hash" - }, - { - "id": "thiserror 2.0.21", - "target": "thiserror" - } - ], - "edition": "2024", - "proc_macro_deps": [ - { - "id": "is-macro 0.3.8", - "target": "is_macro" - } - ] - }, - "library_target_name": "ruff_python_ast", - "license": "MIT", - "license_ids": [ - "MIT" - ], - "name": "ruff_python_ast", - "package_url": "https://github.com/astral-sh/ruff", - "repository": { - "Git": { - "commitish": { - "Rev": "32c54189cb45a9d0409a1140265ce6d5fcec214d" - }, - "remote": "https://github.com/astral-sh/ruff", - "strip_prefix": "crates/ruff_python_ast" - } - }, - "targets": [ - { - "Library": { - "crate_name": "ruff_python_ast", - "crate_root": "src/lib.rs" - } - } - ], - "version": "0.0.0" - }, - "ruff_python_parser 0.0.0": { - "common_attrs": { - "deps": [ - { - "id": "bitflags 2.13.2", - "target": "bitflags" - }, - { - "id": "bstr 1.14.0", - "target": "bstr" - }, - { - "id": "compact_str 0.9.1", - "target": "compact_str" - }, - { - "id": "memchr 2.8.3", - "target": "memchr" - }, - { - "id": "ruff_python_ast 0.0.0", - "target": "ruff_python_ast" - }, - { - "id": "ruff_python_trivia 0.0.0", - "target": "ruff_python_trivia" - }, - { - "id": "ruff_text_size 0.0.0", - "target": "ruff_text_size" - }, - { - "id": "rustc-hash 2.1.3", - "target": "rustc_hash" - }, - { - "id": "static_assertions 1.1.0", - "target": "static_assertions" - }, - { - "id": "unicode-ident 1.0.27", - "target": "unicode_ident" - }, - { - "id": "unicode-normalization 0.1.26", - "target": "unicode_normalization" - }, - { - "id": "unicode_names2 1.3.0", - "target": "unicode_names2" - } - ], - "edition": "2024" - }, - "library_target_name": "ruff_python_parser", - "license": "MIT", - "license_ids": [ - "MIT" - ], - "name": "ruff_python_parser", - "package_url": "https://github.com/astral-sh/ruff", - "repository": { - "Git": { - "commitish": { - "Rev": "32c54189cb45a9d0409a1140265ce6d5fcec214d" - }, - "remote": "https://github.com/astral-sh/ruff", - "strip_prefix": "crates/ruff_python_parser" - } - }, - "targets": [ - { - "Library": { - "crate_name": "ruff_python_parser", - "crate_root": "src/lib.rs" - } - } - ], - "version": "0.0.0" - }, - "ruff_python_trivia 0.0.0": { - "common_attrs": { - "deps": [ - { - "id": "itertools 0.14.0", - "target": "itertools" - }, - { - "id": "ruff_source_file 0.0.0", - "target": "ruff_source_file" - }, - { - "id": "ruff_text_size 0.0.0", - "target": "ruff_text_size" - }, - { - "id": "unicode-ident 1.0.27", - "target": "unicode_ident" - } - ], - "edition": "2024" - }, - "library_target_name": "ruff_python_trivia", - "license": "MIT", - "license_ids": [ - "MIT" - ], - "name": "ruff_python_trivia", - "package_url": "https://github.com/astral-sh/ruff", - "repository": { - "Git": { - "commitish": { - "Rev": "32c54189cb45a9d0409a1140265ce6d5fcec214d" - }, - "remote": "https://github.com/astral-sh/ruff", - "strip_prefix": "crates/ruff_python_trivia" - } - }, - "targets": [ - { - "Library": { - "crate_name": "ruff_python_trivia", - "crate_root": "src/lib.rs" - } - } - ], - "version": "0.0.0" - }, - "ruff_source_file 0.0.0": { - "common_attrs": { - "deps": [ - { - "id": "memchr 2.8.3", - "target": "memchr" - }, - { - "id": "ruff_text_size 0.0.0", - "target": "ruff_text_size" - } - ], - "edition": "2024" - }, - "library_target_name": "ruff_source_file", - "license": "MIT", - "license_ids": [ - "MIT" - ], - "name": "ruff_source_file", - "package_url": "https://github.com/astral-sh/ruff", - "repository": { - "Git": { - "commitish": { - "Rev": "32c54189cb45a9d0409a1140265ce6d5fcec214d" - }, - "remote": "https://github.com/astral-sh/ruff", - "strip_prefix": "crates/ruff_source_file" - } - }, - "targets": [ - { - "Library": { - "crate_name": "ruff_source_file", - "crate_root": "src/lib.rs" - } - } - ], - "version": "0.0.0" - }, - "ruff_text_size 0.0.0": { - "common_attrs": { - "edition": "2024" - }, - "library_target_name": "ruff_text_size", - "license": "MIT", - "license_ids": [ - "MIT" - ], - "name": "ruff_text_size", - "package_url": "https://github.com/astral-sh/ruff", - "repository": { - "Git": { - "commitish": { - "Rev": "32c54189cb45a9d0409a1140265ce6d5fcec214d" - }, - "remote": "https://github.com/astral-sh/ruff", - "strip_prefix": "crates/ruff_text_size" - } - }, - "targets": [ - { - "Library": { - "crate_name": "ruff_text_size", - "crate_root": "src/lib.rs" - } - } - ], - "version": "0.0.0" - }, "rust_icu_release 5.8.0": { "common_attrs": { "crate_features": [ @@ -13379,40 +12775,6 @@ ], "version": "0.8.5" }, - "tinyvec 1.13.3": { - "common_attrs": { - "crate_features": [ - "alloc", - "default" - ], - "edition": "2018" - }, - "library_target_name": "tinyvec", - "license": "Zlib OR Apache-2.0 OR MIT", - "license_file": "LICENSE-APACHE.md", - "license_ids": [ - "Apache-2.0", - "MIT", - "Zlib" - ], - "name": "tinyvec", - "package_url": "https://github.com/Lokathor/tinyvec", - "repository": { - "Http": { - "sha256": "fd3ca314f692efd6c868f8408f53fe444634a845f96c028b97d35f6a1f79f0ee", - "url": "https://static.crates.io/crates/tinyvec/1.13.3/download" - } - }, - "targets": [ - { - "Library": { - "crate_name": "tinyvec", - "crate_root": "src/lib.rs" - } - } - ], - "version": "1.13.3" - }, "tokio 1.54.1": { "common_attrs": { "crate_features": { @@ -13897,46 +13259,6 @@ ], "version": "1.0.27" }, - "unicode-normalization 0.1.26": { - "common_attrs": { - "crate_features": [ - "default", - "std" - ], - "deps": [ - { - "id": "tinyvec 1.13.3", - "target": "tinyvec" - } - ], - "edition": "2018" - }, - "library_target_name": "unicode_normalization", - "license": "(MIT OR Apache-2.0) AND Unicode-3.0", - "license_file": "LICENSE-APACHE", - "license_ids": [ - "Apache-2.0", - "MIT", - "Unicode-3.0" - ], - "name": "unicode-normalization", - "package_url": "https://github.com/unicode-rs/unicode-normalization", - "repository": { - "Http": { - "sha256": "75cd3fb03d5288b3ba9a1ee103ac7e9cbb59f0b03d64f8ddfcc04dd42758a85d", - "url": "https://static.crates.io/crates/unicode-normalization/0.1.26/download" - } - }, - "targets": [ - { - "Library": { - "crate_name": "unicode_normalization", - "crate_root": "src/lib.rs" - } - } - ], - "version": "0.1.26" - }, "unicode-width 0.2.3": { "common_attrs": { "crate_features": [ @@ -13970,112 +13292,6 @@ ], "version": "0.2.3" }, - "unicode_names2 1.3.0": { - "build_script_attrs": { - "deps": [ - { - "id": "unicode_names2_generator 1.3.0", - "target": "unicode_names2_generator" - } - ] - }, - "common_attrs": { - "crate_features": [ - "default" - ], - "deps": [ - { - "id": "phf 0.11.3", - "target": "phf" - } - ], - "edition": "2018", - "extra_deps": [ - ":build_script_build" - ] - }, - "library_target_name": "unicode_names2", - "license": "(MIT OR Apache-2.0) AND Unicode-DFS-2016", - "license_file": "LICENSE-APACHE", - "license_ids": [ - "Apache-2.0", - "MIT", - "Unicode-DFS-2016" - ], - "name": "unicode_names2", - "package_url": "https://github.com/progval/unicode_names2", - "repository": { - "Http": { - "sha256": "d1673eca9782c84de5f81b82e4109dcfb3611c8ba0d52930ec4a9478f547b2dd", - "url": "https://static.crates.io/crates/unicode_names2/1.3.0/download" - } - }, - "targets": [ - { - "Library": { - "crate_name": "unicode_names2", - "crate_root": "src/lib.rs" - } - }, - { - "BuildScript": { - "crate_name": "build_script_build", - "crate_root": "build.rs" - } - } - ], - "version": "1.3.0" - }, - "unicode_names2_generator 1.3.0": { - "common_attrs": { - "crate_features": [ - "default" - ], - "deps": [ - { - "id": "getopts 0.2.24", - "target": "getopts" - }, - { - "id": "log 0.4.35", - "target": "log" - }, - { - "id": "phf_codegen 0.11.3", - "target": "phf_codegen" - }, - { - "id": "rand 0.8.8", - "target": "rand" - } - ], - "edition": "2018" - }, - "library_target_name": "unicode_names2_generator", - "license": "MIT OR Apache-2.0", - "license_file": "LICENSE-APACHE", - "license_ids": [ - "Apache-2.0", - "MIT" - ], - "name": "unicode_names2_generator", - "package_url": "https://github.com/progval/unicode_names2", - "repository": { - "Http": { - "sha256": "b91e5b84611016120197efd7dc93ef76774f4e084cd73c9fb3ea4a86c570c56e", - "url": "https://static.crates.io/crates/unicode_names2_generator/1.3.0/download" - } - }, - "targets": [ - { - "Library": { - "crate_name": "unicode_names2_generator", - "crate_root": "src/lib.rs" - } - } - ], - "version": "1.3.0" - }, "untrusted 0.9.0": { "common_attrs": { "edition": "2018" @@ -16019,8 +15235,6 @@ "rand 0.9.5", "regex 1.13.2", "ring 0.17.14", - "ruff_python_ast 0.0.0", - "ruff_python_parser 0.0.0", "rust_icu_sys 5.8.0", "rustls 0.23.46", "rustls-platform-verifier 0.7.1", diff --git a/docs/reference/rust-review-checklist.md b/docs/reference/rust-review-checklist.md index 0149b1af521..4f35adb7b64 100644 --- a/docs/reference/rust-review-checklist.md +++ b/docs/reference/rust-review-checklist.md @@ -15,8 +15,7 @@ All Rust/C++ interop uses the `cxx` crate. Each crate with a bridge declares `Box`/`UniquePtr`. - **Always** verify that lifetimes are respected — an opaque C++ type behind `&T` must outlive the Rust reference. -- **Always** verify that bridges must use the `workerd::rust::` naming convention. The - only exception is `python-parser` which uses `edgeworker::rust::python_parser`. +- **Always** verify that bridges must use the `workerd::rust::` naming convention. - **Always** verify companion files. Every CXX bridge should have hand-written `ffi.c++` and `ffi.h` implementing the C++ side. Generated headers (`.rs.h`) are produced by the build system. diff --git a/src/rust/AGENTS.md b/src/rust/AGENTS.md index bcd2c5a413f..85008328a63 100644 --- a/src/rust/AGENTS.md +++ b/src/rust/AGENTS.md @@ -27,13 +27,12 @@ _Snapshot — the set drifts as crates come and go; `bazel query //src/rust/...` | `cxx-integration/` | One bridge function, `trigger_panic`: the hook C++ tests use to exercise the panic-to-`kj::Exception` conversion at the bridge | | `cxx-integration-test/` | Non-production crate exercising Rust/C++ integration: callbacks, shared structs, `Result` error mapping | | `transpiler/` | TS type stripping via SWC (`ts_strip()`, `StripOnly` mode) | -| `python-parser/` | Python import extraction via `ruff_python_parser`; **namespace: `edgeworker::rust::`** | | `gen-compile-cache/` | Binary crate — V8 bytecode cache generator; calls C++ `compile()` via CXX | ## CONVENTIONS - **CXX bridge**: `#[cxx::bridge(namespace = "workerd::rust::")]` with companion `ffi.c++`/`ffi.h` files -- **Namespace**: `workerd::rust::*` for crates in this directory, except `python-parser` → `edgeworker::rust::python_parser`; a crate living beside C++ uses that C++'s namespace (e.g. `workerd::server::cli`) +- **Namespace**: `workerd::rust::*` for crates in this directory; a crate living beside C++ uses that C++'s namespace (e.g. `workerd::server::cli`) - **Errors**: `thiserror` for library crates; `jsg::Error` with `ExceptionType` for JSG-facing crates - **JSG nullish values**: `Option` is `T | undefined`; `Nullable` is `T | null` (coerces `undefined` to `Null`, but method arguments remain required). Prefer `NullOrUndefined` to `Option>` for three distinct `Some(T)`, `Null`, and `Undefined` states; omitted arguments become `Undefined`. `LenientOption` is C++ `LenientOptional`: `undefined` or a shallow type mismatch is `None`, and `null` goes through `T`. See [Rust JSG nullish values](jsg/README.md#nullablet-and-nullorundefinedt). - **JSG resources**: `#[jsg_resource]` on struct + impl block; `#[jsg_method]` auto-converts `snake_case` → `camelCase`; methods with `&self` become instance methods, methods without a receiver become static methods, and any other receiver is a compile error (JavaScript can re-enter a resource, so state that methods change goes in `Cell`/`RefCell` fields, or in `jsg::Cell`/`jsg::RefCell` fields when it holds a `jsg::Rc` or a `TracedGlobal`, whose `take`/`replace`/`borrow_mut` take the lock and make the contents strong; never hold a `RefCell` borrow across a call that can run JavaScript); a method or accessor can take `this: jsg::Rc` as its first parameter instead of `&self` to get a `jsg::Rc` of its resource (like `JSG_THIS`) to hand to a callback, and reads the resource with `this.get(lock)`; don't share the resource's state with a callback through an `std::rc::Rc` (see `jsg/README.md` §Reaching the resource from a callback); a `#[jsg_method]` is registered with the type's `v8::Signature`, so its `&self` callback resolves the receiver without the `WORKERD_RUST_WRAPPABLE_TAG` marker check (`jsg::v8::resolve_method_receiver`); callbacks without a signature (accessors, inspect properties, wildcard interceptors, `#[jsg_callable]` call handlers) use `resolve_receiver`, which reads the marker before unwrapping so that it accepts any value; either returns `None` for a value that is not a wrapper of the type, so a method callback registered without the signature throws `Illegal invocation` rather than aborting; an eligible `#[jsg_method]` also gets a V8 Fast API callback (types in `jsg/fast_api.rs`) and must not call into V8; a `#[jsg_constructor]` returns `Self` or `Result` (an `Err` is thrown) and throws `TypeError` when called without `new`; `#[jsg_static_constant]` on `const` items exposes read-only numeric constants on both constructor and prototype (name kept as-is, no camelCase); `#[jsg_resource(nested_types(Foo, Name = Bar))]` on the impl block puts other resources' constructors on the prototype (`JSG_NESTED_TYPE`); `#[jsg_dispose]` / `#[jsg_async_dispose]` install a `&self`/`this` method as `Symbol.dispose` / `Symbol.asyncDispose` (`JSG_DISPOSE` / `JSG_ASYNC_DISPOSE`), combinable with `#[jsg_method]` or `#[jsg_callable]` on the same function (but not with `#[jsg_property]`, `#[jsg_inspect_property]` or `#[jsg_wildcard_property]`); an async disposer should return a promise (not checked); at most one disposer of each kind per type (see `jsg/README.md` §Explicit resource management); resources integrate with GC via `Traced` + `GarbageCollected`: every named field is traced via `Traced::trace(&self.field, visitor)` and all non-traceable types use no-op `Traced` impls; `Traced::trace` has no default, so a struct or enum with nothing to trace uses `#[jsg_traced]`, which checks that each field implements `jsg::HoldsNoGcReferences`, or, when its fields can't (a type from outside JSG), `jsg::jsg_traced_unchecked!` (also `jsg_traced_unchecked!( Foo)` for a generic type that holds a `T`, which requires `T: jsg::HoldsNoGcReferences`); both also implement `jsg::HoldsNoGcReferences` diff --git a/src/rust/python-parser/BUILD b/src/rust/python-parser/BUILD deleted file mode 100644 index 00f0d3600ea..00000000000 --- a/src/rust/python-parser/BUILD +++ /dev/null @@ -1,20 +0,0 @@ -load("//:build/kj_test.bzl", "kj_test") -load("//:build/wd_rust_crate.bzl", "wd_rust_crate") - -wd_rust_crate( - name = "python-parser", - cxx_bridge_src = "lib.rs", - visibility = ["//visibility:public"], - deps = [ - "@crates_vendor//ruff_python_ast", - "@crates_vendor//ruff_python_parser", - ], -) - -kj_test( - src = "import_parsing.c++", - deps = [ - ":python-parser", - "//src/rust/cxx-integration", - ], -) diff --git a/src/rust/python-parser/import_parsing.c++ b/src/rust/python-parser/import_parsing.c++ deleted file mode 100644 index 64aa75230de..00000000000 --- a/src/rust/python-parser/import_parsing.c++ +++ /dev/null @@ -1,180 +0,0 @@ -// Copyright (c) 2017-2022 Cloudflare, Inc. -// Licensed under the Apache 2.0 license found in the LICENSE file or at: -// https://opensource.org/licenses/Apache-2.0 - -#include - -#include - -#include - -using namespace kj_rs; - -using ::edgeworker::rust::python_parser::get_imports; - -kj::Array parseImports(kj::ArrayPtr cpp_modules) { - auto rust_modules = kj::heapArrayBuilder<::rust::Str const>(cpp_modules.size()); - for (auto& entry: cpp_modules) { - rust_modules.add(entry.cStr()); - } - ::rust::Slice<::rust::Str const> rust_slice(rust_modules.begin(), rust_modules.size()); - auto rust_result = get_imports(rust_slice); - return kj::from(rust_result); -} - -namespace workerd::api { -namespace { - -KJ_TEST("basic `import` tests") { - auto result = parseImports(kj::arr("import a\nimport z"_kj, "import b"_kj)); - KJ_REQUIRE(result.size() == 3); - KJ_REQUIRE(result[0] == "a"); - KJ_REQUIRE(result[1] == "b"); - KJ_REQUIRE(result[2] == "z"); -} - -KJ_TEST("supports whitespace") { - auto result = parseImports(kj::arr("import a\nimport \\\n\tz"_kj)); - KJ_REQUIRE(result.size() == 2); - KJ_REQUIRE(result[0] == "a"); - KJ_REQUIRE(result[1] == "z"); -} - -KJ_TEST("supports windows newlines") { - auto result = parseImports(kj::arr("import a\r\nimport \\\r\n\tz"_kj)); - KJ_REQUIRE(result.size() == 2); - KJ_REQUIRE(result[0] == "a"); - KJ_REQUIRE(result[1] == "z"); -} - -KJ_TEST("basic `from` test") { - auto result = parseImports(kj::arr("from x import a,b\nfrom z import y"_kj)); - KJ_REQUIRE(result.size() == 2); - KJ_REQUIRE(result[0] == "x"); - KJ_REQUIRE(result[1] == "z"); -} - -KJ_TEST("ignores indented blocks") { - auto result = parseImports(kj::arr("import a\nif True:\n import x\nimport y"_kj)); - KJ_REQUIRE(result.size() == 2); - KJ_REQUIRE(result[0] == "a"); - KJ_REQUIRE(result[1] == "y"); -} - -KJ_TEST("supports nested imports") { - auto result = parseImports(kj::arr("import a.b\nimport z.x.y.i"_kj)); - KJ_REQUIRE(result.size() == 2); - KJ_REQUIRE(result[0] == "a.b"); - KJ_REQUIRE(result[1] == "z.x.y.i"); -} - -KJ_TEST("nested `from` test") { - auto result = parseImports(kj::arr("from x.y.z import a,b\nfrom z import y"_kj)); - KJ_REQUIRE(result.size() == 2); - KJ_REQUIRE(result[0] == "x.y.z"); - KJ_REQUIRE(result[1] == "z"); -} - -KJ_TEST("ignores trailing period") { - auto result = parseImports(kj::arr("import a.b.\nimport z.x.y.i."_kj)); - KJ_REQUIRE(result.size() == 0); -} - -KJ_TEST("ignores relative import") { - // This is where we diverge from the old AST-based approach. It would have returned `y` in the - // input below. - auto result = parseImports(kj::arr("import .a.b\nimport ..z.x\nfrom .y import x"_kj)); - KJ_REQUIRE(result.size() == 0); -} - -KJ_TEST("supports commas") { - auto result = parseImports(kj::arr("import a,b"_kj)); - KJ_REQUIRE(result.size() == 2); - KJ_REQUIRE(result[0] == "a"); - KJ_REQUIRE(result[1] == "b"); -} - -KJ_TEST("supports backslash") { - // clang-format off - auto result = parseImports(kj::arr( - "import a\\\n,b"_kj, - "import\\\n q,w"_kj, - "from \\\nx import y"_kj, - "from \\\n c import y"_kj - )); - // clang-format on - KJ_REQUIRE(result.size() == 6); - KJ_REQUIRE(result[0] == "a"); - KJ_REQUIRE(result[1] == "b"); - KJ_REQUIRE(result[2] == "c"); - KJ_REQUIRE(result[3] == "q"); - KJ_REQUIRE(result[4] == "w"); - KJ_REQUIRE(result[5] == "x"); -} - -KJ_TEST("multiline-strings ignored") { - // clang-format off - auto files = kj::arr(R"SCRIPT( -FOO=""" -import x -from y import z -""" -)SCRIPT"_kj, -R"SCRIPT( -FOO=''' -import f -from g import z -''' -)SCRIPT"_kj, -R"SCRIPT(FOO = "\ -import b \ -")SCRIPT"_kj, -"FOO=\"\"\" \n"_kj, -R"SCRIPT(import x -from y import z -""")SCRIPT"_kj); - // clang-format on - auto result = parseImports(files); - KJ_REQUIRE(result.size() == 0); -} - -KJ_TEST("multiline-strings with imports in-between") { - auto files = kj::arr( - R"SCRIPT(FOO=""" -import x -from y import z -""" -import q -import w -BAR=""" -import e -""" -from t import u)SCRIPT"_kj); - auto result = parseImports(files); - KJ_REQUIRE(result.size() == 3); - KJ_REQUIRE(result[0] == "q"); - KJ_REQUIRE(result[1] == "t"); - KJ_REQUIRE(result[2] == "w"); -} - -KJ_TEST("import after string literal") { - auto files = kj::arr(R"SCRIPT(import a -"import b")SCRIPT"_kj); - auto result = parseImports(files); - KJ_REQUIRE(result.size() == 1); - KJ_REQUIRE(result[0] == "a"); -} - -KJ_TEST("langchain import") { - auto files = kj::arr(R"SCRIPT(from js import Response, console, URL -from langchain.chat_models import ChatOpenAI -import openai)SCRIPT"_kj); - auto result = parseImports(files); - KJ_REQUIRE(result.size() == 3); - KJ_REQUIRE(result[0] == "js"); - KJ_REQUIRE(result[1] == "langchain.chat_models"); - KJ_REQUIRE(result[2] == "openai"); -} - -} // namespace -} // namespace workerd::api diff --git a/src/rust/python-parser/lib.rs b/src/rust/python-parser/lib.rs deleted file mode 100644 index e8ce1d5fba5..00000000000 --- a/src/rust/python-parser/lib.rs +++ /dev/null @@ -1,43 +0,0 @@ -use std::collections::HashSet; - -use ruff_python_ast::Stmt; -use ruff_python_ast::StmtImportFrom; -use ruff_python_parser::parse_module; - -#[cxx::bridge(namespace = "edgeworker::rust::python_parser")] -#[expect(unsafe_code, reason = "the cxx bridge expands to unsafe FFI glue")] -mod ffi { - - extern "Rust" { - fn get_imports(sources: &[&str]) -> Vec; - } -} - -#[must_use] -pub fn get_imports(sources: &[&str]) -> Vec { - let mut names: HashSet = HashSet::new(); - for src in sources { - // Just skip it if it doesn't parse. - let Ok(module) = parse_module(src) else { - continue; - }; - for stmt in &module.syntax().body { - match stmt { - Stmt::Import(s) => { - names.extend(s.names.iter().map(|x| x.name.id.as_str().to_owned())); - } - Stmt::ImportFrom(StmtImportFrom { - module: Some(module), - level: 0, - .. - }) => { - names.insert(module.id.as_str().to_owned()); - } - _ => {} - } - } - } - let mut result: Vec<_> = names.drain().collect(); - result.sort(); - result -}