Skip to content
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 rust analyzer's "go to definition" on C loaned, owned, etc. types go to corresponding decl_c_type!(...) #785

Open
milyin opened this issue Oct 22, 2024 · 2 comments
Labels
internal Changes not included in the changelog

Comments

@milyin
Copy link
Contributor

milyin commented Oct 22, 2024

Describe the feature

Working on zenoh-c it's frequently necessary to know how rust and c-wrapper types are related.
For example:

  • I see type z_owned_bytes_t in the code
  • I want to know how what this type means
  • I press "F12" and see this blind type in opaque-types module
    #[repr(C, align(8))]
    pub struct z_owned_bytes_t {
      _0: [u8; 40],
     }
  • but what I really need is this:
     decl_c_type! {
        owned(z_owned_bytes_t, ZBytes),
        loaned(z_loaned_bytes_t),
    }

This may be disappointing to anyone who is trying to understand how zenoh-c works. This will slowdown our own performance, making learning curve for zenoh-c internals too steep for new developers and especially for ones who occasionally need to fix something.

The proposal is to declare some internal types in opaque_types instead of the final ones. And declare real API types z_owned_bytes_t, z_loaned_bytes_t, etc. inside decl_c_type! macro. In this case "go to definition" will go directly to this macro call with all necessary information

@milyin milyin added the internal Changes not included in the changelog label Oct 22, 2024
@DenisBiryukov91
Copy link
Contributor

I think the behavior as is is correct and does not need any change, if needed you can always search for something like "owned(z_owned_bytes_t".

@milyin
Copy link
Contributor Author

milyin commented Oct 24, 2024

I think the behavior as is is correct and does not need any change, if needed you can always search for something like "owned(z_owned_bytes_t".

It's correct but not convenient. When I go to type definition, I want to know how to use this type. The opaque type is completely blind and doesn't give any hints where to find additional information. So this is additional obstacle for ones who want to understand how the API works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
internal Changes not included in the changelog
Projects
Status: No status
Development

No branches or pull requests

2 participants