Mark classes as `final` in the tests and goldens.

These I think were meant to be `final`, and their output was incorrect: when we correctly support non-`final` classes, the interfaces here will change to accept `impl Ctor<Output=T>`, not `T` itself.

---

A quick reminder why (since I often forget the details myself): `Pin<&mut T>` has a [`set(T)` method](https://doc.rust-lang.org/std/pin/struct.Pin.html#method.set), and base classes aren't safe to Rust-assign to (including via `set()`). This is true both because Rust-assignment destroys the target (UB for a base class), but also because Rust-assignment overwrites `sizeof(T)` bytes, and derived classes can live inside of that span (e.g. via [EBO](https://en.cppreference.com/w/cpp/language/ebo), though it's more general than that).

Because set exists, but must never be called, we forbid access to the raw `T` type. This ends up being the same as how we treat trivially relocatable functions. (However, note that this decision is reversible if we choose to stop using `Pin`.)  And so, even though it would obviously be safe to use a `T` by value in by-value parameters or return types, we forbid it anyway, because it would allow for unsafe behavior when you have references.

This explanation will become more salient with the followup change, which actually implements pass-by-value for `!Unpin` types (including non-`final` types). Woo!

PiperOrigin-RevId: 461824564
12 files changed
tree: 30c698a9f47044e947cafb7fbce22b94a06a6463
  1. .bazelci/
  2. bazel/
  3. cc_template/
  4. common/
  5. docs/
  6. lifetime_analysis/
  7. lifetime_annotations/
  8. migrator/
  9. nullability_verification/
  10. rs_bindings_from_cc/
  11. .bazelrc
  12. .gitignore
  13. BUILD
  14. Cargo.Bazel.lock
  15. CODE_OF_CONDUCT
  16. CONTRIBUTING
  17. LICENSE
  18. README.md
  19. WORKSPACE
README.md

Crubit: C++/Rust Bidirectional Interop Tool

Build status

Extremely experimental interop tooling for C++ and Rust.

Please don‘t use, this is an experiment and we don’t yet know where will it take us. There will be breaking changes without warning. Unfortunately, we can't take contributions at this point.

Building Crubit

$ apt install clang lld bazel
$ git clone git@github.com:google/crubit.git
$ cd crubit
$ bazel build --linkopt=-fuse-ld=/usr/bin/ld.lld //rs_bindings_from_cc:rs_bindings_from_cc_impl

Using a prebuilt LLVM tree

$ git clone https://github.com/llvm/llvm-project
$ cd llvm-project
$ CC=clang CXX=clang++ cmake -S llvm -B build -DLLVM_ENABLE_PROJECTS='clang' -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=install
$ cmake --build build -j
$ # wait...
$ cmake --install build
$ cd ../crubit
$ LLVM_INSTALL_PATH=../llvm-project/install bazel build //rs_bindings_from_cc:rs_bindings_from_cc_impl