qemu/Cargo.toml
Paolo Bonzini 64574f1c51 rust: pl011: switch from bilge to bitfield-struct
The bilge crate is heavily reliant on traits and, because trait functions
are never const, bilge and const mix about as well as water and oil.
In addition, it has support for the zerocopy crate that only works for an
older version, and is hard to update because the implementation doesn't
like that zerocopy::FromBits and bilge::FromBits are the same name.
zerocopy is definitely something that QEMU could use in the future.

The bitfield-struct crate, instead, is built from the ground up to
support const.  Its use is pretty much the same (device code does not
change at all, only register declarations do), with some things being
more verbose and others being simpler.  The code for the crate itself
is much smaller, too.

It does have two disadvantages: it does not let you annotate enums
as bitfields, and it does not integrate with arbitrary-int.  Thus, it
requires manual size annotations for anything that is not a bool, iNN
or uNN.  Lack of support for arbitrary-int is a very small deal, while
enums are a bit more annoying because they require some repetition
and an implementation of two functions from_bits() and into_bits().
However, the latter is already provided by the "bits!"  and
"#[derive(common::TryInto)]" utilities, and thus is not manual
in QEMU's case.

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-08-20 09:24:57 +02:00

106 lines
2.9 KiB
TOML

[workspace]
resolver = "2"
members = [
"rust/hw/char/pl011",
"rust/hw/timer/hpet",
"rust/tests",
]
[workspace.package]
edition = "2021"
homepage = "https://www.qemu.org"
license = "GPL-2.0-or-later"
repository = "https://gitlab.com/qemu-project/qemu/"
# don't forget to update docs/devel/rust.rst msrv
rust-version = "1.83.0"
authors = ["The QEMU Project Developers <qemu-devel@nongnu.org>"]
[workspace.dependencies]
anyhow = "~1.0"
foreign = "~0.3.1"
libc = "0.2.162"
glib-sys = { version = "0.21.2", features = ["v2_66"] }
[workspace.lints.rust]
unexpected_cfgs = { level = "deny", check-cfg = ['cfg(MESON)'] }
# Occasionally, we may need to silence warnings and clippy lints that
# were only introduced in newer Rust compiler versions. Do not croak
# in that case; a CI job with rust_strict_lints == true disables this
# and ensures that we do not have misspelled allow() attributes.
unknown_lints = "allow"
# Prohibit code that is forbidden in Rust 2024
unsafe_op_in_unsafe_fn = "deny"
[workspace.lints.rustdoc]
private_intra_doc_links = "allow"
broken_intra_doc_links = "deny"
invalid_html_tags = "deny"
invalid_rust_codeblocks = "deny"
bare_urls = "deny"
unescaped_backticks = "deny"
redundant_explicit_links = "deny"
[workspace.lints.clippy]
# default-warn lints
result_unit_err = "allow"
manual_checked_ops = "deny"
should_implement_trait = "deny"
# can be for a reason, e.g. in callbacks
unused_self = "allow"
# common in device crates
upper_case_acronyms = "allow"
# default-allow lints
as_ptr_cast_mut = "deny"
as_underscore = "deny"
assertions_on_result_states = "deny"
bool_to_int_with_if = "deny"
cast_lossless = "deny"
dbg_macro = "deny"
debug_assert_with_mut_call = "deny"
derive_partial_eq_without_eq = "deny"
doc_markdown = "deny"
empty_structs_with_brackets = "deny"
ignored_unit_patterns = "deny"
implicit_clone = "deny"
macro_use_imports = "deny"
missing_safety_doc = "deny"
mut_mut = "deny"
needless_bitwise_bool = "deny"
needless_pass_by_ref_mut = "deny"
needless_update = "deny"
no_effect_underscore_binding = "deny"
option_option = "deny"
or_fun_call = "deny"
ptr_as_ptr = "deny"
ptr_cast_constness = "deny"
pub_underscore_fields = "deny"
redundant_clone = "deny"
redundant_closure_for_method_calls = "deny"
redundant_else = "deny"
redundant_pub_crate = "deny"
ref_binding_to_reference = "deny"
ref_option_ref = "deny"
return_self_not_must_use = "deny"
same_name_method = "deny"
semicolon_inside_block = "deny"
shadow_unrelated = "deny"
significant_drop_in_scrutinee = "deny"
significant_drop_tightening = "deny"
suspicious_operation_groupings = "deny"
transmute_ptr_to_ptr = "deny"
transmute_undefined_repr = "deny"
type_repetition_in_bounds = "deny"
uninlined_format_args = "deny"
used_underscore_binding = "deny"
# nice to have, but cannot be enabled yet
#wildcard_imports = "deny" # still have many bindings::* imports
# these may have false positives
enum_variant_names = "allow"
#option_if_let_else = "deny"
cognitive_complexity = "deny"