-
-
Notifications
You must be signed in to change notification settings - Fork 109
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
Unions: Remove feature-gate for stable rustc #415
Conversation
Travis build failure is legit |
src/codegen/sys/statics.rs
Outdated
let v = vec![ | ||
u, | ||
"#![feature(untagged_unions)]", |
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.
This line unneeded just "" instead
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, 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
Compare
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. |
src/codegen/sys/lib_.rs
Outdated
@@ -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)); |
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.
This not correct too, you lost comment
text
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.
🤦 🤦 🤦
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"
|
src/codegen/sys/lib_.rs
Outdated
@@ -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" { |
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 this don't removed?
src/codegen/sys/lib_.rs
Outdated
@@ -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 { |
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 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", |
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.
This better changed back (it will produce only 1 extra "dont_copy")
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.
..because it just don't right, copy record with unknown size
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.
I'm not sure I understand, pub struct GIConv(u8);
should not be copy?
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.
Yes, with GIOChannel
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 sure I understand either. What is the broken code generated by this?
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.
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
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.
I see... a case for the new #[repr(transparent)] I guess
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.
Sorry, now I don't understand how it related to struct without fields.
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.
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
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.
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 |
src/codegen/sys/lib_.rs
Outdated
if lines.is_empty() { | ||
try!(writeln!( | ||
w, | ||
"{0}#[repr(C)]\n{0}#[derive(Copy,Clone)]\n{0}pub union {1}(c_void);\n", |
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.
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.