From 301dd8a6c7eb52009faedf5caa5009947da52464 Mon Sep 17 00:00:00 2001 From: Benedikt Reinartz Date: Mon, 21 Sep 2026 18:15:40 +0200 Subject: [PATCH 1/3] Nightly Rust warns on non-kebap-case binary names --- rustler/otp_headers/codegen/Cargo.toml | 2 +- rustler_tests/native/binary_example/Cargo.toml | 2 +- rustler_tests/native/rustler_test/Cargo.toml | 2 +- rustler_tests/test/binary_example_test.exs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/rustler/otp_headers/codegen/Cargo.toml b/rustler/otp_headers/codegen/Cargo.toml index e868518d4..67a9ea86b 100644 --- a/rustler/otp_headers/codegen/Cargo.toml +++ b/rustler/otp_headers/codegen/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "nif_api_codegen" +name = "nif-api-codegen" version = "0.1.0" edition = "2024" publish = false diff --git a/rustler_tests/native/binary_example/Cargo.toml b/rustler_tests/native/binary_example/Cargo.toml index bca72e47d..8c5a8c6fc 100644 --- a/rustler_tests/native/binary_example/Cargo.toml +++ b/rustler_tests/native/binary_example/Cargo.toml @@ -5,5 +5,5 @@ authors = [] edition = "2021" [[bin]] -name = "binary_example" +name = "binary-example" path = "src/main.rs" diff --git a/rustler_tests/native/rustler_test/Cargo.toml b/rustler_tests/native/rustler_test/Cargo.toml index cb5c02e20..275f7e00e 100644 --- a/rustler_tests/native/rustler_test/Cargo.toml +++ b/rustler_tests/native/rustler_test/Cargo.toml @@ -10,7 +10,7 @@ path = "src/lib.rs" crate-type = ["cdylib"] [[bin]] -name = "hello_rust" +name = "hello-rust" path = "src/main.rs" [features] diff --git a/rustler_tests/test/binary_example_test.exs b/rustler_tests/test/binary_example_test.exs index 34c08c2d2..0a2655124 100644 --- a/rustler_tests/test/binary_example_test.exs +++ b/rustler_tests/test/binary_example_test.exs @@ -2,7 +2,7 @@ defmodule BinaryExampleTest do use ExUnit.Case test "binary is compiled" do - bins = ~w(binary_example hello_rust) + bins = ~w(binary-example hello-rust) for bin <- bins do assert_exists(bin) From 5ebcaeabfe2d044d4303369b4860bad05d670871 Mon Sep 17 00:00:00 2001 From: Benedikt Reinartz Date: Mon, 21 Sep 2026 18:16:33 +0200 Subject: [PATCH 2/3] Drop unused dependency from rustler_codegen --- rustler_codegen/Cargo.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/rustler_codegen/Cargo.toml b/rustler_codegen/Cargo.toml index efaf1e506..bd962e85c 100644 --- a/rustler_codegen/Cargo.toml +++ b/rustler_codegen/Cargo.toml @@ -17,7 +17,6 @@ syn = { version = "3.0", features = ["full", "extra-traits"] } quote = "1.0" heck = "0.5" proc-macro2 = "1.0" -inventory = "0.3" [dev-dependencies] trybuild = "1.0" From 78b53d3c70a1f46aea9afed23594c88cbe730a9d Mon Sep 17 00:00:00 2001 From: Benedikt Reinartz Date: Mon, 21 Sep 2026 18:17:02 +0200 Subject: [PATCH 3/3] The min_value()/max_value() functions are replaced in favour of MIN/MAX --- rustler/src/sys/types.rs | 3 +- .../native/rustler_serde_test/src/test.rs | 50 +++++++++---------- rustler_tests/test/primitives_test.exs | 8 +-- 3 files changed, 30 insertions(+), 31 deletions(-) diff --git a/rustler/src/sys/types.rs b/rustler/src/sys/types.rs index 8d74235d9..7747a0fe0 100644 --- a/rustler/src/sys/types.rs +++ b/rustler/src/sys/types.rs @@ -260,8 +260,7 @@ pub enum ErlNifMapIteratorEntry { pub type ErlNifTime = i64; /// Error return value for `enif_monotonic_time()`, `enif_time_offset()`, and `enif_convert_time_unit()`. -pub const ERL_NIF_TIME_ERROR: i64 = -9_223_372_036_854_775_808; -//const ERL_NIF_TIME_ERROR:i64 = i64::min_value(); "error: const fn's not yet stable" +pub const ERL_NIF_TIME_ERROR: i64 = i64::MIN; /// See [ErlNifTimeUnit](http://www.erlang.org/doc/man/erl_nif.html#ErlNifTimeUnit) in the Erlang docs. #[derive(Copy, Clone)] diff --git a/rustler_tests/native/rustler_serde_test/src/test.rs b/rustler_tests/native/rustler_serde_test/src/test.rs index 2494caae9..52faca37d 100644 --- a/rustler_tests/native/rustler_serde_test/src/test.rs +++ b/rustler_tests/native/rustler_serde_test/src/test.rs @@ -32,33 +32,33 @@ pub fn test<'a>( "false" => run_test!(false), // Signed Integers - "i8 (min)" => run_test!(i8::min_value()), + "i8 (min)" => run_test!(i8::MIN), "i8 (0)" => run_test!(0_i8), - "i8 (max)" => run_test!(i8::max_value()), - "i16 (min)" => run_test!(i16::min_value()), + "i8 (max)" => run_test!(i8::MAX), + "i16 (min)" => run_test!(i16::MIN), "i16 (0)" => run_test!(0_i16), - "i16 (max)" => run_test!(i16::max_value()), - "i32 (min)" => run_test!(i32::min_value()), + "i16 (max)" => run_test!(i16::MAX), + "i32 (min)" => run_test!(i32::MIN), "i32 (0)" => run_test!(0_i32), - "i32 (max)" => run_test!(i32::max_value()), - "i64 (min)" => run_test!(i64::min_value()), + "i32 (max)" => run_test!(i32::MAX), + "i64 (min)" => run_test!(i64::MIN), "i64 (0)" => run_test!(0_i64), - "i64 (max)" => run_test!(i64::max_value()), - "i128 (min)" => run_test!(i128::min_value()), + "i64 (max)" => run_test!(i64::MAX), + "i128 (min)" => run_test!(i128::MIN), "i128 (0)" => run_test!(0_i128), - "i128 (max)" => run_test!(i128::max_value()), + "i128 (max)" => run_test!(i128::MAX), // Unsigned Integers - "u8 (min)" => run_test!(u8::min_value()), - "u8 (max)" => run_test!(u8::max_value()), - "u16 (min)" => run_test!(u16::min_value()), - "u16 (max)" => run_test!(u16::max_value()), - "u32 (min)" => run_test!(u32::min_value()), - "u32 (max)" => run_test!(u32::max_value()), - "u64 (min)" => run_test!(u64::min_value()), - "u64 (max)" => run_test!(u64::max_value()), - "u128 (min)" => run_test!(u128::min_value()), - "u128 (max)" => run_test!(u128::max_value()), + "u8 (min)" => run_test!(u8::MIN), + "u8 (max)" => run_test!(u8::MAX), + "u16 (min)" => run_test!(u16::MIN), + "u16 (max)" => run_test!(u16::MAX), + "u32 (min)" => run_test!(u32::MIN), + "u32 (max)" => run_test!(u32::MAX), + "u64 (min)" => run_test!(u64::MIN), + "u64 (max)" => run_test!(u64::MAX), + "u128 (min)" => run_test!(u128::MIN), + "u128 (max)" => run_test!(u128::MAX), // Float32 "f32 (0)" => run_test!(f32::from_bits(0x0000_0000)), @@ -99,10 +99,10 @@ pub fn test<'a>( "unit variant" => run_test!(UnitVariant::A), // Newtype Types - "newtype struct" => run_test!(NewtypeStruct(u8::max_value())), - "newtype variant" => run_test!(NewtypeVariant::N(u8::max_value())), + "newtype struct" => run_test!(NewtypeStruct(u8::MAX)), + "newtype variant" => run_test!(NewtypeVariant::N(u8::MAX)), "newtype variant (ok tuple)" => { - let ok: Result = Ok(u8::max_value()); + let ok: Result = Ok(u8::MAX); run_test!(ok) } "newtype variant (error tuple)" => { @@ -115,8 +115,8 @@ pub fn test<'a>( "sequences (primitive)" => run_test!(vec!["hello", "world"]), "sequences (byte)" => run_test!(vec![2, 3, 5, 7, 11, 13]), "sequences (complex)" => { - let a = NewtypeStruct(u8::min_value()); - let b = NewtypeStruct(u8::max_value()); + let a = NewtypeStruct(u8::MIN); + let b = NewtypeStruct(u8::MAX); run_test!(vec![a, b]) } diff --git a/rustler_tests/test/primitives_test.exs b/rustler_tests/test/primitives_test.exs index 0b1a97c7e..ba69ff24d 100644 --- a/rustler_tests/test/primitives_test.exs +++ b/rustler_tests/test/primitives_test.exs @@ -52,15 +52,15 @@ defmodule RustlerTest.PrimitivesTest do assert i == RustlerTest.echo_i128(i) assert -i == RustlerTest.echo_i128(-i) - # i128::min_value() + # i128::MIN i = -170_141_183_460_469_231_731_687_303_715_884_105_728 assert i == RustlerTest.echo_i128(i) - # i128::max_value() + # i128::MAX i = 170_141_183_460_469_231_731_687_303_715_884_105_727 assert i == RustlerTest.echo_i128(i) - # u128::max_value() + # u128::MAX i = 0xFFFF_FFFF_FFFF_FFFF_FFFF_FFFF_FFFF_FFFF assert_raise ArgumentError, fn -> RustlerTest.echo_i128(:non_int) end assert_raise ArgumentError, fn -> RustlerTest.echo_i128(123.45) end @@ -80,7 +80,7 @@ defmodule RustlerTest.PrimitivesTest do i = 1 <<< 127 assert i == RustlerTest.echo_u128(i) - # u128::max_value() + # u128::MAX i = 0xFFFF_FFFF_FFFF_FFFF_FFFF_FFFF_FFFF_FFFF assert i == RustlerTest.echo_u128(i)