-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Fix generating bindings for dead code #8065
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| package a:b; | ||
|
|
||
| world imports { | ||
| import interface-with-live-type; | ||
| import interface-with-dead-type; | ||
| } | ||
|
|
||
| interface interface-with-live-type { | ||
| record live-type { | ||
| a: u32, | ||
| } | ||
| f: func() -> live-type; | ||
| } | ||
|
|
||
|
|
||
| interface interface-with-dead-type { | ||
| use interface-with-live-type.{live-type}; | ||
|
|
||
| record dead-type { | ||
| a: u32, | ||
| } | ||
|
|
||
| variant v { | ||
| a(live-type), | ||
| b(dead-type), | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,6 +40,14 @@ impl std::ops::BitOrAssign for TypeInfo { | |
|
|
||
| impl Types { | ||
| pub fn analyze(&mut self, resolve: &Resolve, world: WorldId) { | ||
| // Build up all type information first which is inherited through types, | ||
| // such as properties of borrows/lists/etc. | ||
| for (t, _) in resolve.types.iter() { | ||
| self.type_id_info(resolve, t); | ||
| } | ||
|
Comment on lines
+45
to
+47
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does doing this step first mean that the calls to
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not for this, but the below bits would still need it for setting the owned/borrowed bits. It's probably best to switching this to |
||
|
|
||
| // ... next handle borrowed/owned flags which aren't inherited through | ||
| // types. | ||
| let world = &resolve.worlds[world]; | ||
| for (import, (_, item)) in world | ||
| .imports | ||
|
|
||
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.
Not clear to me how this tests liveness since both interfaces are part of the imports?
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.
Ah good point, I should clarify, liveness is calculated in terms of what's used by imported/exported functions. No function actually uses
dead-typeorvbutlive-typeis used by a function, and so we don't generate bindings fordead-typeand this PR fixes a bug where we previously tried to generate bindings forvdespite nothing using it.