Re: [TECH TOPIC] Rust for Linux

Miguel Ojeda
2021-07-20T01:46:24Z

On Mon, Jul 19, 2021 at 11:33 PM Arnd Bergmann <arnd@arndb.de> wrote:
>
> I'm worried that this makes things harder to grep for, and to document,
> when the same structure is used in both Rust and C.

For the former, by grepping you should find the Rust abstractions that
use the C structures, because binding generation does not change the
names or their case. Of course, the Rust abstractions on top of that
is a different matter, but those do not exist in C anyway. So, at
least for the use case of searching Rust abstractions that use a given
C structure or API, it should be fine.

For the latter, we started linking the C code and/or docs from the
Rust ones. We do it manually now, but ideally we should be able to
reference C docs (and/or code) just by writing the C name, something
like:

/// Similar to a C [`spinlock_t`].

This is a feature that already works for Rust definitions and we use
it all the time, but not for C ones (obviously). My current plan is to
have `rustdoc` support a "external references map" that is added to
the internal map of Rust "intra-doc" links that it already has. With
that, we could have Sphinx generate the map of references pointing to
its own docs.

Cheers,
Miguel