Skip to content

ffi struct produces warnings on Rust 1.79.0 or +nightly #270

@sax

Description

@sax

I have a struct that I use to convert wrapped errors to strings that can be sent to Swift:

#[swift_bridge::bridge]
mod ffi {
  #[swift_bridge(swift_repr = "struct")]
  pub struct BridgedError {
    pub inner: String
  }
}

This compiles without any errors in Rust 1.77.2, but when I compile it with nightly it produces the following warning:

> cargo +nightly build -Zbuild-std --package my-bridge --target aarch64-apple-darwin

error: field `0` is never read
  --> rust/my-bridge/src/lib.rs:17:14
   |
14 | #[swift_bridge::bridge]
   | ----------------------- field in this variant
...
17 |   pub struct BridgedError {
   |              ^^^^^^^^^^^^
   |
note: the lint level is defined here
  --> rust/my-bridge/src/lib.rs:2:38
   |
2  | #![cfg_attr(feature = "strict", deny(warnings))]
   |                                      ^^^^^^^^
   = note: `#[deny(dead_code)]` implied by `#[deny(warnings)]`
help: consider changing the field to be of unit type to suppress this warning while preserving the field numbering, or remove the field
   |
17 |   pub struct () {
   |              ~~

I'm starting to play around with cross-compiling to watchOS, tvOS, and eventually visionOS, but am finding these targets only seem to build on nightly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions