Skip to content

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

Closed

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.)

Activity

  1. o11c commented on Aug 24, 2014

    @o11c

    Significantly, this occurs even if the struct contains only a pointer-to-non-repr-C-struct

  2. frewsxcv commented on Aug 20, 2015

    @frewsxcv
    Contributor

    Triage comment: the warning has not changed

    playpen link

  3. steveklabnik commented on Feb 11, 2016

    @steveklabnik
    Contributor

    Since new lints have a big impact on users of rustc, the policy is that they should go through the RFC process like other user-facing changes. As such, I'm going to give this one a close, but if anyone comes across this ticket and wants this lint, consider adding it to clippy and/or writing up an RFC. Thanks!

  4. added a commit that references this issue on Mar 10, 2024
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

    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