Skip to content

improper_ctypes lint should check types referenced in C ABI function definitions #19834

Closed
@tomjakubowski

Description

@tomjakubowski

For example, this compiles with no warnings or errors:

#![feature(lang_items)]
#![crate_type="staticlib"]
#![allow(missing_copy_implementations)]
#![deny(improper_ctypes)]
#![no_std]

pub struct Blah {
    pub x: i32
}

#[no_mangle]
pub extern "C" fn yikes(b: Blah) -> i32 {
    b.x
}

#[lang = "copy"] trait Copy {}
#[lang = "sized"] trait Sized {}
#[lang = "stack_exhausted"] extern fn stack_exhausted() {}
#[lang = "eh_personality"] extern fn eh_personality() {}
#[lang = "panic_fmt"] fn panic_fmt() -> ! { loop {} }

Even though Blah lacks the #[repr(C)] attribute.

Metadata

Metadata

Assignees

Labels

A-FFIArea: Foreign function interface (FFI)A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions