Skip to content

Poor error message with #[warn(ctypes)] #16784

Closed
@mrmonday

Description

@mrmonday

The following code:

pub struct Bar;
#[repr(C)]
pub struct Foo {
    bar: Bar
}

extern {
    pub fn extern_func(foo: Foo);
}

fn main() {
}

(Playpen: http://is.gd/ANqwz9)

Gives the error:

<anon>:8:29: 8:32 warning: found type without foreign-function-safe
                                             representation annotation in foreign module, consider adding a #[repr(...)] attribute to the type, #[warn(ctypes)] on by default
<anon>:8     pub fn extern_func(foo: Foo);
                                     ^~~

Despite Foo being marked as #[repr(C)]. This should either:

  • Include a note specifying which part of Foo is causing it to not be repr(C), or
  • Cause an error, since Foo is not repr(C), despite being marked as such.

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