Rollup merge of #73817 - jumbatm:rename-to-clashing-extern-declarations, r=petrochenkov
Rename clashing_extern_decl to clashing_extern_declarations. Rename clashing_extern_decl to clashing_extern_declarations to bring in-line with lint naming conventions. Fixes #73802. r? @petrochenkov
This commit is contained in:
commit
8b92eecbc2
12 changed files with 91 additions and 64 deletions
|
|
@ -1,7 +1,7 @@
|
|||
// build-pass
|
||||
#![allow(dead_code)]
|
||||
#![allow(non_camel_case_types)]
|
||||
#![warn(clashing_extern_decl)]
|
||||
#![warn(clashing_extern_declarations)]
|
||||
|
||||
// pretty-expanded FIXME #23616
|
||||
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@ LL | pub fn rust_task_is_unwinding(rt: *const rust_task) -> bool;
|
|||
note: the lint level is defined here
|
||||
--> $DIR/issue-1866.rs:4:9
|
||||
|
|
||||
LL | #![warn(clashing_extern_decl)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
LL | #![warn(clashing_extern_declarations)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
= note: expected `unsafe extern "C" fn(*const usize) -> bool`
|
||||
found `unsafe extern "C" fn(*const bool) -> bool`
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// run-pass
|
||||
#![allow(dead_code)]
|
||||
#![warn(clashing_extern_decl)]
|
||||
#![warn(clashing_extern_declarations)]
|
||||
// pretty-expanded FIXME #23616
|
||||
|
||||
extern {
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@ LL | | fn malloc2(len: i32, foo: i32) -> *const u8;
|
|||
note: the lint level is defined here
|
||||
--> $DIR/issue-5791.rs:3:9
|
||||
|
|
||||
LL | #![warn(clashing_extern_decl)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
LL | #![warn(clashing_extern_declarations)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
= note: expected `unsafe extern "C" fn(i32) -> *const u8`
|
||||
found `unsafe extern "C" fn(i32, i32) -> *const u8`
|
||||
|
||||
|
|
|
|||
|
|
@ -1,17 +1,17 @@
|
|||
// check-pass
|
||||
// aux-build:external_extern_fn.rs
|
||||
#![crate_type = "lib"]
|
||||
#![warn(clashing_extern_decl)]
|
||||
#![warn(clashing_extern_declarations)]
|
||||
|
||||
extern crate external_extern_fn;
|
||||
|
||||
extern {
|
||||
extern "C" {
|
||||
fn clash(x: u8);
|
||||
fn no_clash(x: u8);
|
||||
}
|
||||
|
||||
fn redeclared_different_signature() {
|
||||
extern {
|
||||
extern "C" {
|
||||
fn clash(x: u64); //~ WARN `clash` redeclared with a different signature
|
||||
}
|
||||
|
||||
|
|
@ -22,7 +22,7 @@ fn redeclared_different_signature() {
|
|||
}
|
||||
|
||||
fn redeclared_same_signature() {
|
||||
extern {
|
||||
extern "C" {
|
||||
fn no_clash(x: u8);
|
||||
}
|
||||
unsafe {
|
||||
|
|
@ -30,12 +30,12 @@ fn redeclared_same_signature() {
|
|||
}
|
||||
}
|
||||
|
||||
extern {
|
||||
extern "C" {
|
||||
fn extern_fn(x: u64);
|
||||
}
|
||||
|
||||
fn extern_clash() {
|
||||
extern {
|
||||
extern "C" {
|
||||
fn extern_fn(x: u32); //~ WARN `extern_fn` redeclared with a different signature
|
||||
}
|
||||
unsafe {
|
||||
|
|
@ -49,7 +49,7 @@ fn extern_no_clash() {
|
|||
crate::extern_fn(123);
|
||||
}
|
||||
}
|
||||
extern {
|
||||
extern "C" {
|
||||
fn some_other_new_name(x: i16);
|
||||
|
||||
#[link_name = "extern_link_name"]
|
||||
|
|
@ -60,7 +60,7 @@ extern {
|
|||
}
|
||||
|
||||
fn link_name_clash() {
|
||||
extern {
|
||||
extern "C" {
|
||||
fn extern_link_name(x: u32);
|
||||
//~^ WARN `extern_link_name` redeclared with a different signature
|
||||
|
||||
|
|
@ -75,85 +75,112 @@ fn link_name_clash() {
|
|||
}
|
||||
|
||||
mod a {
|
||||
extern {
|
||||
extern "C" {
|
||||
fn different_mod(x: u8);
|
||||
}
|
||||
}
|
||||
mod b {
|
||||
extern {
|
||||
extern "C" {
|
||||
fn different_mod(x: u64); //~ WARN `different_mod` redeclared with a different signature
|
||||
}
|
||||
}
|
||||
|
||||
extern {
|
||||
extern "C" {
|
||||
fn variadic_decl(x: u8, ...);
|
||||
}
|
||||
|
||||
fn variadic_clash() {
|
||||
extern {
|
||||
extern "C" {
|
||||
fn variadic_decl(x: u8); //~ WARN `variadic_decl` redeclared with a different signature
|
||||
}
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
fn no_mangle_name(x: u8) { }
|
||||
fn no_mangle_name(x: u8) {}
|
||||
|
||||
extern {
|
||||
extern "C" {
|
||||
#[link_name = "unique_link_name"]
|
||||
fn link_name_specified(x: u8);
|
||||
}
|
||||
|
||||
fn tricky_no_clash() {
|
||||
extern {
|
||||
extern "C" {
|
||||
// Shouldn't warn, because the declaration above actually declares a different symbol (and
|
||||
// Rust's name resolution rules around shadowing will handle this gracefully).
|
||||
fn link_name_specified() -> u32;
|
||||
|
||||
// The case of a no_mangle name colliding with an extern decl (see #28179) is related but
|
||||
// shouldn't be reported by ClashingExternDecl, because this is an example of unmangled
|
||||
// name clash causing bad behaviour in functions with a defined body.
|
||||
// shouldn't be reported by ClashingExternDeclarations, because this is an example of
|
||||
// unmangled name clash causing bad behaviour in functions with a defined body.
|
||||
fn no_mangle_name() -> u32;
|
||||
}
|
||||
}
|
||||
|
||||
mod banana {
|
||||
mod one {
|
||||
#[repr(C)] struct Banana { weight: u32, length: u16 }
|
||||
extern "C" { fn weigh_banana(count: *const Banana) -> u64; }
|
||||
#[repr(C)]
|
||||
struct Banana {
|
||||
weight: u32,
|
||||
length: u16,
|
||||
}
|
||||
extern "C" {
|
||||
fn weigh_banana(count: *const Banana) -> u64;
|
||||
}
|
||||
}
|
||||
|
||||
mod two {
|
||||
#[repr(C)] struct Banana { weight: u32, length: u16 } // note: distinct type
|
||||
// This should not trigger the lint because two::Banana is structurally equivalent to
|
||||
// one::Banana.
|
||||
extern "C" { fn weigh_banana(count: *const Banana) -> u64; }
|
||||
#[repr(C)]
|
||||
struct Banana {
|
||||
weight: u32,
|
||||
length: u16,
|
||||
} // note: distinct type
|
||||
extern "C" {
|
||||
// This should not trigger the lint because two::Banana is structurally equivalent to
|
||||
// one::Banana.
|
||||
fn weigh_banana(count: *const Banana) -> u64;
|
||||
}
|
||||
}
|
||||
|
||||
mod three {
|
||||
// This _should_ trigger the lint, because repr(packed) should generate a struct that has a
|
||||
// different layout.
|
||||
#[repr(packed)] struct Banana { weight: u32, length: u16 }
|
||||
#[repr(packed)]
|
||||
struct Banana {
|
||||
weight: u32,
|
||||
length: u16,
|
||||
}
|
||||
#[allow(improper_ctypes)]
|
||||
extern "C" { fn weigh_banana(count: *const Banana) -> u64; }
|
||||
//~^ WARN `weigh_banana` redeclared with a different signature
|
||||
extern "C" {
|
||||
fn weigh_banana(count: *const Banana) -> u64;
|
||||
//~^ WARN `weigh_banana` redeclared with a different signature
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mod sameish_members {
|
||||
mod a {
|
||||
#[repr(C)]
|
||||
struct Point { x: i16, y: i16 }
|
||||
struct Point {
|
||||
x: i16,
|
||||
y: i16,
|
||||
}
|
||||
|
||||
extern "C" { fn draw_point(p: Point); }
|
||||
extern "C" {
|
||||
fn draw_point(p: Point);
|
||||
}
|
||||
}
|
||||
mod b {
|
||||
#[repr(C)]
|
||||
struct Point { coordinates: [i16; 2] }
|
||||
struct Point {
|
||||
coordinates: [i16; 2],
|
||||
}
|
||||
|
||||
// It's possible we are overconservative for this case, as accessing the elements of the
|
||||
// coordinates array might end up correctly accessing `.x` and `.y`. However, this may not
|
||||
// always be the case, for every architecture and situation. This is also a really odd
|
||||
// thing to do anyway.
|
||||
extern "C" { fn draw_point(p: Point); } //~ WARN `draw_point` redeclared with a different
|
||||
extern "C" {
|
||||
fn draw_point(p: Point); //~ WARN `draw_point` redeclared with a different
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@ LL | fn clash(x: u64);
|
|||
note: the lint level is defined here
|
||||
--> $DIR/clashing-extern-fn.rs:4:9
|
||||
|
|
||||
LL | #![warn(clashing_extern_decl)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
LL | #![warn(clashing_extern_declarations)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
= note: expected `unsafe extern "C" fn(u8)`
|
||||
found `unsafe extern "C" fn(u64)`
|
||||
|
||||
|
|
@ -94,25 +94,25 @@ LL | fn variadic_decl(x: u8);
|
|||
found `unsafe extern "C" fn(u8)`
|
||||
|
||||
warning: `weigh_banana` redeclared with a different signature
|
||||
--> $DIR/clashing-extern-fn.rs:137:22
|
||||
--> $DIR/clashing-extern-fn.rs:154:13
|
||||
|
|
||||
LL | extern "C" { fn weigh_banana(count: *const Banana) -> u64; }
|
||||
| --------------------------------------------- `weigh_banana` previously declared here
|
||||
LL | fn weigh_banana(count: *const Banana) -> u64;
|
||||
| --------------------------------------------- `weigh_banana` previously declared here
|
||||
...
|
||||
LL | extern "C" { fn weigh_banana(count: *const Banana) -> u64; }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this signature doesn't match the previous declaration
|
||||
LL | fn weigh_banana(count: *const Banana) -> u64;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this signature doesn't match the previous declaration
|
||||
|
|
||||
= note: expected `unsafe extern "C" fn(*const banana::one::Banana) -> u64`
|
||||
found `unsafe extern "C" fn(*const banana::three::Banana) -> u64`
|
||||
|
||||
warning: `draw_point` redeclared with a different signature
|
||||
--> $DIR/clashing-extern-fn.rs:157:22
|
||||
--> $DIR/clashing-extern-fn.rs:183:13
|
||||
|
|
||||
LL | extern "C" { fn draw_point(p: Point); }
|
||||
| ------------------------ `draw_point` previously declared here
|
||||
LL | fn draw_point(p: Point);
|
||||
| ------------------------ `draw_point` previously declared here
|
||||
...
|
||||
LL | extern "C" { fn draw_point(p: Point); }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ this signature doesn't match the previous declaration
|
||||
LL | fn draw_point(p: Point);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ this signature doesn't match the previous declaration
|
||||
|
|
||||
= note: expected `unsafe extern "C" fn(sameish_members::a::Point)`
|
||||
found `unsafe extern "C" fn(sameish_members::b::Point)`
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#![allow(unused_variables)]
|
||||
#![allow(non_camel_case_types)]
|
||||
#![allow(clashing_extern_decl)]
|
||||
#![allow(clashing_extern_declarations)]
|
||||
#![deny(dead_code)]
|
||||
|
||||
#![crate_type="lib"]
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#![allow(clashing_extern_decl)]
|
||||
#![allow(clashing_extern_declarations)]
|
||||
// check-pass
|
||||
|
||||
// In this test we check that the parser accepts an ABI string when it
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue