-
Notifications
You must be signed in to change notification settings - Fork 243
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Do not rewrite ADTs mentioned in extern blocks #960
Merged
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
b90b646
Addresses #948
aneksteind aa23b35
use extern "C" in test case
aneksteind 9f35bbf
support foreign statics
aneksteind e789039
update doc FIX -> FIXED
aneksteind 795438a
walk reachable types and fields
aneksteind ddc074e
fix infinite recursion bug in lighttpd
aneksteind 91777bf
comment out breaking portions of lighttpd-minimal
aneksteind e52aa3e
CHECK-DAG -> CHECK-LABEL
aneksteind 1105f6b
CHECK-DAG -> CHECK-LABEL
aneksteind d4655d1
fix CHECK-LABEL failure
aneksteind 320d752
minor cosmetic changes
aneksteind de55129
docs
aneksteind f15d804
use adt_def instead of type_of given that the type is guaranteed to b…
aneksteind 9c856bc
Docstring
aneksteind a2e99a5
documentation of walk_args_and_fields
aneksteind 130bda9
add support for walking function pointer types
aneksteind d0a6aac
fn foreign_mentioned_tys
aneksteind 88472f7
walk_args_and_fields -> walk_ffi_safe_ty
aneksteind 79502f7
docs
aneksteind db64462
Revert "add support for walking function pointer types"
aneksteind e98ff18
simplify field walk
aneksteind 8e34144
simplify foreign_mentioned_tys(..)
aneksteind 0a4557d
walk_args_and_fields -> walk_adts
aneksteind b854368
simplify ADT walk
aneksteind 7893da8
update documentation
aneksteind File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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); | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't we need to substitute generics here? Then generic fields will just be
TyKind::Param
and we won't recognize that it may be an ADT or other type we need to recurse into.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh wait, that should be covered by
.walk
instead, right?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll indeed see
TyKind::Param
when visiting fields of generic structs, butwalk
will separately visit the type that would have been substituted in.walk(*mut Wrapper<Inner>)
will visitWrapper<Inner>
andInner
, so it's okay that the traversal of thex
field sees onlyTyKind::Param
instead ofInner
.