Skip to content

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

Closed
@mrmonday

Description

@mrmonday
Contributor

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.

Activity

huonw

huonw commented on Aug 27, 2014

@huonw
Member

Dupe of #16719. (Thanks for filing!)

added a commit that references this issue on Mar 17, 2024

Auto merge of rust-lang#16784 - Veykril:body-invalid, r=Veykril

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

        Participants

        @mrmonday@huonw

        Issue actions

          Poor error message with #[warn(ctypes)] · Issue #16784 · rust-lang/rust