-
-
Notifications
You must be signed in to change notification settings - Fork 108
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
signals: work-around ObjectType shadowing #1627
base: main
Are you sure you want to change the base?
Conversation
It is shadowed by what? |
|
f3d3060
to
bffcc22
Compare
I think a better solution would be for ostree to rename the enum to something else |
In the bindings, not in the C library (where it would be a breaking change). But also I think we should generally import traits as |
That would be a breaking change to a library that has existed for a long time... Personally, I'd prefer if
Line 106 in 61370e8
|
Happy to swap |
Yeah I completely agree with all that :) It "just" needs someone to untangle the code.
Both seems fine to me and I'm not sure why @bilelmoussaoui was against that. As you say, we do the same for As this is a trait and never used by name, |
I would do the change in prelude then. I am against this change because it confuses tools like rust analyzer. I wouldn't do what was done 9 years ago with Box and just fully qualify the std usages without importing the type. |
If |
Sure. But anyways, the change should be done on prelude as adding more imports to the generated code makes it more fragile to changes in prelude or where the traits are defined. |
That's a good point, I missed that this adds an import instead of just renaming it. Going with gtk-rs/gtk-rs-core#781 is probably a better idea indeed. That would mean changing |
Bear with me here just because I don't have a good knowledge of the gtk-rs ecosystem, I want to make sure I understand: Sounds like consensus is to rename the reexports in glib's prelude to That should fix the issue I described with libostree. Separate from that, for consistency's sake and so this doesn't become an issue with other traits, you'd like to modify other projects in the ecosystem to do the same thing (gir should generate anonymous exports in This is definitely a breaking change, but it's probably not a big deal because very few people are likely referencing those traits by name, right? I can submit a PR for the glib change. |
Yeah that's correct. Just updating the
That's fine, it would be released with the next breaking release in summer. You probably need this solved earlier though, in which case we could consider a temporary workaround like this here (just make it |
bffcc22
to
29f6cf7
Compare
Ok. I replaced the commit with one that imports as |
@sdroege So, it actually looks like glib itself makes extensive use of having the prelude type names in-scope. I could explicitly include all the traits in glib where they're needed, but it is somewhat convenient to have them in a prelude still for commonly-used stuff. Another option would be to make a separate Another thing I could do is to have prelude continue exporting by name, but also anonymously: I do wish that rust supported something like Let me know what you prefer! |
That's tricky. Outside glib, do you think any of the traits make sense to be re-exported from the prelude by name? |
I don't think so? When I wrote some rust gtk4 stuff, I'm pretty sure those trait implementations came automatically from macros, but it's been a while so I really can't remember. |
I think then the glib prelude shouldn't re-export them by name. The prelude is meant for outside code. @bilelmoussaoui Do you think any of the prelude traits should be available by name? |
Related to #772
This is needed because
use glib::prelude::*
will not pull inObjectType
(even though we only need the trait in scope) because it's shadowed.Another way to fix this is by using a fully-qualified path to
ObjectType
at the call-site (happy to submit another PR for that if that's preferred, I do have one somewhere...), but this is more consistent with what's already being done.