You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Update Rust generator to output minidescriptors instead of C minitables
With this change, we no longer emit any C generated code for the Rust upb
implementation. Instead, we output minidescriptors in the Rust generated code,
and use these to construct the minitables at run time. Each message's
`AssociatedMiniTable::mini_table()` method will lazily build the minitable on
first use.
We need a place to put the minidescriptor and lazily-built minitable for enums,
so I added a new `AssociatedMiniTableEnum` trait for this purpose. This is
only necessary for closed enums.
There are a couple of things that were somewhat difficult about building the
minitables at runtime:
- Each map entry is represented as its own implicit message type and needs a
minitable. To facilitate this, I updated the generator to output a
visibility-controlled struct to represent each map entry. This way we can
implement `AssociatedMiniTable` on it and treat it like any other message
for the purpose of building minitables.
- The naive way of recursively building minitables is vulnerable to deadlock
in the case of cycles in the message graph. Such cycles are allowed within a
single .proto file, so we need to be able to handle this. My change handles
this problem by treating each strongly-connected component (SCC) as its own
unit, and then the graph of SCCs has no cycles. Each SCC has an arbitrariliy
chosen representative responsible for linking all messages in the SCC.
PiperOrigin-RevId: 761654774
0 commit comments