Skip to content

Multiple types that are both Copy and Sendable creates a swift file missing a newline #335

@aDifferentJT

Description

@aDifferentJT

The rust source file:

#[derive(Clone, Copy)]
struct T1(u32);

#[derive(Clone, Copy)]
struct T2(u32);

#[swift_bridge::bridge]
mod ffi {
    extern "Rust" {
        #[swift_bridge(Copy(4), Sendable)]
        type T1;
        #[swift_bridge(Copy(4), Sendable)]
        type T2;
    }
}

generates the following swift file:

public struct T2 {
    fileprivate var bytes: __swift_bridge__$T2

    func intoFfiRepr() -> __swift_bridge__$T2 {
        bytes
    }
}
extension __swift_bridge__$T2 {
    func intoSwiftRepr() -> T2 {
        T2(bytes: self)
    }
}

extension T2: @unchecked Sendable {}public struct T1 {
    fileprivate var bytes: __swift_bridge__$T1

    func intoFfiRepr() -> __swift_bridge__$T1 {
        bytes
    }
}
extension __swift_bridge__$T1 {
    func intoSwiftRepr() -> T1 {
        T1(bytes: self)
    }
}

extension T1: @unchecked Sendable {}

which fails to parse because of the missing newline in:

extension T2: @unchecked Sendable {}public struct T1 {

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