-
Notifications
You must be signed in to change notification settings - Fork 243
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not rewrite ADTs mentioned in extern blocks (#960)
Fixes #948. Fixes an issue where we would rewrite structs and their fields even though they appear in extern blocks.
- Loading branch information
Showing
6 changed files
with
186 additions
and
50 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
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
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,66 @@ | ||
extern "C" { | ||
fn foo(bar: Alias) -> Baz; | ||
} | ||
|
||
type Alias = Bar; | ||
|
||
// CHECK-DAG: br: ({{.*}}) perms = UNIQUE, flags = FIXED | ||
// CHECK-DAG: bz: ({{.*}}) perms = UNIQUE, flags = FIXED | ||
// CHECK-DAG: x: ({{.*}}) perms = UNIQUE, flags = FIXED | ||
// CHECK-DAG: y: ({{.*}}) perms = UNIQUE, flags = FIXED | ||
|
||
// CHECK-LABEL: BEGIN{{.*}}foreign.rs | ||
|
||
// CHECK-LABEL: struct Bar | ||
#[repr(C)] | ||
struct Bar { | ||
// CHECK-DAG: br: *mut i32 | ||
br: *mut i32 | ||
} | ||
|
||
// CHECK-LABEL: struct Baz | ||
#[repr(C)] | ||
struct Baz { | ||
// CHECK-DAG: bz: *mut i32 | ||
bz: *mut i32 | ||
} | ||
|
||
// we need something to get rewritten in order | ||
// to check that `Bar` and `Baz` get output | ||
// in the rewrite string | ||
fn fizz(i: *const i32) {} | ||
|
||
extern "C" { | ||
static mut s: S; | ||
} | ||
|
||
#[derive(Copy, Clone)] | ||
#[repr(C)] | ||
// CHECK-LABEL: struct S | ||
pub struct S { | ||
// CHECK-DAG: pub x: *const i32 | ||
pub x: *const i32, | ||
// CHECK-DAG: pub y: *const i32 | ||
pub y: *const i32, | ||
} | ||
|
||
// CHECK-LABEL: struct Nit | ||
#[repr(C)] | ||
struct Nit { | ||
// CHECK-DAG: x: *mut i32 | ||
x: *mut i32, | ||
// CHECK-DAG: y: *mut i32 | ||
y: *mut i32, | ||
} | ||
|
||
// CHECK-LABEL: struct Bin | ||
#[repr(C)] | ||
struct Bin { | ||
// CHECK-DAG: nit: *mut Nit | ||
nit: *mut Nit, | ||
} | ||
|
||
extern "C" { | ||
// CHECK-DAG: fn f(bin: *mut Bin) | ||
fn f(bin: *mut Bin); | ||
} |