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

Make data-carrying enums emit #[derive(Debug)] on the Rust side #209

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
Prev Previous commit
Next Next commit
docs: move comment
amsam0 committed Apr 7, 2023
commit 9ee0b05aa0dba99d0712c52448271a0a97e074e8
Original file line number Diff line number Diff line change
@@ -140,14 +140,15 @@ impl SwiftBridgeModule {
// User derives
let mut derive_impl_ffi_bridges = vec![];

// We currently only allow derive(Debug) on non data carrying enums in order
// to prevent a potential memory safety issue.
// https://github.com/chinedufn/swift-bridge/pull/194#discussion_r1134386788
if shared_enum.derive.debug {
// We don't want to confuse the developer if one of our variants has data and Debug isn't derived,
// so we still want to derive(Debug) on the Rust side.
// TODO: push a warning if one of our variants has data?
derives.push(quote! {::std::fmt::Debug});

// We currently only allow derive(Debug) on non data carrying enums in order
// to prevent a potential memory safety issue.
// https://github.com/chinedufn/swift-bridge/pull/194#discussion_r1134386788
if !shared_enum.has_one_or_more_variants_with_data() {
// __swift_bridge__$SomeEnum$Debug
let export_name = format!("{}$Debug", shared_enum.ffi_name_string());