Unions: Remove feature-gate for stable rustc #415
Conversation
Travis build failure is legit |
let v = vec![ | ||
u, | ||
"#![feature(untagged_unions)]", |
EPashkin
Jul 22, 2017
Member
This line unneeded just "" instead
This line unneeded just "" instead
flukejones
Jul 22, 2017
•
Author
Contributor
Ah, yes. I was using nightly rust still.
Ah, yes. I was using nightly rust still.
Only last problem with |
Not sure how to go about Changing |
@Luke-Nukem Lets wait for other say their options. For |
@EPashkin no problem. I do know we absolutely shouldn't (and can't) implement |
Hm, I don't though that some structures can be large and |
83d94a7
to
e9a7910
last commit produce strange diff: // Records
#[repr(C)]
-pub struct GArray {
+GArraypub struct GArray {
pub data: *mut c_char,
pub len: c_uint,
} |
Oh dear, looks like I'm making a mess of git. Hang on, I'll try and fix this up. |
The sys crates I've compiled so far seem to be fine now. |
@@ -434,7 +434,7 @@ fn generate_records(w: &mut Write, env: &Env, records: &[&Record]) -> Result<()> | |||
if record.derive_copy { | |||
try!(writeln!(w, "{}#[derive(Copy,Clone)]", comment)); | |||
} | |||
try!(writeln!(w, "{0}pub struct {} {{", record.c_type)); | |||
try!(writeln!(w, "pub struct {} {{", record.c_type)); |
EPashkin
Jul 22, 2017
Member
This not correct too, you lost comment
text
This not correct too, you lost comment
text
flukejones
Jul 22, 2017
Author
Contributor
🤦 🤦 🤦
Added back, squashed last series of commits. Should be good now.
🤦 🤦 🤦
Added back, squashed last series of commits. Should be good now.
Only last questionable problems with |
With |
Seems |
I guess that's just a side effect of how things are parsed then read out. Not sure what we can do about it other than just leave it. Or add in a special case for it? Do you think that is the only problem area? |
Just short comments
So in summary, I don't know. Making all Copy seems fine to me, a configuration also. Both are ugly in their own ways and in practice it probably makes no difference |
@sdroege the one problem with making all Copy though, is that there will be some things that shouldn't be or are inherently non-copy. I think Copy on pointers... iirc raw pointers are fine and safe for copy, it's only when we deref them that it's unsafe. (?) |
For pointers, correct. You just need to be careful to free all copies later, I.e. do double-frees. But that's already with plain pointers |
@GuillaumeGomez what you think about implementing |
That's something I proposed not that long ago so I'm totally for it! |
@Luke-Nukem sorry for delay, I thought that I already asked. |
Sorry about the delay here, I'll push through an update soon. Was a bit tied up with study this week. |
I'm not sure about Appveyor is pretty far behind in rust versions isn't it... |
Suggestions? |
About old appveyour version: added fix #420 |
As gtk has single problem too, IMHO better add config parameter for object like "dont_copy=true"
|
@@ -574,7 +516,7 @@ fn generate_fields(env: &Env, struct_name: &str, fields: &[Field]) -> (Vec<Strin | |||
if c_type.is_err() { | |||
commented = true; | |||
} | |||
if !cfg!(feature = "use_unions") && is_gvalue && field.name == "data" { | |||
if is_gvalue && field.name == "data" { |
EPashkin
Jul 29, 2017
Member
Why this don't removed?
Why this don't removed?
@@ -565,7 +507,7 @@ fn generate_fields(env: &Env, struct_name: &str, fields: &[Field]) -> (Vec<Strin | |||
continue 'fields; | |||
} | |||
|
|||
if is_gweakref && !cfg!(feature = "use_unions") { | |||
if is_gweakref { |
EPashkin
Jul 29, 2017
Member
Why this don't removed?
Why this don't removed?
@@ -444,7 +417,7 @@ fn generate_records(w: &mut Write, env: &Env, records: &[&Record]) -> Result<()> | |||
if lines.is_empty() { | |||
try!(writeln!( | |||
w, | |||
"{}#[repr(C)]\n{0}pub struct {}(c_void);\n", | |||
"{0}#[repr(C)]\n{0}#[derive(Copy,Clone)]\n{0}pub struct {1}(u8);\n", |
EPashkin
Jul 29, 2017
•
Member
This better changed back (it will produce only 1 extra "dont_copy")
This better changed back (it will produce only 1 extra "dont_copy")
EPashkin
Jul 29, 2017
Member
..because it just don't right, copy record with unknown size
..because it just don't right, copy record with unknown size
flukejones
Jul 29, 2017
Author
Contributor
I'm not sure I understand, pub struct GIConv(u8);
should not be copy?
I'm not sure I understand, pub struct GIConv(u8);
should not be copy?
EPashkin
Jul 29, 2017
Member
Yes, with GIOChannel
Yes, with GIOChannel
sdroege
Jul 29, 2017
Member
Not sure I understand either. What is the broken code generated by this?
Not sure I understand either. What is the broken code generated by this?
EPashkin
Jul 29, 2017
Member
this case produce warning: found non-foreign-function-safe member in struct marked #[repr(C)]: found Rust tuple type in foreign module; consider using a struct instead
just struct produce warning: found zero-size struct in foreign module, consider adding a member to this struct
this case produce warning: found non-foreign-function-safe member in struct marked #[repr(C)]: found Rust tuple type in foreign module; consider using a struct instead
just struct produce warning: found zero-size struct in foreign module, consider adding a member to this struct
sdroege
Jul 29, 2017
Member
I see... a case for the new #[repr(transparent)] I guess
I see... a case for the new #[repr(transparent)] I guess
EPashkin
Jul 29, 2017
Member
Sorry, now I don't understand how it related to struct without fields.
Sorry, now I don't understand how it related to struct without fields.
sdroege
Jul 29, 2017
Member
You would want to represent an opaque C type. It's not really a struct without fields, it's just that the struct definition is unknown from the headers. So you can only ever use it as a pointer.
But that's actually extern type
: rust-lang/rfcs#1861
You would want to represent an opaque C type. It's not really a struct without fields, it's just that the struct definition is unknown from the headers. So you can only ever use it as a pointer.
But that's actually extern type
: rust-lang/rfcs#1861
EPashkin
Jul 29, 2017
Member
extern type
is that we need for this case but it not realized and may cause build error when inserted in other struct directly (as with GIConv
)
#[repr(transparent)]
can be used for minimize alignment errors for known fields, so also not for this case, so last repr(C)
.
I prefer c_void
over u8
as it don't implement Copy
while has same size and alignment.
extern type
is that we need for this case but it not realized and may cause build error when inserted in other struct directly (as with GIConv
)
#[repr(transparent)]
can be used for minimize alignment errors for known fields, so also not for this case, so last repr(C)
.
I prefer c_void
over u8
as it don't implement Copy
while has same size and alignment.
About |
if lines.is_empty() { | ||
try!(writeln!( | ||
w, | ||
"{0}#[repr(C)]\n{0}#[derive(Copy,Clone)]\n{0}pub union {1}(c_void);\n", |
EPashkin
Jul 29, 2017
Member
Copy
better removed as for records
PS. this code actually unused.
Copy
better removed as for records
PS. this code actually unused.
@EPashkin can you advise where I would look for examples of how to do this? |
Add field to GObject same as https://github.com/gtk-rs/gir/blob/master/src/config/gobjects.rs#L151
|
.. As |
I need to put this on the backlog for a week or so while I do a few other things of importance. I may work on it off/on through the week however, we'll see. |
What's the status here? |
I've not had much free time. I'll try and get a look at it again this week,
I should be able to juggle my schedule a bit.
…On 18/09/2017 8:03 PM, "Sebastian Dröge" ***@***.***> wrote:
What's the status here?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#415 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AB7Cfsc3v_nuFfAeRZFZYm3CzjgQcSsuks5sjiPagaJpZM4Of-Go>
.
|
IMHO just having copy on all FFI things is fine, configuration can be added later once needed :) |
Okidoki, then this may be good to go if edge cases are okay.
…On 25 October 2017 at 21:59, Sebastian Dröge ***@***.***> wrote:
IMHO just having copy on all FFI things is fine, configuration can be
added later once needed :)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#415 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AB7CfrQG3LWkO6JcR6tH2eXYFTh7M9SFks5svvhigaJpZM4Of-Go>
.
|
Tests will pass with this commit to cairo. I get the impression that this is going to require a more in-depth solution rather than just implement |
Removes all feature-gating of
union
, and now requires rust 1.19Updates readme to reflect this.