From f55abe5995c5580a5c41094f2c7c2de40c31b0a7 Mon Sep 17 00:00:00 2001 From: samuelburnham <45365069+samuelburnham@users.noreply.github.com> Date: Sat, 22 Aug 2026 14:23:01 -0400 Subject: [PATCH 1/2] chore: Update Rust to 1.98 Repin the fenix toolchain hash in flake.nix; without it every nix build fails on a hash mismatch against the 1.92 pin. clippy::from_iter_instead_of_collect was removed upstream, so the xclippy alias emitted renamed_and_removed_lints. Under the CI action's default RUSTFLAGS=-D warnings that was a hard error, not a warning. Replace both warning-denial mechanisms with build.warnings, stabilized in 1.97. It applies to local packages only, so a warning in a dependency no longer fails the build, and it stays out of RUSTFLAGS, so it no longer invalidates the dependency build cache. --- .cargo/config.toml | 6 +++++- .github/workflows/ci.yml | 5 +++++ flake.nix | 7 ++++--- rust-toolchain.toml | 2 +- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index 0ffbcaf..5b58f9a 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -27,7 +27,6 @@ xclippy = [ "-Wclippy::fallible_impl_from", "-Wclippy::filter_map_next", "-Wclippy::flat_map_option", - "-Wclippy::from_iter_instead_of_collect", "-Wclippy::implicit_clone", "-Wclippy::inefficient_to_string", "-Wclippy::invalid_upcast_comparisons", @@ -58,3 +57,8 @@ xclippy = [ "-Wtrivial_numeric_casts", "-Wunused_qualifications", ] + +[build] +# Deny warnings from local packages; replaces RUSTFLAGS="-D warnings" in CI +# (which invalidates the build cache and also applies to dependencies). +warnings = "deny" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cfc0e3e..e2c380b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,6 +19,11 @@ jobs: steps: - uses: actions/checkout@v7 - uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + # Warning handling lives in `.cargo/config.toml` via `build.warnings`, + # which applies to local packages only. The action defaults to + # `-D warnings`, which also denies warnings from dependencies. + rustflags: "" # Simpler to install Lean than to use lean-action for only this purpose. - name: Install Lean run: | diff --git a/flake.nix b/flake.nix index 2d19ea1..6a96851 100644 --- a/flake.nix +++ b/flake.nix @@ -60,7 +60,7 @@ # Pins the Rust toolchain rustToolchain = fenix.packages.${system}.fromToolchainFile { file = ./rust-toolchain.toml; - sha256 = "sha256-sqSWJDUxc+zaz1nBWMAJKTAGBuGWP25GCftIOlCEAtA="; + sha256 = "sha256-P30Tm3O7vQAE725YtDCDHGjNrSsfZO4us11UwJGZSJo="; }; # Rust package @@ -127,12 +127,13 @@ }; checks = { - # Lint the Rust workspace; warnings are errors. + # Lint the Rust workspace; `build.warnings` in .cargo/config.toml + # promotes warnings to errors. clippy = craneLib.cargoClippy ( craneArgs // { inherit cargoArtifacts; - cargoClippyExtraArgs = "--workspace --all-targets --all-features -- -D warnings"; + cargoClippyExtraArgs = "--workspace --all-targets --all-features"; } ); # Build and run the Lean FFI test suite as a flake check. diff --git a/rust-toolchain.toml b/rust-toolchain.toml index a5b578d..23de054 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,4 +1,4 @@ [toolchain] # The default profile includes rustc, rust-std, cargo, rust-docs, rustfmt and clippy. profile = "default" -channel = "1.92" +channel = "1.98" From 987036eee7b5c40079d93dbbc4769e875cb2eee6 Mon Sep 17 00:00:00 2001 From: samuelburnham <45365069+samuelburnham@users.noreply.github.com> Date: Sat, 22 Aug 2026 14:30:39 -0400 Subject: [PATCH 2/2] chore: Move lint config from the xclippy alias into Cargo.toml The alias existed because clippy had no project-wide lint configuration. Cargo's [lints] tables cover that now, so the lint set moves to [workspace.lints] and both members inherit it. CI lint jobs call cargo clippy directly with the full argument list. Dropping the alias removes .cargo/config.toml entirely, so build.warnings moves to CARGO_BUILD_WARNINGS in the CI workflow and the flake's clippy check. Local builds warn rather than fail. Because the lints now travel with the manifest instead of one alias, they apply to every cargo invocation, including the flake's clippy check, which previously ran with only clippy's defaults. --- .cargo/config.toml | 64 ---------------------------------------- .github/workflows/ci.yml | 14 ++++++--- Cargo.toml | 58 ++++++++++++++++++++++++++++++++++++ bignat/Cargo.toml | 5 +++- flake.nix | 5 ++-- 5 files changed, 75 insertions(+), 71 deletions(-) delete mode 100644 .cargo/config.toml diff --git a/.cargo/config.toml b/.cargo/config.toml deleted file mode 100644 index 5b58f9a..0000000 --- a/.cargo/config.toml +++ /dev/null @@ -1,64 +0,0 @@ -[alias] -# Collection of project wide clippy lints. This is done via an alias because -# clippy doesn't currently allow for specifying project-wide lints in a -# configuration file. This is a similar workaround to the ones presented here: -# -xclippy = [ - "clippy", "--workspace", "--all-targets", "--all-features", "--", - "-Wclippy::all", - #"-Wclippy::cast_lossless", # TODO: Fix or remove. Causes issues with Aiur macros - "-Wclippy::cast_possible_truncation", - "-Wclippy::cast_precision_loss", - "-Wclippy::cast_sign_loss", - "-Wclippy::cast_possible_wrap", - "-Wclippy::cast_sign_loss", - "-Wclippy::char_lit_as_u8", - "-Wclippy::fn_to_numeric_cast", - "-Wclippy::fn_to_numeric_cast_with_truncation", - "-Wclippy::ptr_as_ptr", - "-Wclippy::unnecessary_cast", - "-Winvalid_reference_casting", - "-Wclippy::checked_conversions", - "-Wclippy::dbg_macro", - "-Wclippy::disallowed_methods", - "-Wclippy::derive_partial_eq_without_eq", - "-Wclippy::enum_glob_use", - "-Wclippy::explicit_into_iter_loop", - "-Wclippy::fallible_impl_from", - "-Wclippy::filter_map_next", - "-Wclippy::flat_map_option", - "-Wclippy::implicit_clone", - "-Wclippy::inefficient_to_string", - "-Wclippy::invalid_upcast_comparisons", - "-Wclippy::large_stack_arrays", - "-Wclippy::large_types_passed_by_value", - "-Wclippy::macro_use_imports", - "-Wclippy::manual_assert", - "-Wclippy::manual_ok_or", - "-Wclippy::map_err_ignore", - "-Wclippy::map_flatten", - "-Wclippy::map_unwrap_or", - "-Wclippy::match_same_arms", - "-Wclippy::match_wild_err_arm", - "-Wclippy::needless_borrow", - "-Wclippy::needless_continue", - "-Wclippy::needless_for_each", - "-Wclippy::needless_pass_by_value", - "-Wclippy::option_option", - "-Wclippy::same_functions_in_if_condition", - "-Wclippy::trait_duplication_in_bounds", - "-Wclippy::unnecessary_wraps", - "-Wclippy::unnested_or_patterns", - "-Wnonstandard_style", - "-Wrust_2018_idioms", - "-Wtrivial_numeric_casts", - "-Wunused_lifetimes", - "-Wunreachable_pub", - "-Wtrivial_numeric_casts", - "-Wunused_qualifications", -] - -[build] -# Deny warnings from local packages; replaces RUSTFLAGS="-D warnings" in CI -# (which invalidates the build cache and also applies to dependencies). -warnings = "deny" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e2c380b..87cc00d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,6 +13,12 @@ concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} cancel-in-progress: true +# Fail every cargo invocation on warnings from workspace-local packages +# (cargo's build.warnings, stable since 1.97). CI-only: local builds +# still just warn. +env: + CARGO_BUILD_WARNINGS: deny + jobs: test: runs-on: ubuntu-latest @@ -20,9 +26,9 @@ jobs: - uses: actions/checkout@v7 - uses: actions-rust-lang/setup-rust-toolchain@v1 with: - # Warning handling lives in `.cargo/config.toml` via `build.warnings`, - # which applies to local packages only. The action defaults to - # `-D warnings`, which also denies warnings from dependencies. + # Warnings are handled by CARGO_BUILD_WARNINGS above, which applies + # to local packages only. The action defaults to `-D warnings`, + # which also denies warnings from dependencies. rustflags: "" # Simpler to install Lean than to use lean-action for only this purpose. - name: Install Lean @@ -32,7 +38,7 @@ jobs: - name: Check Rustfmt code style uses: actions-rust-lang/rustfmt@v1 - name: Check clippy warnings - run: cargo xclippy + run: cargo clippy --workspace --all-targets --all-features - name: Check *everything* compiles run: cargo check --workspace --all-targets --all-features - name: Run workspace tests diff --git a/Cargo.toml b/Cargo.toml index ea0ded8..6cc514e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,6 +9,61 @@ license = "MIT OR Apache-2.0" [workspace.dependencies] num-bigint = "0.4.6" +[workspace.lints.rust] +invalid_reference_casting = "warn" +nonstandard_style = { level = "warn", priority = -1 } +rust_2018_idioms = { level = "warn", priority = -1 } +trivial_numeric_casts = "warn" +unreachable_pub = "warn" +unused_lifetimes = "warn" +unused_qualifications = "warn" + +[workspace.lints.clippy] +all = { level = "warn", priority = -1 } +# Casts +#cast_lossless = "warn" # TODO: Fix or remove. Causes issues with Aiur macros +cast_possible_truncation = "warn" +cast_possible_wrap = "warn" +cast_precision_loss = "warn" +cast_sign_loss = "warn" +char_lit_as_u8 = "warn" +checked_conversions = "warn" +fn_to_numeric_cast = "warn" +fn_to_numeric_cast_with_truncation = "warn" +invalid_upcast_comparisons = "warn" +ptr_as_ptr = "warn" +unnecessary_cast = "warn" +# Everything else +dbg_macro = "warn" +derive_partial_eq_without_eq = "warn" +disallowed_methods = "warn" +enum_glob_use = "warn" +explicit_into_iter_loop = "warn" +fallible_impl_from = "warn" +filter_map_next = "warn" +flat_map_option = "warn" +implicit_clone = "warn" +inefficient_to_string = "warn" +large_stack_arrays = "warn" +large_types_passed_by_value = "warn" +macro_use_imports = "warn" +manual_assert = "warn" +manual_ok_or = "warn" +map_err_ignore = "warn" +map_flatten = "warn" +map_unwrap_or = "warn" +match_same_arms = "warn" +match_wild_err_arm = "warn" +needless_borrow = "warn" +needless_continue = "warn" +needless_for_each = "warn" +needless_pass_by_value = "warn" +option_option = "warn" +same_functions_in_if_condition = "warn" +trait_duplication_in_bounds = "warn" +unnecessary_wraps = "warn" +unnested_or_patterns = "warn" + [package] name = "lean-ffi" version.workspace = true @@ -29,6 +84,9 @@ num-bigint.workspace = true bindgen = "0.72" cc = "1" +[lints] +workspace = true + [profile.dev] panic = "abort" diff --git a/bignat/Cargo.toml b/bignat/Cargo.toml index a1d479c..cdfabb7 100644 --- a/bignat/Cargo.toml +++ b/bignat/Cargo.toml @@ -5,4 +5,7 @@ edition.workspace = true license.workspace = true [dependencies] -num-bigint.workspace = true \ No newline at end of file +num-bigint.workspace = true + +[lints] +workspace = true diff --git a/flake.nix b/flake.nix index 6a96851..47367dd 100644 --- a/flake.nix +++ b/flake.nix @@ -127,12 +127,13 @@ }; checks = { - # Lint the Rust workspace; `build.warnings` in .cargo/config.toml - # promotes warnings to errors. + # Lint the Rust workspace; the lint set lives in Cargo.toml and + # CARGO_BUILD_WARNINGS promotes local-package warnings to errors. clippy = craneLib.cargoClippy ( craneArgs // { inherit cargoArtifacts; + CARGO_BUILD_WARNINGS = "deny"; cargoClippyExtraArgs = "--workspace --all-targets --all-features"; } );