-
Notifications
You must be signed in to change notification settings - Fork 286
Do not rewrite ADTs mentioned in extern blocks #960
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
Merged
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
b90b646
Addresses #948
oinoom aa23b35
use extern "C" in test case
oinoom 9f35bbf
support foreign statics
oinoom e789039
update doc FIX -> FIXED
oinoom 795438a
walk reachable types and fields
oinoom ddc074e
fix infinite recursion bug in lighttpd
oinoom 91777bf
comment out breaking portions of lighttpd-minimal
oinoom e52aa3e
CHECK-DAG -> CHECK-LABEL
oinoom 1105f6b
CHECK-DAG -> CHECK-LABEL
oinoom d4655d1
fix CHECK-LABEL failure
oinoom 320d752
minor cosmetic changes
oinoom de55129
docs
oinoom f15d804
use adt_def instead of type_of given that the type is guaranteed to b…
oinoom 9c856bc
Docstring
oinoom a2e99a5
documentation of walk_args_and_fields
oinoom 130bda9
add support for walking function pointer types
oinoom d0a6aac
fn foreign_mentioned_tys
oinoom 88472f7
walk_args_and_fields -> walk_ffi_safe_ty
oinoom 79502f7
docs
oinoom db64462
Revert "add support for walking function pointer types"
oinoom e98ff18
simplify field walk
oinoom 8e34144
simplify foreign_mentioned_tys(..)
oinoom 0a4557d
walk_args_and_fields -> walk_adts
oinoom b854368
simplify ADT walk
oinoom 7893da8
update documentation
oinoom 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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::Paramand 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
.walkinstead, 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::Paramwhen visiting fields of generic structs, butwalkwill 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 thexfield sees onlyTyKind::Paraminstead ofInner.