Skip to content

Warning at use site for #[repr(C)] type that contains non-#[repr(C)] types #16719

Closed
@huonw

Description

@huonw
#![allow(dead_code)]

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

extern { fn whatever(x: Bar); }

fn main() {}
<anon>:7:25: 7:28 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>:7 extern { fn whatever(x: Bar); }
                                 ^~~

This could either be a warning on Bar, that Foo isn't FFI safe; or not a warning at all. (Or, at the very least, a note pointing to the x field, to help diagnose the problem.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions