rust: build: generate lint flags from Cargo.toml

Cargo.toml makes it possible to describe the desired lint level settings
in a nice format.  We can extend this to Meson-built crates, by teaching
rustc_args.py to fetch lint and --check-cfg arguments from Cargo.toml.
--check-cfg arguments come from the unexpected_cfgs lint as well as crate
features

Start with qemu-api, since it already has a [lints.rust] table and
an invocation of rustc_args.py.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
Paolo Bonzini 2024-11-07 10:02:15 +01:00
parent 1de82059aa
commit 97ed1e9c8e
3 changed files with 86 additions and 4 deletions

View file

@ -120,7 +120,8 @@ if have_rust
endif
if have_rust
rustc_args = find_program('scripts/rust/rustc_args.py')
rustc_args = [find_program('scripts/rust/rustc_args.py'),
'--rustc-version', rustc.version()]
rustfmt = find_program('rustfmt', required: false)
# Prohibit code that is forbidden in Rust 2024