Closed
Description
The clashing_extern_declarations
lint currently incorrectly misses clashing extern fn declarations if they clash on a struct with same-sized members.
In this example here:
#![crate_type = "lib"]
#![allow(unused)]
mod a {
#[repr(C)]
struct Point3 {
x: f32,
y: f32,
z: f32,
}
extern "C" { fn origin() -> Point3; }
}
mod b {
#[repr(C)]
struct Point3 {
x: i32,
y: i32,
z: i32, // NOTE: Incorrectly redeclared as i32
}
extern "C" { fn origin() -> Point3; }
}
The declaration of origin
should clash, because a::Point3
and b::Point3
have members of different type. However, the lint currently misses that the return type of origin
is inconsistently declared, even though ani32
and f32
clash is warned on its own:
mod a {
extern "C" { fn clash(x: i32); }
}
mod b {
extern "C" { fn clash(x: f32); } //~ WARN `clash` redeclared with a different signature
}
Note that this false negative only occurs for same-sized members -- the lint correctly fires for members of different sizes:
mod a {
#[repr(C)]
struct Point3 {
x: f32,
y: f32,
z: f32,
}
extern "C" { fn origin() -> Point3; }
}
mod b {
#[repr(C)]
struct Point3 {
x: i64,
y: i64,
z: i64,
}
extern "C" { fn origin() -> Point3; }
//~^ WARN `origin` redeclared with a different signature
}
This issue has been assigned to @jumbatm via this comment.