-
Notifications
You must be signed in to change notification settings - Fork 233
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
make mod_path()
consistent with/without nightly feature
#2330
base: main
Are you sure you want to change the base?
Conversation
The current implementation returns a module path with that feature on purpose, that's why the function is named as it is named. It should not be changed to flatten that into a single identifier. If the scaffolding generation doesn't work with the nightly feature, that's a bug. If some backend doesn't work with the nightly feature, you can try to adjust the backend to support it. The intent with this feature was to allow uniffi to generate bindings that consist of multiple modules, mirroring the Rust-side structure. |
That's why I provided the alternative. It's not a backend issue, but a scaffolding issue. As I described, identifiers seem to be created through the I'll adjust the PR to use the proposed alternative, which is replacing the columns with an underscore. |
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, but this still changes the function when the bug is in some of its usages. Specifically it seems like ffi_names.rs
is treating the module path like something that can be interpolated into a symbol name verbatim, and the same seems to be true in setup_scaffolding.rs
for some format_ident!
invocations.
All of the other uses of this function are correct and should stay the way they are.
I think there used to be some code there that replaced ::
with __
(double underscore), to make it a little more bullet-proof against name collisions. I'm guessing a refactoring changed that.
@jplatte This seems to be the commit that changed this. The return type used to be a I can take this on but since my ideas do not seem right, what's the expected behavior here? Should How certain are you that the other usages of the function are correct? |
I don't think it would be necessary to go back to Anyways, let's wait to hear what @bendk thinks. Good thing he authored that change, because he should be the most knowledgable person on the scaffolding generation in general :) |
2b1a18a
to
983fd7a
Compare
@jplatte I followed your advice and only normalized the usage of I assume the reason the module path is meant to be used as-is is that the Thanks for the guidance! Let me know if there's something else to change. |
The
nightly
version of themod_path()
function does not do the same thing as the one readingCargo.toml
.We'll only ever get the crate name from
Cargo.toml
, but thecore::module_path!()
macro will return the module path, with components separated by::
, as the Rust convention goes.The problem is that the crate name is the first element of
core::module_path!()
macro, and the current impl does not consider that. This might not have been visible if tested from thelib.rs
of a crate, since themodule_path == crate_name
, but UniFFI objects in nested modules will pose issues.If the desire is to hold on to the full module path, then we could at least replace the
::
with_
as otherwisesyn
complains that identifiers are not valid. Let me know if that's a better approach (though I think the behavior should be consistent with the non-nightly version).