diff --git a/Cargo.toml b/Cargo.toml index 6f4e96c08f0f3..26952388c9e93 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -240,7 +240,7 @@ resolver = "2" [workspace.package] edition = "2021" -rust-version = "1.80.1" +rust-version = "1.83.0" [profile.dev] split-debuginfo = "unpacked" @@ -326,6 +326,7 @@ reqwest-retry = { git = "https://github.com/MaterializeInc/reqwest-middleware.gi # DO NOT EDIT. Automatically generated by bin/gen-lints. [workspace.lints.rust] unknown_lints = "allow" +non_local_definitions = "allow" unexpected_cfgs = { level = "warn", check-cfg = ['cfg(bazel, stamped, coverage, nightly_doc_features, release, tokio_unstable)'] } [workspace.lints.rustdoc] diff --git a/WORKSPACE b/WORKSPACE index 87ecf3ee77cac..6acf475d00ee2 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -311,9 +311,9 @@ c_repositories() # Rules for building Rust crates, and several convienence macros for building all transitive # dependencies. -RULES_RUST_VERSION = "0.53.0" +RULES_RUST_VERSION = "0.54.1" -RULES_RUST_INTEGRITY = "sha256-heIBNyerJvsiq9/+SyrAwnotW2KWFnumPY9uExQPUfk=" +RULES_RUST_INTEGRITY = "sha256-r09Wyq5QqZpov845sUG1Cd1oVIyCBLmKt6HK/JTVuwI=" maybe( http_archive, @@ -334,9 +334,9 @@ rules_rust_dependencies() # Fetch and register the relevant Rust toolchains. We use a custom macro that # depends on `rules_rust` but cuts down on bloat from their defaults. -RUST_VERSION = "1.80.1" +RUST_VERSION = "1.83.0" -RUST_NIGHTLY_VERSION = "nightly/2024-08-01" +RUST_NIGHTLY_VERSION = "nightly/2024-12-02" load("//misc/bazel/toolchains:rust.bzl", "rust_toolchains") @@ -348,66 +348,66 @@ rust_toolchains( { "aarch64-apple-darwin": { "stable": { - "rustc": "ada84b7c4521b10f54ab73d34916cb45fb68cc928b16c9e1be39f89406b84c86", - "clippy": "f1f6772c917008d170e4cdc7ae10e370cfbe11da6105bf5913a1b43ea126b0f1", - "cargo": "4649742a7bfc4a46036e47ea057d60bf8301c0299054c9785ee37947b2d1294c", - "llvm-tools": "725bb2381dd287fb070a05eb6092fc5b4000ba69eb2cb27790c0f40fd248a56a", - "rust-std": "ddd123723fe4576a155ce0190da5f16a2c067cbd5b1a2c23b301592568e5752d", + "cargo": "1608c47547350e17a6c8adde254ccce1d728c2a88bf83c28079918f265dcf5e9", + "clippy": "be37e667fb9fc7f1cccbeff65138f538ff74fac87487ad0e98b75a01313ded14", + "llvm-tools": "ed8b7cb072a171fd9254366e30c9b3223eb7d82ae028dbf0c6875cc2d4ddaf96", + "rust-std": "d4f6a6c23c8cb643ba8a7a166bdf86d054eae2ea4e4b3bd7562dc2cb373b9fe2", + "rustc": "94bc661bda0ee93a2760068e539750f80a71017b5d0d6d4fc7be46587ff6febc", }, "nightly": { - "rustc": "16a8eefc8121633bc1d80342975cc5299a3da4c11d28e3a134ce376eafea4784", - "clippy": "341b35b68ab14d0de0b6cece0042ae91b640a66b6fbc71ff6a4e021c2a1cea18", - "cargo": "e633472e33eb97d2886d3149968b27956b91efa8da5cded10399c7a1f0ede481", - "llvm-tools": "2cf35c331fff0034301fb0cbef221c3203f23ab4c6780e20a70c92d76b1bf7f5", - "rust-std": "f0742c7371383c1ea2849440b8d5f631be2aa7211b3e150a41cca552dcd92ddd", + "cargo": "efc0487a586e8b3d2f611374b135d6877833a98e352dea1a2c3500545cf67dc1", + "clippy": "76e8a48b0209027c7d0d887194837a0d731a72c4faf90c420e846c34f5075450", + "llvm-tools": "a0a9549fbd77648b843af8d081c443db08a900327c1d90a81c62ea187aee0e85", + "rust-std": "a101b44e0f97d5484c02d82396570e6b61a8d7ec816452d6e4c3a208e863672b", + "rustc": "7213e573a87b737ea98a0b32ef4ff0e65f56d03937b9897a69a9386d2bf998f9", }, }, "aarch64-unknown-linux-gnu": { "stable": { - "rustc": "4ca87875f8a23ef1f23d60a958a0dc798e2b8e97bf6782b2ec534026181fa72c", - "clippy": "fcda253a6704f612310696f25f161c880f16ec8be6b640ccf5fe26245c822efc", - "cargo": "6973b542f54ade0215becd34a06d011e4c35a8091a27ac667d0438ebc45a935e", - "llvm-tools": "2574807dcf8a1d68adc57c42c4caa812ac3d54f376b16b536c8073c60877c680", - "rust-std": "07238d367cfba20bf80150f725234b877b11bc3ab82d04ed0ccc95375e9cedd8", + "cargo": "facfde3caea4919e4fbf48da8fe87cf67ab59bacc2e277f481e3d700f0c09b18", + "clippy": "f83e26c85e880b4473e10f7acc7ecb8097923061bb9592b7e51179e5bf101df2", + "llvm-tools": "66bf1fade70c32b540c38e938219d7ef7bb3cc858c0301942f07c946742dabf8", + "rust-std": "27d90fb3322f5f60d8c1adde3a0c5081de66343323616ba19462db6159041cdf", + "rustc": "875597345b11c42c726a42c9405c8ed37cc6a23c4b09553a79e65960562b342d", }, "nightly": { - "rustc": "d21d28f3b81637070004f486c5267989381ad763e7d4c9084d2d226aa46cd308", - "clippy": "58a022177e2cb99f40ddd4e4dacd4b5580af9920829a873bbbd92d91cb934979", - "cargo": "4b56caba8ccd3101cbae3b2093b0858ae9045534c7378fc16150285d0f3c082f", - "llvm-tools": "52cf02c11e64b320d05ca1df8d1104a757080a3088e397bd1f752f5bd0b6b258", - "rust-std": "6ad1dc3b4aa3f78a7ead87ecc475299b35e884778ecc99a057a3178fa1c332b5", + "cargo": "71bd7220e9412a30bc9e7fd5e159cbfc358a908f073dc1c2afea5fdc698b4788", + "clippy": "91286bc8cacd615421ed3e90a4b7b1b4c736e8ba680a8fc27f35a3fd6af621da", + "llvm-tools": "cfb01325e555ed05217c6d32800a3344dc4353ffd9b9dc32bc0020a497872cf0", + "rust-std": "ea2d8acf5c8cf2e56f87419b80d1a7849061f4869091ecdcf959267aa6a2c4d9", + "rustc": "ff8c5cbf4c152ddce1519c9641269b30316fd29f1f1487e76c7a0e1e97270706", }, }, - "x86_64-unknown-linux-gnu": { + "x86_64-apple-darwin": { "stable": { - "rustc": "5c7fce7a0323b8669b4e17ec370b38a5f207fcdcd5c66b83c877b72e252d561e", - "clippy": "39253ce4ecb036977686f5a8cc183de295cf280766678201f919c5655e3dd063", - "cargo": "863c016fc458b1fa8809d7b66dcccd272f8b6b2e8a42c89b7dff4b619f3d3940", - "llvm-tools": "86e441024b0e538ed69fa0098be48592caae6fc28097f7630b906be276c79622", - "rust-std": "e7b766fce1cd89c02bde33f8cc3a81f341c52677258a546df2bee1c7090e9fc5", + "cargo": "8296adfdd7ca78ee8b8ef0ec97d42d4a9fd754af197e0a079d65795e927f1963", + "clippy": "94f9fa4f67dc6933bf5ad47cc1c6673184e0db5fca9f2a57e251f273e22b2071", + "llvm-tools": "b39bc3518ef6a253b80f58facee36fdc5e54199e5e0264249902d1c545242ba4", + "rust-std": "8e43cc2dbd2f8a4fb1120fa8ff685c5929d3c71d68d75836d88ecde3fd9af4f4", + "rustc": "5c51f5ff7955e8c2b013ea9ebfcc89ce9a86d33d3bd229d8fa98b0f4b29759bd", }, "nightly": { - "rustc": "10bf2f8f95cf934bf1f3e0f7d507b615c6a329bedb78adaa1d3bdf75532d7d36", - "clippy": "692f4550bf4e2f3a783f97a3706ed0c557258b885a6c166830e4b4e40bc8ba06", - "cargo": "10cc2e832b8ac2386eb0fbd2f1eb3583ff6f9468332619f6bb1324b27fe6451f", - "llvm-tools": "45b11ccde9ec167c4d741ade55fdab958db01a938a6e2b437f93733aa2bfa036", - "rust-std": "8a8bf9b1d4f93ca2a162a28d0f478ac7bc73aab241befecdf9a1dbf27d86f68f", + "cargo": "42034eef7f0cc76ebb5605363a660c6c5bb4e403c3cbe5169f76601d54d894b1", + "clippy": "4bd33568e73f9972890fbdfd5ccf2756a7f51992f7434cc29097b3ef8cbcb10d", + "llvm-tools": "83fbbe591566f7ccf28ec599b5cfbed9285ce14cee41d94ac263dc72e5d5a94c", + "rust-std": "9c93397a365cbdf940575967a084910adf78441eb045408ecc6e16ffe213e7c3", + "rustc": "8676f69a3303d19d226667a0b7b60bc28dd03f3d1b975c6fcce716606c2243d3", }, }, - "x86_64-apple-darwin": { + "x86_64-unknown-linux-gnu": { "stable": { - "rustc": "f0adfff86a9d5055f537dab26f6d0b7a81efe087f90b7e16c42698d58af0ffca", - "clippy": "5b6e393a7784839a1554188df2d87481696a0e0be242d1d2982e442b43199c08", - "cargo": "e3d03157061987be0c7cddf1e708f376929273779a65459a9b3a7ebc6ccadaae", - "llvm-tools": "3c443d068464c95a0a02072082bff6661cee5568dbbedbb82dcb6737147f3d6c", - "rust-std": "c9e366e76ee470d11afadbd70b200976ef4b34e626b568f19e429d4d23dead86", + "cargo": "49a1426f692cd26dfe8e41e5cff2954d686133d5d777893d0c2fe78cc8e39237", + "clippy": "c9523adb965ef47ca924c6f5f10496075ae7e3678622668eef3e612303737b6b", + "llvm-tools": "49fee083c3d09f3b75b57c8072682932aabdedb0880a8b8935262fe7ba83c5a7", + "rust-std": "9ee7421198c668a6f61c1202c262243c0a9d2ceff894ec6ac5ab78af27c73e48", + "rustc": "055407ec7be6d3e95b10d4426f0c14cfacadc5d4fa9834a02f96797061cd0818", }, "nightly": { - "rustc": "9ea43d51a690240f2c505ba62f1705de3c1329d7b3399ce462f4ecd242dbd87a", - "clippy": "058e05278fe37789a54ad603691e06b35c7ff345b1dbad82d13552c2409f0ff0", - "cargo": "fe5c735fec5c8d05de922ad4ec1296f2115cf3e2cc0617420104586d020efe6d", - "llvm-tools": "8a3f90b01ec1ae47dbe33fbb5329a8457da1252a07c2bbfac0d297cb4f031b88", - "rust-std": "a2d70b9f21a69639b61c87273495de579a32d197015e4a76dabf6cd417a6a12f", + "cargo": "9eddd8e51f87de1239db8f35c3e4a574c231fa883ed055b5ac64471c2f272501", + "clippy": "0adb5c12df13550daf954af7414cd7af9c849878c7894a02e61b9720d32f9143", + "llvm-tools": "e5a79a9b1c0816e613abe6c5764946688668412985edc2b1728308db2a69ba4f", + "rust-std": "665d761c020c0f9320a3e0aedad27ad466c54e802c59ac773a40f7899cc994e5", + "rustc": "8685599744c5b6b7a2cbad4fa5c5dec8fcc4a42e04fc864a7b9bb8371ffbfdbe", }, }, }, diff --git a/bin/lint-versions b/bin/lint-versions index a65fa4fa12021..d515ea5dba013 100755 --- a/bin/lint-versions +++ b/bin/lint-versions @@ -11,5 +11,5 @@ # # lint-versions - Check rust version -grep "rust-version = " Cargo.toml | grep -q "1\.80\.1" || \ +grep "rust-version = " Cargo.toml | grep -q "1\.83\.0" || \ (echo "Please validate new Rust versions for compilation time performance regressions or ask Team Testing to do so. Afterwards change the tested version in bin/lint-versions" && exit 1) diff --git a/doc/developer/upgrade-rust.md b/doc/developer/upgrade-rust.md index d801315bf6557..7463f007b5577 100644 --- a/doc/developer/upgrade-rust.md +++ b/doc/developer/upgrade-rust.md @@ -7,13 +7,28 @@ possible. Anyone is welcome to upgrade the version of Rust! Below is the list of things you need to do: -1. Bump the `rust-version` field in our [Workspace `Cargo.toml`](/Cargo.toml) and in the [Bazel `WORKSPACE`](/WORKSPACE). +1. Pick a version of the Nightly Rust compiler. Materialize builds with the Stable compiler, but we + run [Miri](https://github.com/rust-lang/miri) in CI which requires Nightly. + * First, look at this list of [available components](https://rust-lang.github.io/rustup-components-history/aarch64-unknown-linux-gnu.html) + and make sure you pick a version that has everything available. + * Second, check the [rust-lang GitHub Issue Tracker](https://github.com/rust-lang/rust/issues?q=is%3Aopen%20label%3AP-critical) + to make sure the Nightly version you pick does not have any open `P-critical` issues. +2. Package the toolchain for consumption by Bazel using the [Rust GitHub Action](https://github.com/MaterializeInc/toolchains/actions/workflows/rust.yml) + in our `toolchains` repository. Example options you would run the GitHub action with are: + * (Stable): "1.83.0", "rust-1.83.0" + * (Nightly): "nightly/2024-12-02", "rust-nightly/2024-12-02" + * **Note:** It's important to follow this exact naming convention because the Tag at which + the release is uploaded to determines the URL it can be fetched with. +3. Bump the `rust-version` field in our [Workspace `Cargo.toml`](/Cargo.toml) and in the [Bazel `WORKSPACE`](/WORKSPACE). + * Run `bin/bazel integrity toolchains ` to generate the hashes for the `rust_toolchains` + rule in our `WORKSPACE` file. 2. Bump the `NIGHTLY_RUST_DATE` value in the [`ci-builder`](/bin/ci-builder) script. * Note: CI has a nightly version of Rust so we can run [Miri](https://github.com/rust-lang/miri). 3. Locally run `rustup upgrade stable` to pull the latest version of the Rust toolchain, or whatever version you're upgrading to. 4. From the root of the repository run `cargo clippy --workspace --tests`, fix any new clippy lints that were introduced. + * First try running `cargo fix`, that should go a long way in automatically fixing many of the lints. 5. Check if Rust's unicode version has changed. If it has make sure to include in the release notes what version it previously was, and what version it got bumped to. * The [Releases](https://github.com/rust-lang/rust/releases) page for the Rust repository diff --git a/misc/bazel/cargo-gazelle/src/targets.rs b/misc/bazel/cargo-gazelle/src/targets.rs index 9b7e1765f4448..134797a46d595 100644 --- a/misc/bazel/cargo-gazelle/src/targets.rs +++ b/misc/bazel/cargo-gazelle/src/targets.rs @@ -1234,7 +1234,7 @@ pub fn crate_features<'a>( /// TODO(parkmycar): Make the list of platforms configurable. pub fn platform_feature_sets<'a>( package: &'a PackageMetadata<'a>, -) -> BTreeMap { +) -> BTreeMap> { // Resolve a feature graph for all crates that depend on this one. let dependents = package .to_package_query(DependencyDirection::Reverse) diff --git a/misc/bazel/rust_deps/cxxbridge-cmd/Cargo.cxxbridge-cmd.lock b/misc/bazel/rust_deps/cxxbridge-cmd/Cargo.cxxbridge-cmd.lock index aee7fbcd6cfd9..eed6391e308d4 100644 --- a/misc/bazel/rust_deps/cxxbridge-cmd/Cargo.cxxbridge-cmd.lock +++ b/misc/bazel/rust_deps/cxxbridge-cmd/Cargo.cxxbridge-cmd.lock @@ -1,5 +1,5 @@ { - "checksum": "1b88de7d7f3ec7292f59a809812300eeed87d6453d1f6b712059b88cd3f31140", + "checksum": "b2b75eaba9abbc55071dcf7f2ded98069da446c19b24e7ac327c70bc8edf867e", "crates": { "anstyle 1.0.4": { "name": "anstyle", @@ -713,22 +713,6 @@ "compile_data_glob": [ "**" ], - "crate_features": { - "common": [ - "consoleapi", - "errhandlingapi", - "fileapi", - "minwindef", - "processenv", - "std", - "sysinfoapi", - "winbase", - "wincon", - "winerror", - "winnt" - ], - "selects": {} - }, "deps": { "common": [ { @@ -964,111 +948,20 @@ "aarch64-apple-darwin": [ "aarch64-apple-darwin" ], - "aarch64-apple-ios": [ - "aarch64-apple-ios" - ], - "aarch64-apple-ios-sim": [ - "aarch64-apple-ios-sim" - ], - "aarch64-fuchsia": [ - "aarch64-fuchsia" - ], - "aarch64-linux-android": [ - "aarch64-linux-android" - ], - "aarch64-pc-windows-msvc": [ - "aarch64-pc-windows-msvc" - ], "aarch64-unknown-linux-gnu": [ "aarch64-unknown-linux-gnu" ], - "aarch64-unknown-nixos-gnu": [ - "aarch64-unknown-nixos-gnu" - ], - "aarch64-unknown-nto-qnx710": [ - "aarch64-unknown-nto-qnx710" - ], - "arm-unknown-linux-gnueabi": [ - "arm-unknown-linux-gnueabi" - ], - "armv7-linux-androideabi": [ - "armv7-linux-androideabi" - ], - "armv7-unknown-linux-gnueabi": [ - "armv7-unknown-linux-gnueabi" - ], - "cfg(windows)": [ - "aarch64-pc-windows-msvc", - "i686-pc-windows-msvc", - "x86_64-pc-windows-msvc" - ], - "i686-apple-darwin": [ - "i686-apple-darwin" - ], - "i686-linux-android": [ - "i686-linux-android" - ], + "cfg(windows)": [], "i686-pc-windows-gnu": [], - "i686-pc-windows-msvc": [ - "i686-pc-windows-msvc" - ], - "i686-unknown-freebsd": [ - "i686-unknown-freebsd" - ], - "i686-unknown-linux-gnu": [ - "i686-unknown-linux-gnu" - ], - "powerpc-unknown-linux-gnu": [ - "powerpc-unknown-linux-gnu" - ], - "riscv32imc-unknown-none-elf": [ - "riscv32imc-unknown-none-elf" - ], - "riscv64gc-unknown-none-elf": [ - "riscv64gc-unknown-none-elf" - ], - "s390x-unknown-linux-gnu": [ - "s390x-unknown-linux-gnu" - ], - "thumbv7em-none-eabi": [ - "thumbv7em-none-eabi" - ], - "thumbv8m.main-none-eabi": [ - "thumbv8m.main-none-eabi" - ], "wasm32-unknown-unknown": [ "wasm32-unknown-unknown" ], - "wasm32-wasi": [ - "wasm32-wasi" - ], "x86_64-apple-darwin": [ "x86_64-apple-darwin" ], - "x86_64-apple-ios": [ - "x86_64-apple-ios" - ], - "x86_64-fuchsia": [ - "x86_64-fuchsia" - ], - "x86_64-linux-android": [ - "x86_64-linux-android" - ], "x86_64-pc-windows-gnu": [], - "x86_64-pc-windows-msvc": [ - "x86_64-pc-windows-msvc" - ], - "x86_64-unknown-freebsd": [ - "x86_64-unknown-freebsd" - ], "x86_64-unknown-linux-gnu": [ "x86_64-unknown-linux-gnu" - ], - "x86_64-unknown-nixos-gnu": [ - "x86_64-unknown-nixos-gnu" - ], - "x86_64-unknown-none": [ - "x86_64-unknown-none" ] }, "direct_deps": [ diff --git a/misc/bazel/rust_deps/repositories.bzl b/misc/bazel/rust_deps/repositories.bzl index aeb5655339a63..513936c3952c2 100644 --- a/misc/bazel/rust_deps/repositories.bzl +++ b/misc/bazel/rust_deps/repositories.bzl @@ -42,6 +42,15 @@ def rust_repositories(): cargo_lockfile = "@cxxbridge-cmd//:Cargo.lock", lockfile = "//misc/bazel/rust_deps:cxxbridge-cmd/Cargo.cxxbridge-cmd.lock", manifests = ["@cxxbridge-cmd//:Cargo.toml"], + # Restricting the number of platforms we support _greatly_ reduces the + # amount of time it takes to "Splice Cargo Workspace". + supported_platform_triples = [ + "aarch64-unknown-linux-gnu", + "x86_64-unknown-linux-gnu", + "aarch64-apple-darwin", + "x86_64-apple-darwin", + "wasm32-unknown-unknown", + ], isolated = False, # Only used if developing rules_rust. # generator = "@cargo_bazel_bootstrap//:cargo-bazel", diff --git a/misc/python/materialize/bazel.py b/misc/python/materialize/bazel.py index c47a9acfbdf51..8e5ec645d4308 100644 --- a/misc/python/materialize/bazel.py +++ b/misc/python/materialize/bazel.py @@ -7,9 +7,12 @@ # the Business Source License, use of this software will be governed # by the Apache License, Version 2.0. +import hashlib import pathlib import subprocess +import requests + from materialize import MZ_ROOT, ui """Utilities for interacting with Bazel from python scripts""" @@ -55,3 +58,80 @@ def write_git_hash(): f.write(result.stdout.strip()) else: ui.warn(f"Failed to get current revision of {MZ_ROOT}, falling back to all 0s") + + +def calc_ingerity(path) -> str: + """ + Calculate the 'integrity' for a given file. + + 'integrity' is a hash of the file used in rules like 'http_archive'. + + See: + """ + + digest = subprocess.run( + ["openssl", "dgst", "-sha256", "-binary", str(path)], stdout=subprocess.PIPE + ) + base64 = subprocess.run( + ["openssl", "base64", "-A"], input=digest.stdout, stdout=subprocess.PIPE + ) + formatted = subprocess.run( + ["sed", "s/^/sha256-/"], input=base64.stdout, stdout=subprocess.PIPE + ) + + return formatted.stdout.decode("utf-8") + + +def toolchain_hashes(stable, nightly) -> dict[str, dict[str, str]]: + """ + Generates the hashes for our Bazel toolchains. + + Fetches the specified Stable and Nightly version of the Rust compiler from our toolchains repo, + hashes the downloaded files, and returns a properly formatted dictionary for Bazel. + """ + + ARCHS = [ + "aarch64-apple-darwin", + "aarch64-unknown-linux-gnu", + "x86_64-apple-darwin", + "x86_64-unknown-linux-gnu", + ] + TOOLS = [ + "cargo", + "clippy", + "llvm-tools", + "rust-std", + "rustc", + ] + VERSIONS = {"stable": stable, "nightly": nightly} + URL_TEMPLATE = "https://github.com/MaterializeInc/toolchains/releases/download/rust-{version}/{tool}-{channel}-{arch}.tar.zst" + + hashes = {} + + for arch in ARCHS: + hashes[arch] = {} + for channel, version in VERSIONS.items(): + hashes[arch][channel] = {} + for tool in TOOLS: + if channel == "stable": + url_channel = version + else: + url_channel = channel + + print(f"Processing {tool} {version} {arch}") + + # Download the file. + url = URL_TEMPLATE.format( + version=version, tool=tool, channel=url_channel, arch=arch + ) + response = requests.get(url, stream=True) + response.raise_for_status() + + # Hash the response. + sha256_hash = hashlib.sha256() + for chunk in response.iter_content(chunk_size=8192): + if chunk: + sha256_hash.update(chunk) + hashes[arch][channel][tool] = sha256_hash.hexdigest() + + return hashes diff --git a/misc/python/materialize/cli/bazel.py b/misc/python/materialize/cli/bazel.py index d945231de65c8..758634eb111f8 100644 --- a/misc/python/materialize/cli/bazel.py +++ b/misc/python/materialize/cli/bazel.py @@ -42,6 +42,8 @@ def main() -> int: output_path_cmd(config, sub_args) elif args.action == "check": check_cmd(config, sub_args) + elif args.action == "integrity": + integrity_cmd(config, sub_args) else: bazel_cmd(config, [args.action] + sub_args) @@ -98,6 +100,20 @@ def output_path_cmd(config: BuildConfig, args: list[str]): print(path) +def integrity_cmd(config: BuildConfig, args: list[str]): + """Calculate the integrity value for a file.""" + if args[0] == "toolchains": + assert len(args) == 3, "expected " + stable = args[1] + nightly = args[2] + hashes = bazel.toolchain_hashes(stable, nightly) + print(hashes) + else: + for path in args: + integrity = bazel.calc_ingerity(path) + print(integrity) + + def bazel_cmd(config: BuildConfig, args: list[str]): """Forwards all arguments to Bazel, possibly with extra configuration.""" remote_cache = remote_cache_arg(config) diff --git a/misc/python/materialize/cli/gen-lints.py b/misc/python/materialize/cli/gen-lints.py index 36987225fe60e..731ccf5426d26 100644 --- a/misc/python/materialize/cli/gen-lints.py +++ b/misc/python/materialize/cli/gen-lints.py @@ -22,6 +22,7 @@ ALLOW_RUST_LINTS = [ # Allows us to allow/deny new lints and support older versions of rust/clippy. "unknown_lints", + "non_local_definitions", ] ALLOW_RUST_DOC_LINTS = [ diff --git a/misc/wasm/Cargo.toml b/misc/wasm/Cargo.toml index 765f503534a6d..d544bd0fcede9 100644 --- a/misc/wasm/Cargo.toml +++ b/misc/wasm/Cargo.toml @@ -13,6 +13,7 @@ rust-version = "1.76.0" # DO NOT EDIT. Automatically generated by bin/gen-lints. [workspace.lints.rust] unknown_lints = "allow" +non_local_definitions = "allow" unexpected_cfgs = { level = "warn", check-cfg = ['cfg(bazel, stamped, coverage, nightly_doc_features, release, tokio_unstable)'] } [workspace.lints.rustdoc] diff --git a/src/adapter/src/catalog.rs b/src/adapter/src/catalog.rs index a41c2dd371f05..5b98e844bf392 100644 --- a/src/adapter/src/catalog.rs +++ b/src/adapter/src/catalog.rs @@ -1121,14 +1121,14 @@ impl Catalog { } pub fn get_role_allowed_cluster_sizes(&self, role_id: &Option) -> Vec { - return if role_id == &Some(MZ_SYSTEM_ROLE_ID) { + if role_id == &Some(MZ_SYSTEM_ROLE_ID) { self.cluster_replica_sizes() .enabled_allocations() .map(|a| a.0.to_owned()) .collect::>() } else { self.system_config().allowed_cluster_replica_sizes() - }; + } } pub fn concretize_replica_location( diff --git a/src/adapter/src/coord/timeline.rs b/src/adapter/src/coord/timeline.rs index cdce586f4ff68..a04e6f4a979e3 100644 --- a/src/adapter/src/coord/timeline.rs +++ b/src/adapter/src/coord/timeline.rs @@ -197,7 +197,7 @@ impl Coordinator { pub(crate) async fn ensure_timeline_state<'a>( &'a mut self, timeline: &'a Timeline, - ) -> &mut TimelineState { + ) -> &'a mut TimelineState { Self::ensure_timeline_state_with_initial_time( timeline, Timestamp::minimum(), diff --git a/src/catalog/src/durable.rs b/src/catalog/src/durable.rs index 1b6f85f603d95..ddf6fc198be87 100644 --- a/src/catalog/src/durable.rs +++ b/src/catalog/src/durable.rs @@ -276,6 +276,7 @@ pub trait ReadOnlyDurableCatalogState: Debug + Send { /// A read-write API for the durable catalog state. #[async_trait] +#[allow(elided_named_lifetimes)] pub trait DurableCatalogState: ReadOnlyDurableCatalogState { /// Returns true if the catalog is opened in read only mode, false otherwise. fn is_read_only(&self) -> bool; diff --git a/src/catalog/src/durable/persist.rs b/src/catalog/src/durable/persist.rs index 94c83a13f41fb..cdd764ba21e51 100644 --- a/src/catalog/src/durable/persist.rs +++ b/src/catalog/src/durable/persist.rs @@ -1695,6 +1695,7 @@ impl ReadOnlyDurableCatalogState for PersistCatalogState { } #[async_trait] +#[allow(elided_named_lifetimes)] impl DurableCatalogState for PersistCatalogState { fn is_read_only(&self) -> bool { matches!(self.mode, Mode::Readonly) diff --git a/src/catalog/src/durable/transaction.rs b/src/catalog/src/durable/transaction.rs index 2d34e0ae5f7d1..59dc140ba0771 100644 --- a/src/catalog/src/durable/transaction.rs +++ b/src/catalog/src/durable/transaction.rs @@ -134,7 +134,7 @@ impl<'a> Transaction<'a> { txn_wal_shard, }: Snapshot, upper: mz_repr::Timestamp, - ) -> Result { + ) -> Result, CatalogError> { Ok(Transaction { durable_catalog, databases: TableTransaction::new_with_uniqueness_fn( diff --git a/src/compute/src/row_spine.rs b/src/compute/src/row_spine.rs index 58b5cfa1d0274..ced151deb2444 100644 --- a/src/compute/src/row_spine.rs +++ b/src/compute/src/row_spine.rs @@ -326,7 +326,10 @@ mod container { use mz_repr::fixed_length::ToDatumIter; impl<'long> ToDatumIter for DatumSeq<'long> { - type DatumIter<'short> = DatumSeq<'short> where Self: 'short; + type DatumIter<'short> + = DatumSeq<'short> + where + Self: 'short; fn to_datum_iter<'short>(&'short self) -> Self::DatumIter<'short> { *self } diff --git a/src/expr/src/explain/text.rs b/src/expr/src/explain/text.rs index bb4c712a903ea..ca58590df0fe5 100644 --- a/src/expr/src/explain/text.rs +++ b/src/expr/src/explain/text.rs @@ -877,7 +877,7 @@ impl MirRelationExpr { fn column_names<'a>( &'a self, ctx: &'a PlanRenderingContext<'_, MirRelationExpr>, - ) -> Option<&Vec> { + ) -> Option<&'a Vec> { if !ctx.config.humanized_exprs { None } else if let Some(analyses) = ctx.annotations.get(self) { diff --git a/src/mz/src/config_file.rs b/src/mz/src/config_file.rs index 112860e59a567..dad432239945f 100644 --- a/src/mz/src/config_file.rs +++ b/src/mz/src/config_file.rs @@ -115,7 +115,7 @@ impl ConfigFile { /// Loads a profile from the configuration file. /// Panics if the profile is not found. - pub fn load_profile<'a>(&'a self, name: &'a str) -> Result { + pub fn load_profile<'a>(&'a self, name: &'a str) -> Result, Error> { match &self.parsed.profiles { Some(profiles) => match profiles.get(name) { None => Err(Error::ProfileMissing(name.to_string())), @@ -257,7 +257,7 @@ impl ConfigFile { &'a self, name: &str, profile: &'a str, - ) -> Result, Error> { + ) -> Result, Error> { let profile = self.load_profile(profile)?; let value = (PROFILE_PARAMS[name].get)(profile.parsed); diff --git a/src/ore-proc/src/test.rs b/src/ore-proc/src/test.rs index 0908f7a93ccbc..926adb805c41d 100644 --- a/src/ore-proc/src/test.rs +++ b/src/ore-proc/src/test.rs @@ -23,7 +23,7 @@ use syn::{parse_macro_input, parse_quote, AttributeArgs, ItemFn, Meta, NestedMet /// Based on /// Copyright (C) 2019-2022 Daniel Mueller /// SPDX-License-Identifier: (Apache-2.0 OR MIT) - +/// /// Implementation for the `test` macro. pub fn test_impl(attr: TokenStream, item: TokenStream) -> TokenStream { let args = parse_macro_input!(attr as AttributeArgs); diff --git a/src/persist/src/location.rs b/src/persist/src/location.rs index 96d629c56ae8d..60893263fc0f3 100644 --- a/src/persist/src/location.rs +++ b/src/persist/src/location.rs @@ -593,6 +593,7 @@ impl Blob for Tasked { } } +/// Test helpers for the crate. #[cfg(test)] pub mod tests { use std::future::Future; @@ -630,6 +631,7 @@ pub mod tests { Ok(keys) } + /// Common test impl for different blob implementations. pub async fn blob_impl_test< B: Blob, F: Future>, @@ -801,6 +803,7 @@ pub mod tests { Ok(()) } + /// Common test impl for different consensus implementations. pub async fn consensus_impl_test< C: Consensus, F: Future>, diff --git a/src/pgwire-common/src/codec.rs b/src/pgwire-common/src/codec.rs index 37c9f32ed96ce..22a97e92da172 100644 --- a/src/pgwire-common/src/codec.rs +++ b/src/pgwire-common/src/codec.rs @@ -242,7 +242,7 @@ pub struct Cursor<'a> { impl<'a> Cursor<'a> { /// Constructs a new `Cursor` from a byte slice. The cursor will begin /// decoding from the beginning of the slice. - pub fn new(buf: &'a [u8]) -> Cursor { + pub fn new(buf: &'a [u8]) -> Cursor<'a> { Cursor { buf } } diff --git a/src/repr/src/adt/datetime.rs b/src/repr/src/adt/datetime.rs index d629aeb79f752..d64d97540a4a6 100644 --- a/src/repr/src/adt/datetime.rs +++ b/src/repr/src/adt/datetime.rs @@ -990,7 +990,7 @@ impl ParsedDateTime { } fn seconds_has_fraction(&self) -> bool { - return self.second.is_some() && self.second.as_ref().unwrap().fraction != 0; + self.second.is_some() && self.second.as_ref().unwrap().fraction != 0 } pub fn check_datelike_bounds(&mut self) -> Result<(), String> { diff --git a/src/repr/src/explain.rs b/src/repr/src/explain.rs index 39fe0f75346c3..953017f107570 100644 --- a/src/repr/src/explain.rs +++ b/src/repr/src/explain.rs @@ -368,7 +368,7 @@ pub struct RenderingContext<'a> { } impl<'a> RenderingContext<'a> { - pub fn new(indent: Indent, humanizer: &'a dyn ExprHumanizer) -> RenderingContext { + pub fn new(indent: Indent, humanizer: &'a dyn ExprHumanizer) -> RenderingContext<'a> { RenderingContext { indent, humanizer } } } diff --git a/src/repr/src/fixed_length.rs b/src/repr/src/fixed_length.rs index ab0fc57bdd6ff..e04165393f9f4 100644 --- a/src/repr/src/fixed_length.rs +++ b/src/repr/src/fixed_length.rs @@ -29,7 +29,11 @@ pub trait ToDatumIter: Sized { } impl<'b, T: ToDatumIter> ToDatumIter for &'b T { - type DatumIter<'a> = T::DatumIter<'a> where T: 'a, Self: 'a; + type DatumIter<'a> + = T::DatumIter<'a> + where + T: 'a, + Self: 'a; fn to_datum_iter<'a>(&'a self) -> Self::DatumIter<'a> { (**self).to_datum_iter() } diff --git a/src/sql-parser/tests/sqlparser_common.rs b/src/sql-parser/tests/sqlparser_common.rs index d2e05d2a4c524..21fd6752da6d0 100644 --- a/src/sql-parser/tests/sqlparser_common.rs +++ b/src/sql-parser/tests/sqlparser_common.rs @@ -218,7 +218,6 @@ fn test_basic_visitor() -> Result<(), Box> { )?; #[rustfmt::skip] // rustfmt loses the structure of the expected vector by wrapping all lines - let expected = vec![ "a01", "a02", "a03", "a04", "a05", "a06", "a07", "a08", "a09", "a10", "a11", "a12", "a13", "a14", "a15", "a16", "a17", "a18", "a19", "a20", "a21", "a22", "int4", "a23", "a24", diff --git a/src/sql-pretty/src/util.rs b/src/sql-pretty/src/util.rs index 4bb9dd18bfca5..cda422fc9234b 100644 --- a/src/sql-pretty/src/util.rs +++ b/src/sql-pretty/src/util.rs @@ -33,7 +33,7 @@ where pub(crate) fn title_comma_separate<'a, F, T, S>(title: S, f: F, v: &'a [T]) -> RcDoc<'a, ()> where - F: Fn(&'a T) -> RcDoc, + F: Fn(&'a T) -> RcDoc<'a>, S: Into, { let title = RcDoc::text(title.into()); @@ -50,7 +50,7 @@ pub(crate) fn nest_comma_separate<'a, F, T: 'a, I>( v: I, ) -> RcDoc<'a, ()> where - F: Fn(&'a T) -> RcDoc, + F: Fn(&'a T) -> RcDoc<'a>, I: IntoIterator, { nest(title, comma_separate(f, v)) @@ -58,7 +58,7 @@ where pub(crate) fn comma_separate<'a, F, T: 'a, I>(f: F, v: I) -> RcDoc<'a, ()> where - F: Fn(&'a T) -> RcDoc, + F: Fn(&'a T) -> RcDoc<'a>, I: IntoIterator, { let docs = v.into_iter().map(f); diff --git a/src/sql/src/catalog.rs b/src/sql/src/catalog.rs index fcc90b5de17e8..63eacd8a9e6c9 100644 --- a/src/sql/src/catalog.rs +++ b/src/sql/src/catalog.rs @@ -199,13 +199,13 @@ pub trait SessionCatalog: fmt::Debug + ExprHumanizer + Send + Sync + ConnectionR fn resolve_cluster<'a, 'b>( &'a self, cluster_name: Option<&'b str>, - ) -> Result<&dyn CatalogCluster<'a>, CatalogError>; + ) -> Result<&'a dyn CatalogCluster<'a>, CatalogError>; /// Resolves the named cluster replica. fn resolve_cluster_replica<'a, 'b>( &'a self, cluster_replica_name: &'b QualifiedReplica, - ) -> Result<&dyn CatalogClusterReplica<'a>, CatalogError>; + ) -> Result<&'a dyn CatalogClusterReplica<'a>, CatalogError>; /// Resolves a partially-specified item name, that is NOT a function or /// type. (For resolving functions or types, please use diff --git a/src/sql/src/names.rs b/src/sql/src/names.rs index 30a79ca61e6a0..33e26a9552959 100644 --- a/src/sql/src/names.rs +++ b/src/sql/src/names.rs @@ -1276,7 +1276,7 @@ pub struct NameResolver<'a> { } impl<'a> NameResolver<'a> { - fn new(catalog: &'a dyn SessionCatalog) -> NameResolver { + fn new(catalog: &'a dyn SessionCatalog) -> NameResolver<'a> { NameResolver { catalog, ctes: BTreeMap::new(), diff --git a/src/sql/src/pure/references.rs b/src/sql/src/pure/references.rs index 8f26363a4303f..21847645f06f5 100644 --- a/src/sql/src/pure/references.rs +++ b/src/sql/src/pure/references.rs @@ -309,7 +309,7 @@ impl RetrievedSourceReferences { &'a self, requested: Option<&ExternalReferences>, source_name: &UnresolvedItemName, - ) -> Result>, PlanError> { + ) -> Result>, PlanError> { // Filter all available references to those requested by the `ExternalReferences` // specification and include any alias that the user has specified. // TODO(database-issues#8620): The alias handling can be removed once subsources are removed. diff --git a/src/storage-types/src/stats.rs b/src/storage-types/src/stats.rs index 772536c649acc..0ff48f8d15244 100644 --- a/src/storage-types/src/stats.rs +++ b/src/storage-types/src/stats.rs @@ -185,7 +185,7 @@ impl RelationPartStats<'_> { num_oks.map(|num_oks| num_results - num_oks) } - fn col_values<'a>(&'a self, idx: usize, arena: &'a RowArena) -> Option { + fn col_values<'a>(&'a self, idx: usize, arena: &'a RowArena) -> Option> { let name = self.desc.get_name(idx); let typ = &self.desc.typ().column_types[idx]; diff --git a/src/timely-util/src/antichain.rs b/src/timely-util/src/antichain.rs index 00e4138ed7e61..7cf903d75666e 100644 --- a/src/timely-util/src/antichain.rs +++ b/src/timely-util/src/antichain.rs @@ -42,7 +42,10 @@ impl AntichainExt for MutableAntichain { } impl<'a, T: Display> AntichainExt for AntichainRef<'a, T> { - type Pretty<'b> = FrontierPrinter where Self: 'b; + type Pretty<'b> + = FrontierPrinter + where + Self: 'b; fn pretty(&self) -> Self::Pretty<'a> { FrontierPrinter(*self) diff --git a/src/timely-util/src/containers/stack.rs b/src/timely-util/src/containers/stack.rs index 29b34c22b0d09..70b6dbf2de8d5 100644 --- a/src/timely-util/src/containers/stack.rs +++ b/src/timely-util/src/containers/stack.rs @@ -122,8 +122,14 @@ impl BatchContainer for StackWrapper } impl Container for StackWrapper { - type ItemRef<'a> = &'a T where Self: 'a; - type Item<'a> = &'a T where Self: 'a; + type ItemRef<'a> + = &'a T + where + Self: 'a; + type Item<'a> + = &'a T + where + Self: 'a; fn len(&self) -> usize { match self { @@ -476,8 +482,14 @@ impl + 'static> BatchContainer for Chu } impl Container for ChunkedStack { - type ItemRef<'a> = &'a T where Self: 'a; - type Item<'a> = &'a T where Self: 'a; + type ItemRef<'a> + = &'a T + where + Self: 'a; + type Item<'a> + = &'a T + where + Self: 'a; fn len(&self) -> usize { self.len() diff --git a/src/transform/src/semijoin_idempotence.rs b/src/transform/src/semijoin_idempotence.rs index c42277b63fbab..c33f88add9635 100644 --- a/src/transform/src/semijoin_idempotence.rs +++ b/src/transform/src/semijoin_idempotence.rs @@ -308,7 +308,7 @@ fn validate_replacement( /// A `Replacement` may be offered up by any `MirRelationExpr`, meant to be `B` from above or similar, /// and indicates that the offered expression can be projected onto columns such that it then exactly equals /// a column projection of `Get{id} semijoin replacement`. - +/// /// Specifically, /// the `columns` member lists indexes `(a, b, c)` where column `b` of the offering expression corresponds to /// columns `a` in `Get{id}` and `c` in `replacement`, and for which the semijoin requires `a = c`. The values diff --git a/src/txn-wal/src/lib.rs b/src/txn-wal/src/lib.rs index 86e4daa5efde2..f68417acc3307 100644 --- a/src/txn-wal/src/lib.rs +++ b/src/txn-wal/src/lib.rs @@ -551,7 +551,7 @@ pub(crate) async fn cads( } #[cfg(test)] -pub mod tests { +mod tests { use std::collections::{BTreeMap, BTreeSet}; use std::sync::Arc; use std::sync::Mutex; diff --git a/src/walkabout/src/ir.rs b/src/walkabout/src/ir.rs index 914bd0b9070cb..2a5250a6afadc 100644 --- a/src/walkabout/src/ir.rs +++ b/src/walkabout/src/ir.rs @@ -40,7 +40,7 @@ pub enum Item { } impl Item { - pub fn fields<'a>(&'a self) -> Box + 'a> { + pub fn fields<'a>(&'a self) -> Box + 'a> { match self { Item::Struct(s) => Box::new(s.fields.iter()), Item::Enum(e) => Box::new(e.variants.iter().flat_map(|v| &v.fields)), diff --git a/src/walkabout/src/parse.rs b/src/walkabout/src/parse.rs index 2dc27c0393bb9..b1f3f0e7a11f3 100644 --- a/src/walkabout/src/parse.rs +++ b/src/walkabout/src/parse.rs @@ -20,8 +20,6 @@ use syn::{Data, DataEnum, DataStruct, DataUnion, DeriveInput, Item}; /// Returns [`DeriveInput`]s representing all struct and enum items in the /// module. This is exactly what a custom derive procedural macro would see, /// except that we can present information for all types simultaneously. -/// - pub fn parse_mod

(path: P) -> Result> where P: AsRef,