Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Nif* macros requiring an encoder #676

Merged
merged 2 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion rustler_codegen/src/ex_struct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ pub fn transcoder_decorator(ast: &syn::DeriveInput, add_exception: bool) -> Toke

#decoder

#[allow(clippy::needless_borrow)]
#encoder
};

Expand Down
1 change: 0 additions & 1 deletion rustler_codegen/src/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ pub fn transcoder_decorator(ast: &syn::DeriveInput) -> TokenStream {

#decoder

#[allow(clippy::needless_borrow)]
#encoder
};

Expand Down
33 changes: 33 additions & 0 deletions rustler_tests/native/rustler_test/src/test_codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,39 @@ pub fn tuplestruct_record_echo(tuplestruct: TupleStructRecord) -> TupleStructRec
tuplestruct
}

mod check_if_only_decode_is_enough {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is also a test for encode, decode further above in this file, maybe that test should reference the mod here or so..

// Regression test, failed to compile
// TODO: Move this test to the trybuild tests in rustler_codegen

use rustler::{NifMap, NifRecord, NifStruct, NifTaggedEnum, NifTuple, NifUnitEnum};

#[derive(NifMap)]
#[rustler(decode)]
struct TestMap {}

#[derive(NifRecord)]
#[tag = "test_rec"]
#[rustler(decode)]
struct TestRec {}

#[derive(NifTuple)]
#[rustler(decode)]
struct TestTuple {}

#[derive(NifStruct)]
#[module = "TestStruct"]
#[rustler(decode)]
struct TestStruct {}

#[derive(NifUnitEnum)]
#[rustler(decode)]
enum TestUnitEnum {}

#[derive(NifTaggedEnum)]
#[rustler(decode)]
enum TestTaggedEnum {}
}

pub mod reserved_keywords {
use rustler::{NifMap, NifRecord, NifStruct, NifTuple, NifUntaggedEnum};

Expand Down
Loading