Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

improper_ctypes behaves weird around function pointers #42050

Closed
retep998 opened this issue May 17, 2017 · 0 comments
Closed

improper_ctypes behaves weird around function pointers #42050

retep998 opened this issue May 17, 2017 · 0 comments
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug.

Comments

@retep998
Copy link
Member

#![deny(improper_ctypes)]

// Intentionally not #[repr(C)]
pub struct Foo;

#[repr(C)] // Expect error here that Bar is marked repr(C) but contains fn ptr referencing non-repr(C) type
pub struct Bar {
    // Alternatively expect error here that extern fn contains type that is non-repr(C).
    pub f: unsafe extern "system" fn(arg: *const Foo)
}

extern "system"{
    pub fn baz(bar: *const Bar); // Actually get error here implying Bar is not marked repr(C) even though it is
}

fn main() {

}
error: found non-foreign-function-safe member in struct marked #[repr(C)]: found struct without foreign-function-safe representation annotation in foreign module, consider adding a #[repr(C)] attribute to the type
  --> src/main.rs:12:21
   |
12 |     pub fn baz(bar: *const Bar); // Actually get error here implying Bar is not marked repr(C) even though it is
   |                     ^^^^^^^^^^
   |
note: lint level defined here
  --> src/main.rs:1:9
   |
1  | #![deny(improper_ctypes)]
   |         ^^^^^^^^^^^^^^^

error: aborting due to previous error
@retep998 retep998 added the A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. label May 17, 2017
@Mark-Simulacrum Mark-Simulacrum added the C-bug Category: This is a bug. label Jul 27, 2017
Manishearth added a commit to Manishearth/rust that referenced this issue Feb 19, 2018
…bank

Overhaul improper_ctypes output

This snowballed into a rather big set of improvements to the diagnostics of the improper_ctypes lint. See commits for details, including effects of each change on the `compile-fail/improper-ctypes.rs` test (now a UI test), which is pretty gnarly and hopefully not representative of real code, but covers a lot of different error cases.

Fixes rust-lang#42050
Manishearth added a commit to Manishearth/rust that referenced this issue Feb 23, 2018
…bank

Overhaul improper_ctypes output

This snowballed into a rather big set of improvements to the diagnostics of the improper_ctypes lint. See commits for details, including effects of each change on the `compile-fail/improper-ctypes.rs` test (now a UI test), which is pretty gnarly and hopefully not representative of real code, but covers a lot of different error cases.

Fixes rust-lang#42050
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug.
Projects
None yet
Development

No branches or pull requests

2 participants