-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make clashing_extern_declarations considering generic args for ADT field
fixes #130851
- Loading branch information
Showing
3 changed files
with
76 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
//@ build-pass | ||
#![warn(clashing_extern_declarations)] | ||
|
||
#[repr(C)] | ||
pub struct A { | ||
a: [u16; 4], | ||
} | ||
#[repr(C)] | ||
pub struct B { | ||
b: [u32; 4], | ||
} | ||
|
||
pub mod a { | ||
extern "C" { | ||
pub fn foo(_: super::A); | ||
} | ||
} | ||
pub mod b { | ||
extern "C" { | ||
pub fn foo(_: super::B); | ||
//~^ WARN `foo` redeclared with a different signature | ||
} | ||
} | ||
|
||
#[repr(C)] | ||
pub struct G<T> { | ||
g: [T; 4], | ||
} | ||
|
||
pub mod x { | ||
extern "C" { | ||
pub fn bar(_: super::G<u16>); | ||
} | ||
} | ||
pub mod y { | ||
extern "C" { | ||
pub fn bar(_: super::G<u32>); | ||
//~^ WARN `bar` redeclared with a different signature | ||
} | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
warning: `foo` redeclared with a different signature | ||
--> $DIR/clashing-extern-fn-issue-130851.rs:20:9 | ||
| | ||
LL | pub fn foo(_: super::A); | ||
| ------------------------ `foo` previously declared here | ||
... | ||
LL | pub fn foo(_: super::B); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^ this signature doesn't match the previous declaration | ||
| | ||
= note: expected `unsafe extern "C" fn(A)` | ||
found `unsafe extern "C" fn(B)` | ||
note: the lint level is defined here | ||
--> $DIR/clashing-extern-fn-issue-130851.rs:2:9 | ||
| | ||
LL | #![warn(clashing_extern_declarations)] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
warning: `bar` redeclared with a different signature | ||
--> $DIR/clashing-extern-fn-issue-130851.rs:37:9 | ||
| | ||
LL | pub fn bar(_: super::G<u16>); | ||
| ----------------------------- `bar` previously declared here | ||
... | ||
LL | pub fn bar(_: super::G<u32>); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this signature doesn't match the previous declaration | ||
| | ||
= note: expected `unsafe extern "C" fn(G<u16>)` | ||
found `unsafe extern "C" fn(G<u32>)` | ||
|
||
warning: 2 warnings emitted | ||
|