diff --git a/.cargo/config.toml b/.cargo/config.toml deleted file mode 100644 index 0ffbcaf..0000000 --- a/.cargo/config.toml +++ /dev/null @@ -1,60 +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::from_iter_instead_of_collect", - "-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", -] diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cfc0e3e..87cc00d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,12 +13,23 @@ 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 steps: - uses: actions/checkout@v7 - uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + # 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 run: | @@ -27,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 2d19ea1..47367dd 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,14 @@ }; checks = { - # Lint the Rust workspace; warnings are 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; - cargoClippyExtraArgs = "--workspace --all-targets --all-features -- -D warnings"; + CARGO_BUILD_WARNINGS = "deny"; + 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"