Skip to content

transpile: typedef of anonymous types are lost if name is not used #1738

@Rua

Description

@Rua
typedef enum { A } E;

int foo(void) {
    return A;
}
#![allow(
    dead_code,
    non_camel_case_types,
    non_snake_case,
    non_upper_case_globals,
    unused_assignments,
    unused_mut
)]
pub type C2Rust_Unnamed = ::core::ffi::c_uint;
pub const A: C2Rust_Unnamed = 0;
#[no_mangle]
pub unsafe extern "C" fn foo() -> ::core::ffi::c_int {
    return A as ::core::ffi::c_int;
}

Rather than keeping the name E, the typedef's name is being lost here, and the enum is instead being translated as a regular anonymous enum. Seems likely related to the code that prunes unwanted declarations? It is probably eliminating the typedef because it's not used anywhere.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions