The GitHub Actions job "mainline-only" on tvm-ffi.git/main has succeeded.
Run started by GitHub user tqchen (triggered by tqchen).

Head commit for run:
a35b3eab56e577dd5414f8a53b941111cd3cc08e / Linzhang Li 
<[email protected]>
[STUBGEN][RUST] Rename the wrapper slot to `base` and tighten `rust_ident` 
(#742)

## Summary

For every reflected object the Rust target emits two structs: `XObj`,
the `#[repr(C)]` mirror whose first field `base` holds the parent, and
`X`, the reference wrapper that owns an `ObjectArc<XObj>`. That wrapper
field was named `data`, which made `base` and `data` the two names a
reflected field could not use; `rust_ident` spelled such fields `base_`
/ `data_`, and TVM has both (`tirx.Ramp.base`, `tirx.DeclBuffer.data`).
This PR names the wrapper field `base` too, so `base` is the only
reserved name and a reflected `data` stays `data`. `derive(ObjectRef)`
now takes the slot name from the struct's first field instead of
requiring `data`, so the crate's own wrappers and the generated ones
both derive. `rust_ident` also becomes exact: it unwraps a single
trailing underscore (`imports_` -> `imports`) and a dunder name
(`__dict__` -> `dict`) and leaves every other spelling alone, instead of
stripping all trailing underscores.

## Changes

- `rust/tvm-ffi-macros/src/object_macros.rs`: `derive_object_ref` reads
the first field's identifier and emits it in `data` / `into_data` /
`from_data` and the `Any` conversions, instead of hard-coding `data`.
- `rust_generator/codegen.py`: the wrapper struct, its `Deref`, and the
allocator body use `base`.
- `rust_generator/consts.py`: `RUST_RESERVED_MEMBERS = {"base"}`.
- `rust_generator/utils.py`: `rust_ident` maps `name_` and `__name__` to
`name`; `__name`, `_name`, `name__`, `_` stay verbatim.
- `examples/rust_stubgen/`: regenerated `mod.rs`; `test_rust_ident` and
the goldens updated.

## Testing

`test_stubgen_rust.py`, `test_stubgen.py`, `test_stub_layout.py`: 121
passed; ruff clean. `cargo test` in `rust/` passes with the macro
change. The example regenerates an identical `mod.rs` and `cargo run`
prints `a=1 b=2 kind=PairKind(1)` and `sum=3`.

Signed-off-by: yuchuan <[email protected]>

Report URL: https://github.com/apache/tvm-ffi/actions/runs/33937544717

With regards,
GitHub Actions via GitBox


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to