commit | f2384037f82f9abeee3766a2beb23b54a2b50f9e | [log] [tgz] |
---|---|---|
author | Devin Jeanpierre <jeanpierreda@google.com> | Fri Mar 10 14:26:27 2023 -0800 |
committer | Copybara-Service <copybara-worker@google.com> | Fri Mar 10 14:27:04 2023 -0800 |
tree | 6643a49147add264fb50ba1da2b1975d9876e134 | |
parent | 68c7b62bc34d7b827dceb4e248f7527f93e4d6d4 [diff] |
Use `#[serde(deny_unknown_fields)]` for IR. https://serde.rs/container-attrs.html#deny_unknown_fields Unknown fields are always a bug, since we control both serialization and deserialization and they both come from the same version of the codebase. (Unlike traditional deserialization code, we don't need to deal with data that was generated a long time ago.) This is a common, and potentially confusing, source of bugs. As an example, during recent feature work I accidentally forgot to rename a field in `ir.rs` when renaming it in `ir.h`, and the result was that everything compiled and ran but did a subtly incorrect thing, which took time to debug. `deny_unknown_fields` would have prevented this. (We don't need to stop using `default`, because a mismatch in name will show up as both an unknown field and a defaulted field -- it's never a major or confusing bug to just have a defaulted field with no corresponding unknown field.) Note that the attribute isn't necessary for enums. [Fieldless enums](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=aeedbefac83cb6e73eb459927dcc3682) fail as one might expect even without the attribute, but so do [fieldful enums](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=b752164835f2b9d853f2ed1e669d1a36). PiperOrigin-RevId: 515738803
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.
$ 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
$ 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