Paolo Bonzini <pbonz...@redhat.com> writes:
> On Mon, Oct 21, 2024 at 8:16 AM Zhao Liu <zhao1....@intel.com> wrote: >> unsafe_op_in_unsafe_fn is allowed in >> rust/qemu-api/src/lib.rs. So should we wrap the bindings in a separate >> lib (similar to the rust/bindings in the Linux kernel)? >> >> This way, the special lint settings can be applied only to the binding >> files, while the default lint checks can cover the other user >> development code. >> >> In addition, another thing that confuses me is why bindgen still >> generates code that does not follow the unsafe_op_in_unsafe_fn >> requirement. It seems that bindgen has supported unsafe_op_in_unsafe_fn >> since v0.62 [1, 2], but binding code we generated still violates >> unsafe_op_in_unsafe_fn. Is this a bug of bindgen? > > The plan is to support older versions of bindgen (0.60.x) as long as > Debian has them. One possibility to fix this is, as you said, to use a > completely separate crate. Another is to add #![allow()] to just the > bindings module, for example by changing bindgen.rs to > > #![allow(...)] > include!("bindgen.rs.inc") > > This is related to the fact that we don't have yet a good way to run > "clippy", because "cargo clippy" needs the bindgen.rs file. So we > should probably look at these issues at once. > > Paolo Since meson 0.6.0 clippy-driver can be used as a wrapper of rustc. So we can run clippy by: mkdir build.clippy && cd build.clippy RUSTC=clippy-driver ../configure --enable-rust ... ninja librust_x86_64_softmmu.a -- Best Regards Junjie Mao