Paolo Bonzini <pbonz...@redhat.com> writes:

> An extra benefit of workspaces is that they allow to place lint level
> settings in a single Cargo.toml; the settings are then inherited by
> packages in the workspace.
>
> Correspondingly, teach rustc_build_args.py to get the unexpected_cfgs
> configuration from the workspace Cargo.toml.
>
> Note that it is still possible to allow or deny warnings per crate or
> module, via the #![] attribute syntax.  The rust/qemu-api/src/bindings.rs
> file is an example.
>
> Signed-off-by: Paolo Bonzini <pbonz...@redhat.com>
> ---
>  meson.build                     |  8 +++++---
>  rust/Cargo.toml                 |  8 ++++++++
>  rust/hw/char/pl011/Cargo.toml   |  3 +++
>  rust/qemu-api-macros/Cargo.toml |  3 +++
>  rust/qemu-api/Cargo.toml        |  5 ++---
>  rust/qemu-api/meson.build       |  2 +-
>  scripts/rust/rustc_args.py      | 31 +++++++++++++++++++++++++++----
>  7 files changed, 49 insertions(+), 11 deletions(-)
>
[snip]
> diff --git a/rust/Cargo.toml b/rust/Cargo.toml
> index 0c94d5037da..0230b92a9fa 100644
> --- a/rust/Cargo.toml
> +++ b/rust/Cargo.toml
> @@ -5,3 +5,11 @@ members = [
>      "qemu-api",
>      "hw/char/pl011",
>  ]
> +
> +[workspace.lints.rust]
> +unexpected_cfgs = { level = "warn", check-cfg = [
> +    'cfg(MESON)', 'cfg(HAVE_GLIB_WITH_ALIGNED_ALLOC)',
> +    'cfg(has_offset_of)'] }
> +

Making a universal unexpected_cfgs apply to the whole workspace may lead
to a lengthy cfg list when more devices in Rust are added. As cargo does
not allow overriding workspace-defined lints once inherited, I think it
better to keep unexpected_cfgs crate-specific.

--
Best Regards
Junjie Mao

Reply via email to