-
Notifications
You must be signed in to change notification settings - Fork 321
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
Handle fully qualified paths and use
aliases
#7
Comments
My comments earlier were wrong.
|
Any updates on this? I've got multiple
|
Unfortunately, I'm not sure there is a workaround yet besides renaming the types. My first thought would have been to use the structs behind type aliases with different names, but that won't work if you want to expose them.. I don't currently have specific plans on implementing this. Unfortunately this is a tricky issue with a couple different options.
I've been told by @gankro that option 1 is not going to be fun as this is a very complicated and not well understood part of rustc and has evolved. I think this part of the rust reference is relevant. Using rls-analysis could be viable, but needs investigation. My concern with using rls would be if it is using a lossy/mostly correct goto definition feature and not focused on strict correctness. I have no idea of how feasible option 3 would be. |
use
aliases
Issue: Import renames à la
|
Issue: Incorrect type resolving for differently scoped types of same name.A minimalistic crate like this … // lib.rs
pub mod foo {
pub struct Foobar<T> { pub field: T }
}
pub mod bar {
pub struct Foobar { pub field: u8 }
#[no_mangle]
pub unsafe extern "C" fn placebo(_foobar: &Foobar) {}
} … generates a header like this … // lib.h
#include <cstdint>
#include <cstdlib>
template<typename T>
struct Foobar;
extern "C" {
void placebo(const Foobar *_foobar);
} // extern "C" … while it should generate something like this instead: #include <cstdint>
#include <cstdlib>
struct Foobar;
extern "C" {
void placebo(const Foobar *_foobar);
} // extern "C" What's wrong:
Observations:
(Cross-posted from #199, which was closed in favor of this original issue) |
I just pushed a PR (#201) that aims to move us a bit closer towards a direction of fixing this. |
This is an issue with https://github.com/KZen-networks/multi-party-ecdsa |
Did #233 fix this? |
Not really, though it added the infrastructure to potentially do it. |
Any updates here? Would love to see this implemented 🙏 |
Can you elaborate on this a bit? I know nothing about the internals of this project but would really like to see this feature implemented 😅 |
@UebelAndre A look at the diff shows that the PR replaces the use of bare strings with pub struct Path {
name: String,
} As such the PR has improved type-safety, but has not actually made the jump from "name-based" to "full qualified path-based", unlike what the name might suggest. |
…andling issues Issues: * mozilla/cbindgen#7 * mozilla/cbindgen#286 * mozilla/cbindgen#573
…andling issues Issues: * mozilla/cbindgen#7 * mozilla/cbindgen#286 * mozilla/cbindgen#573
…andling issues Issues: * mozilla/cbindgen#7 * mozilla/cbindgen#286 * mozilla/cbindgen#573
My workaround for the "Issue: Import renames à la use Foo as Bar; are not resolved properly." issue is a macro for opaque newtype wrapping.
(where the This only works in my specific case because these types are opaque (they're always provided behind a pointer). I don't know a workaround for non-opaque types. |
hyper has plenty of structs named
|
Each Rust
Item
has a path that includes the crate and mods needed to get to it. Currentlycbindgen
just ignores all segments of a path except the last one, which is the name of the item.This works as long as there are no duplicates in different modules, but isn't correct and will probably cause someone an issue someday.
The text was updated successfully, but these errors were encountered: